By Nitin on October 3, 2009
Recently, while working on my project FeedAPI ImageGrabber I came across the issue where I had to select HTML elements by a given css class. The HTML element can have a single CSS class:
or multiple CSS classes associated with it.
1
| <div class="foo exp tar"></div> |
Now if you want to select the HTML elements with class “foo”, this div element would be one of them.
Continue reading “PHP: Select HTML elements with more than one css class using XPath”
Posted in Drupal | Tagged css, Drupal, php, xpath
By Nitin on September 20, 2009
I get a lot of requests for this, so here is a tutorial explaining the 3 W’s (What, Why and How) of FeedAPI ImageGrabber.
Motivation

a feed item from google reader
This is a screenshot of a news item from my Google Reader. Anyone who has a moderate knowledge about the feeds would know that the image on the left in the above news-item is actually not published with the feed.
In other words, If you refresh any feed on your Drupal website using FeedAPI, you won’t get the image in the posts, unless they are published along with the feed which is quite rare.
The purpose of FeedAPI Imagegrabber is to make the feed more informative as well as interesting for the user. As, we all know that “comics are much better than novels”, this module appends the feed-item with an appropriate image from its content URL. The goal of the FeedAPI ImageGrabber is to mimic the thumbnail display of Google Reader for the feeds on your Drupal website.
As soon as you refresh the feed, ImageGrabber automatically attaches an appropriate image from the original article to the feed-item node on your website. You don’t even have to press an extra button!!
Continue reading “Tutorial for FeedAPI Image Grabber”
Posted in Drupal | Tagged Drupal, feedapi, imagegrabber, module, tutorial
By Nitin on September 16, 2009
PayPal is used by a lot of online merchants to accept payments for the products they sell online. PayPal can also be used to accept donations for your technical open source projects or charity organization.
Recently, I opened an account with PayPal to accept payments from my clients who reside outside India. Before I started, I searched for reviews on PayPal which seemed quite horrible. You can read a lot of them here. But then I needed the payments and had no other option (without spending a huge transaction amount), so gave it a try and I am happy that my experience with them till now is excellent.
So, here is a step by step procedure to Withdraw funds to your bank account in India. Continue reading “Withdraw PayPal Money Directly to A Bank Account in India”
Posted in Nitin's Blog | Tagged Drupal, paypal
By Nitin on July 17, 2009
Often we need MINUS operator as defined by the SQL definitions i.e you have two sets P and Q and you want P-Q which gives all the elements in P that are not in Q. But unfortunately, MYSQL does not have any operator for such an operation (yeah, I had the same reaction when I heard this!!).
So here is a way how you can implement it in MYSQL. For simplicity let us consider we have two tables P and Q (we can also have views, joins, etc instead of the tables here) which have atleast one column in common (say id, which usually will be the primary key) and we want to evaluate P – Q which removes all those rows from P whose id is present in Q.
Here is the SQL statement for it. The statement is quite self explanatory, but if you still have doubt then leave a comment.
1
| Select * from P left join Q on P.id = Q.id where Q.id is NULL; |
Thats is what I could think of. If you are using some better and efficient method, then please leave a comment.
Posted in Nitin's Blog | Tagged Intern, mysql
By Nitin on July 15, 2009
Until sometime back, I was unaware of how I could get the value of an auto-incremented field after an Insert Statement. But recently I needed it for two of my projects simultaneously, so I explored the possibilities. As one of my project is in Java and other is in PHP, we will go through both of them.
So, here is the problem. In general, the PRIMARY KEY field is the AUTO_INCREMENT field. Now wen you insert a row, a new key is generated and you can’t get it through usual way as this row can be accessed only using the primary key.
So here is how it can be done:
Continue reading “MYSQL: Get the Auto-Increment Values after Insert Statement”
Posted in Nitin's Blog | Tagged Intern, java, mysql, php
By Nitin on July 5, 2009
Recently while working for my project, I came across this situation when I had a 2-D array and I needed to sort it twice on 2 of its columns. Consider the following 2D array:
1 2 3 4
| String[][] testString = new String[][] {
{"1", "2", "6"},
{"4", "5", "3"}
}; |
Sorting the above 2D array on zero column will give
1 2 3 4
| {
{"1", "2", "6"},
{"4", "5", "3"}
} |
whereas sorting it on second column will give
1 2 3 4
| {
{"4", "5", "3"},
{"1", "2", "6"}
} |
I did not want to do the most common as well as tedious thing, i.e. write my own sorting function like this:
1 2 3
| public void myOwnSort (String [][] exampleArray ) {
//code for sorting the array according to my wish.
} |
I wanted to avoid this for 2 resons:
- I would have to write the code for it ( lazy me!!).
- Secondly, I can possibly never match the efficiency provided by the sorting functions of java.util.Arrays
Continue reading “Sorting a 2-Dimensional Array in Java”
Posted in Nitin's Blog | Tagged code, Intern, java