Labels

Friday, September 10, 2010

Inspiring Quote by Steve Jobs

Remembering that I’ll be dead soon is the most important tool I’ve ever encountered to help me make the big choices in life. Because almost everything — all external expectations, all pride, all fear of embarrassment or failure — these things just fall away in the face of death, leaving only what is truly important. Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose. You are already naked. There is no reason not to follow your heart.

Sunday, September 5, 2010

Upgrade your WordPress site or blog for free..

Yes, you heard that right... got a WordPress site or blog ? if yes, MULTIDOTS offers free upgradation to latest version of WordPress.




visit : http://www.guptaanil.com/free-wordpress-upgrade-at-multidots/

Its a campaign cum activity started by WordPress group at MULTIDOTS.
So hurry up and avail yourself of new features offered by latest version of wp....

Thursday, August 5, 2010

jQuery: How to submit a form with AJAX in jQuery

Excellent explanation of how to submit a form with ajax using jquery - visit :

http://www.ajaxlines.com/ajax/stuff/article/how_to_submit_a_form_with_ajax_in_jquery.php

jQuery: Access value of selected/checked radio button

if you have a group of radio buttons (grouping done using same value for name attribute in all) and you want to get value of selected radio button out of them,
using jquery you can do that with below code snippet:

Suppose you have:

Diya [name="bolly",value="diya"]
Kareena [name="bolly",value="kareena"]
Katrina [name="bolly",value="katrina"]

Then,
var sel_val = $('input:radio[name=bolly]:checked').val();

You will get: sel_val = "diya"


For more reference:
http://stackoverflow.com/questions/986120/how-to-get-select-radiobutton-value-using-its-name-in-jquery

Monday, June 28, 2010

Javascript: Inline javascript function in event handler declaration

If you want to write javascript function code directly in the onclick event handler declaration instead of using a separate function for that code, you can do it as follows:

<input type="button" value="Save" onclick="javascript:(function(){ //your code; })();"/>

Monday, May 31, 2010

Google Maps: Best Fit Zoom Level and Center Point.

If you are working with Google maps and have an array of latitude longitude points to plot as markers on map, then you might need to calculate the best fit zoom level and map center point so that all the lat lng points can accommodate comfortably. Here's the code snippet:
// map: an instance of GMap2
// latlng: an array of instances of GLatLng
var latlngbounds = new GLatLngBounds();
for (var i = 0; i < latlng.length; i++)
{
latlngbounds.extend(latlng[i]);
}
map.setCenter(latlngbounds.getCenter(),map.getBoundsZoomLevel(latlngbounds));

For further reference:
http://911-need-code-help.blogspot.com/2009/03/zoom-to-fit-all-markers-polylines-or.html

Thursday, April 29, 2010

PHP: Get Yesterday's Date

echo date("Y-m-d", strtotime("-1 day") );

For some specific date:
echo date("Y-m-d", strtotime("2010-Jan-1 -1 day") );


Play around with this function to get your desired results. The PHP date parser is very smart.

Tuesday, April 27, 2010

MySQL/SQL: 'ON DUPLICATE KEY UPDATE' for multiple rows insert in single query

Hello All.

I had a sql query where I wanted to insert multiple rows in single query. so I used something like:

$sql = "INSERT INTO beautiful (name, age)
VALUES
('Helen', 24),
('Katrina', 21),
('Samia', 22),
('Hui Ling', 25),
('Yumie', 29)"
;

mysql_query
( $sql, $conn );

The problem was when I executed this query, I wanted to check whether a UNIQUE key (which is not the PRIMARY KEY), for eg. 'name' in above case, should be checked and if such a 'name' already exists, the corresponding whole row should be updated otherwise inserted.

For instance, in below eg., if 'Katrina' is already present in database, the whole row, irrespective of number of fields, should be updated. Again if 'Samia' is not present, the row should be inserted.

I thought of using:

INSERT INTO beautiful (name, age)
VALUES
('Helen', 24),
('Katrina', 21),
('Samia', 22),
('Hui Ling', 25),
('Yumie', 29) ON DUPLICATE KEY UPDATE

Here is the trap. I got stuck and confused how to proceed. I had multiple rows to insert/update at a time. Then StackOverflow came to my rescue. Thanks to Peter Lang.

The Solution:

INSERT INTO beautiful (name, age)
VALUES
('Helen', 24),
('Katrina', 21),
('Samia', 22),
('Hui Ling', 25),
('Yumie', 29)
ON DUPLICATE KEY UPDATE
age
= VALUES(age),
...

Friday, April 2, 2010

Ubuntu: Extract rar files

Install the unrar program for Ubuntu (I tried it for Ubuntu 9.10):
Command:
sudo aptitude install unrar

Wednesday, February 3, 2010

Flex: The World Factbook

The World Factbook: This demo application displays C.I.A. World Factbook Data using gauges, treemap, 3D charts and radar chart from the IBM ILOG Elixir components suite.

Visit:

Sunday, January 31, 2010

JSON Parser

Working with JSON? Getting it difficult to parse the syntax or format of JSON?
Check out below link. It will definitely help you.

http://json.parser.online.fr/