Friday, July 10, 2009

WordPress: Display only on first page

This code will enable you to display items such as text or image only on the first page of the homepage or archive.

It can be use in index.php, category.php or archive.php.

What you need is the $page WordPress variable. 1 for the first page of results, 2 for the second page, etc.

To use it, put the code inside The Loop.
<?php if ( $paged < 2 ) { ?>

Your text or image for the first page goes here!

<?php } else { ?>

WordPress 2.8.1 is avalaible for download

According to the WordPress blog, WordPress 2.8.1 is now ready for download. Version 2.8.1 includes updates and security patches for version 2.8 bugs. One of the most important update is the reduce of memory usage of the Dashboard.

Click here to download the latest WordPress release.

Friday, July 3, 2009

How to disable Flickr automatic updates in Nokia 5800

Nokia 5800 supports Flickr services via its Share Online feature. It can even updates the Flickr photos automatically. The bad thing is that this feature is turned on by default when you enable the Flickr service. The default setting is it will update to Flickr every 6 hours, and it will consumes for about 600kb of data transfer. This feature is bad for users that do not subscribe to the unlimited data plan.


How to turn the automatic update feature off?



  1. Press the XpressMusic button.

  2. Select Settings (The bottom third right most icon).

  3. Select Advance.

  4. Disable Use cellular. Disable Use cellular will disallow the phone to use mobile network to connect to Flickr.

  5. Disable Roaming. The phone will not update Flickr outside when you are overseas.

  6. Select Download interval option to Manual.

Count the number of occurences using Counter() in Python

Counter is an object of collections module, and it is a dict subclass for counting hashable objects, in Python 3.

To count the number of elements occurrences in a list

>>> from collections import Counter
>>> z = ['blue', 'red', 'blue', 'yellow', 'blue', 'red']
>>> Counter(z)
Counter({'blue': 3, 'red': 2, 'yellow': 1})

Count the number of alphabet occurrences in a text

>>> from collections import Counter
>>> Counter("This is a test")
Counter({' ': 3, 's': 3, 'i': 2, 't': 2, 'a': 1, 'e': 1, 'h': 1, 'T': 1})

To find the n most common words in a text

n is the number of most common words to find
Counter(the_text).most_common(3)
For more information, read The Python Standard Library

Archive and Compress Files Using zip

Zip and unzip are two free command line programs that comes with Linux. For Windows, they can be downloaded from the Info-ZIP Website. This article provides the basic of archiving and compressing files using the command line zip program.

Zip one file

zip filename.zip file_to_compress

Zip multiple files

zip filename.zip file_to_compress1 file_to_compress2 file_to_compress3

Compression options


The compression level ranges from 0 to 9. Level 0 means no compression, 1 compress faster, and 9 compress better. The default is 6.
zip -9 filename.zip file_to_compress

Password protect zip archive

zip -P the_password filename.zip file_to_compress

To be prompted for password instead of specifying the password in the command line, use -e instead of -P.
zip -e filename.zip file_to_compress
Enter password:
Verify password:

Unzip files

unzip filename.zip

Unzip files with informations (verbose mode)

unzip -v filename.zip

List files that will be unzipped

unzip -l filename.zip

Test Files That Will Be Unzipped

unzip -t filename.zip

Thursday, July 2, 2009

How to disable A-GPS in Nokia 5800

Nokia 5800 comes with an integrated GPS device. Besides, Nokia 5800 also support Assisted GPS (A-GPS), and it is turn on by default.

A-GPS could help the phone to connect to the satellite faster. However, A-GPS requires the internet connection. Therefore, if you are not subscribed to the unlimited data plan package, you may want to disable the A-GPS support.

My ignorance of this issue had cost me a few hundreds Ringgit.

To disable the A-GPS support in Nokia 5800, follow this steps:

  1. Press the white Menu button.

  2. Select Apps.

  3. Select Location.

  4. SelectPositioning.

  5. Select Positioning Methods.

  6. Select Assisted GPS, and select Disable.

Wednesday, July 1, 2009

How to list out Python reserved words

To list out the Python reserved words, just enter the following lines into the Python interpreter.
>>> import keyword
>>> print(keyword.kwlist)

['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
Python Reserved Words