Vijay Joshi's Blog, page 2
April 3, 2012
Code snippet : WordPress qTranslate – Getting current language

So I was working with the qTranslate plugin of WordPress’s and needed to select an image depending on language. qTranslate provides a utility function which returns the current language.
The function is called qtrans_getLanguage() and it works as follows:
$currentLang = qtrans_getLanguage();
if($currentLang == 'fr')
{
//show french logo
$imageName = logoFR.png';
}
else if($currentLang == 'hi')
{
//show Hindi logo
$imageName = logoHI.png';
}
else
{
//show english logo to rest
$imageName = logoEN.png...
March 1, 2012
Code Snippet : javascript – Checking for blank spaces in sentence without regex

This is actually very interesting. I had a text field which expected a single word string and I had to check it on client side. Using jQuery and JavaScript’s split function we can easily check if an input string contains spaces or not.
split function accepts a delimiter as first parameter, a string as second paramter and splits the string into an array by that delimiter. Returns original string if delimiter is not found.
Here is the code I used :
// id of the textbox is timeTaken
var strText...
February 28, 2012
jQueryUI Sortable-tr width reduces when used with table

I am working on a project where I need to make a list of items sortable. Naturally, I used jQueryUI’s sortable component. Now it works great for elements like ul, or ol or any other html structure.
In my case the items were in a table and I had to make the tr’s sortable. Implementing the sortable gave me the desired behavior. Here is the code I used:
$('#tblSort tbody.content').sortable(
{
cursor: 'move'
});
But while dragging the rows, the width of cells inside currently dragged row was getti...
October 21, 2011
Comment box not visible on a page/post in WordPress 3.2.1

First of all I will congratulate you on upgrading to wordpress 3.2.1. Having latest version means your site is updated and safe.
Now coming to the point, some of you might have faced this problem. You create a new page or post and do not want to allow comments on that. So you scroll down but cannot find the discussion box. The box which has 2 checkboxes “Allow comments” and “Allow trackbacks and pingbacks”.
To fix this, look at the top right of your screen for the Screen Options button. Cli...
September 6, 2011
PHP: Get intersecting dates between 2 date ranges

Here is a small code snippet that will give you intersecting dates between 2 date ranges. Say, for example, you have 2 date ranges, 1-Jan-2011 to 31-Mar-2011 and 23-Feb-2011 to 4-May-2011. This function will give you 23-Feb-2011 to 31-Mar-2011 as result.
Here is the code:
$a1 = "2011-01-01";
$a2 = "2011-03-31";
$b1 = "2011-02-23";
$b2 = "2011-05-04";
$intersection = getIntersection($a1,$a2,$b1,$b2);
if($intersection === false)
{
echo 'No intersecting dates found';
}
else
{
echo 'From '.date('d-M-Y',...
February 9, 2011
Book Review: Mastering phpMyAdmin 3.3.x for Effective MySQL Management

Recently I was contacted by Richard from Packt Publication to review their new book “Mastering phpMyAdmin 3.3.x for Effective MySQL Management“. Being a PHP-MySQL developer and an avid reader of technical books myself, I instantly agreed.
It took me a bit longer to read it then I had expected. At first, I had decided to just skim through the important chapters but it was interesting enough to change my decision. I then read all chapters one by one and realized that despite using phpMyAdmin...
January 23, 2011
Favorite tech links of the week : 17 Jan – 23 Jan, 2011

This post contains some of the useful and interesting tech links I found during last week. To keep up to date with the latest information,subscribe to the feed or follow me on twitter@v08i.
How to write a simple application on jQuery Mobile : http://goo.gl/5DpOO
50 Free Tools and Apps for Web Designers and Developers : http://goo.gl/6YjNL
10 Useful jQuery Plugins for Images : http://goo.gl/VTk1F
20 less known Open Source PHP CMS-es : http://goo.gl/cM6f3
11 More Things I Learned From the jQuery...
January 20, 2011
PHP class for expanding and shortening URLs using Google URL shortener API

I have combined the 2 previous posts for expanding and shortening goo.gl URLs and have created a small class for it. Below is the download link for the class.
Expanding a URL
expand('http://goo.gl/WlFX');
if(FALSE === $result)
{
echo $objAPI->error;
}
else
{
echo 'Long URL:'.$result;
}
?>
Shorten A URL
shorten('https://www.packtpub.com/php-jquery-c...
if(FALSE === $result)
{
echo $objAPI->error;
}
else
{
echo 'Short URL:'.$result;
}
?>
As I have mentioned e...
15 HTML5 resources and tutorials for web developers and designers

Here is a collection of 15 resources on HTML5 that I think will be useful to web developers as well as designers.
What is HTML5? (Infographic)Dive Into HTML5HTML 5 Demos and ExamplesHTML5 Boilerplate :A rock-solid default for HTML5 awesomeHTML 5 Cheat Sheet (PDF)28 HTML5 Features, Tips, and Techniques you Must KnowA Beginners Look Into HTML515 Easy Guides on Getting You Started with HTML535 Inspiring Examples of Websites Using HTML5When to Use the HTML5 "section" Element
January 16, 2011
Favorite tech links of the week : 10 Jan – 16 Jan, 2011

This post contains some of the useful and interesting tech links I found during this week. To keep up to date with the latest information, subscribe to the feed or follow me on twitter @v08i
22 Brilliant and Advanced jQuery Effects to WOW Your Visitors – http://goo.gl/IUz3d12 Cool Javascript – jQuery checkbox replacement you shouldn't miss – http://goo.gl/4OxcT70 Must See CSS3 Tips, Tricks And Tutorials – http://goo.gl/VarE4The anatomy of a WordPress theme –