mod_rewrite
Posted on August 24, 2008
Filed Under PHP | Leave a Comment
I used apache mod_rewrite to create user friendly and search engine optimized urls for sri-lankan.net. Here is how I did it.
Using the following .htaccess configuration, I redirected all the requests to index.php.
1 2 3 4 5 6 7 | <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> |
And decide what to show the user by checking $_SERVER[’REQUEST_URI’]…
1 2 3 4 | <? $url = $_SERVER['REQUEST_URI']; $parts = explode('/', $url); ?> |
Mum and me…
Posted on August 23, 2008
Filed Under Photos | 1 Comment

A kindergarten picture of mine, which I found wile scanning my old albums.
Merging Subversion Repositories
Posted on March 29, 2008
Filed Under Linux | Leave a Comment
I had two different projects in separate subversion repositories and I wanted to merge them together. I found a simple tick like this.
1 2 3 4 5 6 7 | $ svnadmin dump srilankan > sri.dump $ svnadmin dump ebizlanka > ebiz.dump $ svnadmin create projects $ svn mkdir file:///home/ramesh/svn/projects/srilankan $ svnadmin load projects --parent-dir srilankan < sri.dump $ svn mkdir file:///home/ramesh/svn/projects/ebizlanka $ svnadmin load projects --parent-dir ebizlanka < ebiz.dump |
Show working directory in bash prompt
Posted on March 28, 2008
Filed Under Linux | Leave a Comment
I always get confused with which directory I’m working under. The solution I found is to display the working directory in the bash prompt. This is the single line that does the magic in the ~/.bashrc
1 | PS1=[\\w]\\$ |
Change timezone of PHP
Posted on February 9, 2008
Filed Under PHP | Leave a Comment
If you wanna change the timezone of a PHP script, set the timezone environmental variable in your PHP code as simple as shown bellow.
1 2 3 | <? putenv("TZ=Asia/Colombo"); ?> |
U.S. Robotics Wireless USB Adapter in Ubuntu 7.10
Posted on February 4, 2008
Filed Under Linux | Leave a Comment
I had a hard time configuring my U.S. Robotics Wireless USB Adapter in Ubuntu 7.10, at last found out non of the native drives work for it and installed the windows driver with ndiswrapper and disabled all the native usb drivers by adding them to the /etc/modprobe.d/blacklist and boom it start working.
1 2 3 4 5 6 7 8 9 10 11 | blacklist islsm_pci blacklist islsm blacklist islsm_usb blacklist prism2_usb blacklist rtl8187 blacklist r8187b blacklist r8187 blacklist prism54usb blacklist prism54pci blacklist p54usb blacklist p54pci |
Note:If you don’t disable the these modules by adding them to the the blacklist the ndiswrapper wouldn’t work properly.
Hacking W800i…
Posted on January 9, 2008
Filed Under Mobile | Leave a Comment
I decided to play around with my W800i and hack it’s features as I want. I used the Far Manager with SEFP (Sony Ericsson Flash Plugin) to access the phone configuration. Here are the stuff I did with my phone. (Use at your own risk)
Remove Camera Sound
I wasn’t able to find the configuration file for the camera sound; so I simply deleted the audio files that’s used by the camera and got it done.
1 2 3 4 5 | /FS/tpa/preset/system/sound/cameraburst.3gp /FS/tpa/preset/system/sound/cameraburst.mid /FS/tpa/preset/system/sound/camerafocus.3gp /FS/tpa/preset/system/sound/camerashutter.3gp /FS/tpa/preset/system/sound/cameratimer.mid |
Remove SMS Limit
Edit the SMS storage configuration file “/ifs/settings/messaging/pref_store.txt” and change “/smsdata” to “/tpa”.
Removing Operator Name
Ooops I didn’t like the big Dilog GSM hiding part of my Wallpaper, I got rid of it by editing the /FS/tpa/system/layout/layout.xml file.
1 2 3 4 5 6 7 8 9 10 11 12 | <object name="StatusIndication"> <settings> <sett name="RowHeight" value="0"/> <sett name="TopOffset" value="0"/> <sett name="TitleHeight" value="0"/> <sett name="TitleTopOffset" value="0"/> <sett name="TitleMode" value="4"/> <!-- change "1" to "4" --> <sett name="OverlayStyle" value="2"/> <!-- change "0" to "2" --> <sett name="YPos" value="18"/> <sett name="Height" value="176"/> </settings> </object> |
Download all file from ftp server recursively
Posted on January 7, 2008
Filed Under Linux | Leave a Comment
I moved http://www.sri-lankan.net to DreamHost last month and wanted to download all the files from my old hosting provider. I found the ncftpget command so useful. Here is how…
1 | $ ncftpget -T -R -v -u "ramesh" sri-lankan.net ./sri /www |
HSQL changes not getting saved
Posted on January 6, 2008
Filed Under Java | Leave a Comment
I had my time with the interns yesterday when they complained that the changes they made are not getting saved to the HSQL database. I spend an hour trying to find out why, at last I found out that in HSQL you need to send a SHUTDOWN command to save the changes in a clean way…
1 2 3 4 5 | Statement st = conn.createStatement(); // db writes out to files and performs clean shuts down st.execute("SHUTDOWN"); conn.close(); |
Select a random row from a table
Posted on December 22, 2007
Filed Under SQL | Leave a Comment
I was looking for a clean and simple way of selecting a random record from a table. Here is what I found…
1 | SELECT * FROM TABLE ORDER BY RAND() LIMIT 1 |