Posts

Simplest way to remove trailing zeros of decimal numbers

This is a simple method I found to remove or strip trailing zeros of a decimal number. The function accepts the decimal number and return the trimmed value back. It removes all the redundant zeros in the number after the decimal point and if no number othe …

Batch Insert/Update for Mysql in Java

Large inserts/Updates are a costly operation. One foolish way that I used to do is to run each update or insert query one at a time. Its incredibly slow. With most of the systems currently the latency is what is killing the performance not the CPU. Hence l …

Display Reminders In Gnome Panel

It was a long standing requirement of mine to create a reminder software or something which can keep me reminding of things as I always keep forgetting things. So I made a reminder that displays my reminders on the Gnome Panel. It looks something like this …

Find Invisible Users In Gmail

Finding who is invisible is something that I always wanted to do.It’s always fun to ping a person who feels none can see him/her online. While studying XMPP protocol I found out that even when the person is offline the chat client knows that person is onli …

Print Array in PHP

There are various methods and commands used in PHP to print an array of elements. They are different in the way they print the array elements. I will cover three main ones I usually use. Lets assume an array as follows to explain the various types of print …

User Level Threads

User level threads is created for light weight threads. It needs to be controlled, context switched and swapped by the process. To the Operating System it is only one process without any threads. Here is one implementation of it: q.h





#include  …

Get the nth Word from a text field in mysql

I had a requirement to get the nth word out of a string and sort or order by the same. This is used when the text is stored in a purticular format and you would want to order it according to that or group it or so on. So how is it done? We do it using a  …

More than 100% CPU in top in Linux/Mac

If you are power linux/mac user you should have noticed at least once that top shows more than 100% CPU for a process. I also have seen this multiple times but always wondered how it can be. Here is an example of how my top looked when I started my java an …

Automatic Desktop Wallpaper Changer for Linux

I have a lot of wallpaper that I wanted to switch automatically. After a lot of search i found that there a command way to control all the gnome settings. So I the command I used is “gconftool-2″. So code is like:




#!/bin/bash
folder="/home/rsr …

Auto Away Notifier for Pidgin in Perl

Whenever I am away from laptop my chat buddies leave me lots message and finally lots of “You there???”. So I thought of making a script that would inform my buddies that I am away when someone sends me a message. This method works with Pigin API. I have  …