Thursday, April 18, 2013

FQL: query user table by name

I was trying to find Facebook user by querying by name in the user table. According to the Facebook documentation, the name field of user table is indexable. Therefore, logically it is possible to query by name.

But when I query user table by name field, it gives me the error with code 604.

The error message is "Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from http://developers.facebook.com/docs/reference/fql "

The name field of user table is marked with * in the facebook documentation; https://developers.facebook.com/docs/reference/fql/user/.

----

I have googled about it and found the solution in stackoverflow. It says to run the query on profile table by name and get the id of the user. Then query the user table by the id.

SELECT uid FROM user WHERE uid IN (SELECT id FROM profile WHERE name="kamrul hassan")

Source: http://stackoverflow.com/questions/13793567/fql-filter-user-table-by-name

Wish this will help you.

Monday, March 25, 2013

Show "Post" count by searching in Wordpress



Sometimes in Wordpress, we need to perform custom search in our blog or site. It is not difficult to perform custom search. When I wanted to show the number of post found after search, I got problem. After google about it, I found the following easy solution.


  echo wp_specialchars($s); // printing the keyword
  $allsearch = &new WP_Query("s=$s&showposts=-1");
  $count = $allsearch->post_count;
  echo ' (' . $count . ') '; // printing the founded post count
  wp_reset_query();

I wish this will help you.

Selecting multiple element from a List using Lambda Expression

I was searching an easy way to select multiple entry form a List of objects using Lambda Expression by matching their IDs. It can be done easily using a loop but I don't wanna use a loop in my code just for this. Finally I found it and it is very easy.

Consider you have a List of objects where each object has an field called ID. You want to extracts 5 elements from that List by matching the ID. The size of the list maybe few thousand.

Just use for following code, and you are done



List someListOfIds = new List(700, 1234, 3412, 400, 10); mainlist.Where(x => someListOfIds.Contains(x.ID));

This technique helps us to find few date from the Database by avoiding complex nested query if you don't love writing those query :)

Thursday, July 15, 2010

ASP.net redirect to another page

One can use one of the following three commands to redirect in another page. On button click, this command can also be used. 

Response.Redirect("Page1.aspx");

Server.Transfer("Page2.aspx");

Tuesday, May 11, 2010

Read and write NTFS from Mac OS X

To perform read, write action of NTFS file system from Mac OS X (Snow Leopard), just install the following two software.

1. MacFUSE first. "MacFUSE allows you to extend Mac OS X's native file handling capabilities via 3rd-party file systems."
Download from: http://code.google.com/p/macfuse/
2. Secondly NTFS-3G.  "NTFS-3G is an open source cross-platform implementation of the Microsoft Windows NTFS file system with read-write support. NTFS-3G often uses the FUSE file system interface, so it can run unmodified on many different operating systems".
Download link (Last accessed May 10, 2010)
Blog: http://macntfs-3g.blogspot.com/



Done. Now enjoy :)