r
Source: Indibloggies
December 10, 2009
November 26, 2009
How to delete blank rows in excel
Deleting blank rows is a common thing one would like to do after importing data to excel. There are dozens of ways of achieving the same. I bet, this being one of the simplest:
1. Press F5 on the keyboard. The ‘Go To’ dialog window appears.
2. Click ‘Special..’ button at the bottom left corner of the dialog box.
3. The ‘Go To Special’ dialog window opens.
4. Select ‘Blanks’ radio button and click ok.
5. All the blank rows will be selected on the excel.
6. Click ‘Delete Cells’ under ‘Home’ Tab.
7. This will delete all blank rows on the excel.
November 23, 2009
Google Wave Invitation
My Google Wave invitation mail has just arrived.
I have few invitations left.
Let me know if you need one.
November 17, 2009
Java Sort By Map Value
Java utility method to sort a Map based on map values.
@SuppressWarnings(value = { “unchecked” })
public static List sortByValue(final Map m) {
List keys = new ArrayList();
keys.addAll(m.keySet());
Collections.sort(keys, new Comparator() {
public int compare(Object o1, Object o2) {
Object v1 = m.get(o1);
Object v2 = m.get(o2);
if (v1 == null) {
return (v2 == null) ? 0 : 1;
} else if (v1 instanceof Comparable) {
return ((Comparable) v2).compareTo(v1);
} else {
return 0;
}
}
});
return keys;
}
November 26, 2008
String Reverse in Python
One line code to reverse a string in Python:
strOrig = “xyz”
revStr = s[::-1]
where ’strOrig’ is the source string and ‘revStr’ is the string reversed.
Python is indeed powerful!!
How to send free SMS through email
To send free sms, add your service provider’s domain name to the end of the 10-digit mobile number of the person whom you want to send SMS.
For example, if the mobile number is – 123-456-7890 and the provider is AT&T, then sms can be send through email as:
Recipient’s address: 1234567890@message.alltel.com
Type the message in the message ‘Subject’ or message ‘Body’.
Enjoy free messaging!!
Mobile Device Address
Alltel: @message.alltel.com
AT&T: @txt.att.net
Boost Mobile: @myboostmobile.com
Sprint Nextel: @messaging.sprintpcs.com
T-Mobile: @tmomail.com
U.S. Cellular: @email.uscc.net
Verizon: @vtext.com
Virgin Mobile: @vmobl.com
October 19, 2008
Python Prime Number Generator (Sieve Algorithm demystified)
#The prime number generator is using Sieve algorithm for fast prime number computaion. The following are the steps of the algorithm:
#
#Algorithm:
#==========
#
# Step 1. Consider a contiguous list of numbers from two to some maximum. (This is the list of squares on the left side of the picture.)
#
# Step 2. Strike off all multiples of 2 greater than 2 from the list.
#
# Step 3. The next highest, uncrossed off number in the list is a prime number.
#
# Step 4. Strike off all multiples of this number from the list. The crossing-off of multiples can be started at the square of the number, as lower multiples have already been crossed out in previous steps.
#
# Step 5. Repeat steps 3 and 4 until you reach a number greater than or equal to the square root of the highest number in the list; all the numbers remaining in the list are prime.
#
#Source: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
import math
def primeNumGenerator(input):
#Here if the input is less than 2, then return an empty list since the smallest prime number is 2
if input < 2: return []
#If input is 2, then return 2
if input == 2: return [2]
# Steps 1&2 of the algorithm – We are here considering a contiguous list of number from 2 to given imput. Setting step of 2 in the range function strikes off all multiples of 2 greater than 2 from the list
s = range(3, input, 2)
mroot = math.sqrt(input)
listofinput = len(s)
i = 0
# Step 3 of the algorithm. We start with number 3 in the list as we have already considered scenarios till number 2 in the list above
m = 3
#As per prime number generator theorm, the numbers in the list are only checked till the square root of the number for which the prime number series is to be generated
while m <= mroot:
if s[i]:
#Step 4 of the algorithm. To strike off all multiples of this number from the list, we need to first calculate the index of the multiple in the list.
#The formula for doing so is (m*m-1). But since we are considering only odd number series, the formula gets modified to: (m*m-1)/2.
#Now since our odd number series does not have 1 (or has a member missing), the formula further gets modified to: ((m*m-1)/2)-1 = (m * m – 3)/2
#Also floor division is used here (//) since only the integer part is needed for index
j = (m * m – 3)//2
# Step 4 of the algorithm continued. Striking off multiple of this number
s[j] = 0
# Continuing to striking all other multiples of this number from the list
while j < listofinput:
s[j] = 0
j += m
# Increasing the index to process with the next number in the list
i = i + 1
# Now the nth element in a odd number series is (2n+1) where n is the index. Since our list starts with 3, the formula gets gets modied to:
# 2(m+1)+1 = 2m+3 which gives us the next number in the series
m = 2 * i + 3
# Using list comprehension to build the prime number series. First we are adding 2 to the series since we didn’t consider 2 in our series are 2 is prime. Now all the indexes not marked as 0 are the prime numbers
return [2]+[prime for prime in s if prime]
if __name__ == ‘__main__’:
num = 20
primeNumberList = primeNumGenerator(num)
print “List of prime numbers from 2 to < %d:” % num
print primeNumberList
June 23, 2008
Zen Of Python
To see the ‘Zen Of Python’, which is widely accepted as the principles on which the python is based, simply type ‘import this’ at the Python prompt.
C:\>python
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on
win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren’t special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one– and preferably only one –obvious way to do it.
Although that way may not be obvious at first unless you’re Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it’s a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea — let’s do more of those!
>>>
June 5, 2008
How to download video from YouTube
Real Player 11 though as not much popular these days, did strike back big with cool features with its version 11 allowing downloading streaming video.
Here is how you can download videos from YouTube.
Download RealPlayer 11 for your Operating System. You can use the following link to download:
http://www.real.com/freeplayer/?rppr=rnwk
After downloading the file, start to installation by double clicking on the executable file and following the installation steps. When you come to the installation step (as shown below), make sure to check the check box for “Download & Recording”. Continue with the installation process.
After installation is finished, open the Real Player. Go to Tools->Preferences. Click on the “Download & Recording” tab from the “Category“list on the left hand side of the window (as shown below)
Select “Only on mouse-over” radio button. You can also change here the directory path where you want the downloaded video to be saved. Click the “OK” button. Close the internet browser and then again reopen.
Now to download the video from the YouTube, start to play the video you want to download on YouTube. Point the mouse cursor to the top right corner of the screen and click the download button.
The download of the gets started. Real Player can download multiple files simultaneously. The file is saved with “.flv” extension which can be later player by RealPlayer or VLC. Happy downloading
May 26, 2008
The Big Californian Earthquake
Scientists have been predicting a massive earthquake in California for years now – the question is not if, but when.
“If the much-feared ”Big One” struck California, the massive earthquake would leave 1,800 dead, 50,000 wounded and 200 billion dollars in damage, a team of scientists said.”



RSS - Posts