I came across an interesting dating site for people of Indian origin called
BharatMatrimonial.com.
Friday, June 26, 2009
Tuesday, June 23, 2009
Wednesday, June 17, 2009
An Interesting New Blog
There is a new blog called Online Siesta which looks like it might be interesting for people who are into blogging, marketing, and the internet.
It is written by Tomer Treves, who is the vice president of an internet advertising company called Infolinks. He calls his blog "Online Siesta", because the idea is that he is writing his own opinions during his lunch hour.
Since the blog is so new, it does not have a lot of posts, but the "About Me" blurb says that Tomer will be writing a lot about "online business and life".
The best post so far on Online Siesta is a really interesting one about how all the different forms of advertising (i.e. TV, radio, newspaper commercials, internet ads, etc.) all followed the same cycle of user acceptance and penetration.
It is written by Tomer Treves, who is the vice president of an internet advertising company called Infolinks. He calls his blog "Online Siesta", because the idea is that he is writing his own opinions during his lunch hour.
Since the blog is so new, it does not have a lot of posts, but the "About Me" blurb says that Tomer will be writing a lot about "online business and life".
The best post so far on Online Siesta is a really interesting one about how all the different forms of advertising (i.e. TV, radio, newspaper commercials, internet ads, etc.) all followed the same cycle of user acceptance and penetration.
Unix Shell Script Command Parsing
For unix scripts that get executed by lots of other users, I like to make them user friendly by allowing arguments to be passed in any order.
For example, let's say that I created a script called cube that takes four parameters: three values for the cube's dimensions (height, width, and depth) and a flag to make it a die (i.e. have the sides numbered 1-6).
For quick and dirty scripts, I would just read in the arguments in order. For example, I might assign $1 to height, $2 to width, $3 to depth, and $4 to flag.
So, if a user ran cube 3 4 5 1, I would create a 3x4x5 cube that was a die.
If I wanted to make the script user friendly, I would specify the parameters -height, -width, -depth, and -die, where the first 3 params would take an argument.
Let's further clarify that the height is the only required parameter. If the width or depth is omitted, it would be the same as the height. If -die is not provided, then the cube will not be a die.
My shell script would start with two functions: Usage and parseArgs.
The Usage function simply prints out the possible arguments and whether they are optional (i.e. in brackets):
function Usage
{
echo "Usage: cube -height height [-width width] [-depth depth] [-die]"
}
The pargeArgs function initializes a heightcheck variable to 0, because height is a required field. Then, as long as the first argument ($1) exists, the while loop will execute. The while loop uses a nested case statement to identify the parameter, and then does a shift to shift all arguments to the left (so $2 becomes the new $1). If the parameter takes an argument, then $2 is accessed and an extra shift statement is done.
function parseArgs
{
heightcheck = 0
while [ -n "$1" ]
do
case "$1" in
-heigth) height="$2"
heightCheck=1
shift
;;
-width) width="$2"
shift
;;
-depth) depth="$2"
shift
;;
-die die=1
;;
esac
shift
done
# make sure we got a height on the command line...
if [ $heightCheck = 0 ] ; then
Usage
exit 2
fi
}
After these functions, the main script will start. First, we will check for the arguments by calling parseArgs with the arguments to the script:
# Parse Command Line
parseArgs $*
Next, We will set the defaults. ${a:-"b"} returns a if a is set (assigned a value) or else it will return b:
# Set defaults if these args
# were not set on command line.
width=${width:-"$height"}
depth=${depth:-"$height"}
die=${die:-0}
After this, you write the rest of your script.
For example, let's say that I created a script called cube that takes four parameters: three values for the cube's dimensions (height, width, and depth) and a flag to make it a die (i.e. have the sides numbered 1-6).
For quick and dirty scripts, I would just read in the arguments in order. For example, I might assign $1 to height, $2 to width, $3 to depth, and $4 to flag.
So, if a user ran cube 3 4 5 1, I would create a 3x4x5 cube that was a die.
If I wanted to make the script user friendly, I would specify the parameters -height, -width, -depth, and -die, where the first 3 params would take an argument.
Let's further clarify that the height is the only required parameter. If the width or depth is omitted, it would be the same as the height. If -die is not provided, then the cube will not be a die.
My shell script would start with two functions: Usage and parseArgs.
The Usage function simply prints out the possible arguments and whether they are optional (i.e. in brackets):
function Usage
{
echo "Usage: cube -height height [-width width] [-depth depth] [-die]"
}
The pargeArgs function initializes a heightcheck variable to 0, because height is a required field. Then, as long as the first argument ($1) exists, the while loop will execute. The while loop uses a nested case statement to identify the parameter, and then does a shift to shift all arguments to the left (so $2 becomes the new $1). If the parameter takes an argument, then $2 is accessed and an extra shift statement is done.
function parseArgs
{
heightcheck = 0
while [ -n "$1" ]
do
case "$1" in
-heigth) height="$2"
heightCheck=1
shift
;;
-width) width="$2"
shift
;;
-depth) depth="$2"
shift
;;
-die die=1
;;
esac
shift
done
# make sure we got a height on the command line...
if [ $heightCheck = 0 ] ; then
Usage
exit 2
fi
}
After these functions, the main script will start. First, we will check for the arguments by calling parseArgs with the arguments to the script:
# Parse Command Line
parseArgs $*
Next, We will set the defaults. ${a:-"b"} returns a if a is set (assigned a value) or else it will return b:
# Set defaults if these args
# were not set on command line.
width=${width:-"$height"}
depth=${depth:-"$height"}
die=${die:-0}
After this, you write the rest of your script.
Sunday, June 14, 2009
Direct TV
If you are tired of high cable bills, you may want to consider satellite TV.
Direct TV tends to be cheaper than cable. This means that, for the same amount of money, you can upgrade your Direct TV Service and take advantage of more channels, including premium channels like HBO.
Also, your Directv System makes it easier for you to recieve HD programming. A lot of other providers have too many packages, and make it confusing to figure out which HD channels you are subscribing to.
Direct TV tends to be cheaper than cable. This means that, for the same amount of money, you can upgrade your Direct TV Service and take advantage of more channels, including premium channels like HBO.
Also, your Directv System makes it easier for you to recieve HD programming. A lot of other providers have too many packages, and make it confusing to figure out which HD channels you are subscribing to.
Previous Month Date Math in Unix
Here is a unix shell script that calculates the previous month.
Here is the run:
[576]-> last_month
Today is 10/10/2006
Last month was 9/2006
First day of last month was 9/01/2006
Last day of last month was 9/30/2006
Here is the script:
day=`date +%d`
month=`date +%m`
year=`date +%Y`
echo "Today is $month/$day/$year"
lmonth=`expr $month - 1`
if test "$lmonth" = "0"
then
lmonth=12
year=`expr $year - 1`
fi
echo "Last month was $lmonth/$year"
lday=`cal $lmonth $year |awk '$0~/[0-9]/ {print $NF}'|tail -1`
echo "First day of last month was $lmonth/01/$year"
echo "Last day of last month was $lmonth/$lday/$year"
The first part of the script uses the unix date command to retrieve today's day, month, and year. We print today's date.
'
Next, we use the korn shell's expr command to subtract 1 from the month. If the month becomes 0, then that means that this month is January, so we wrap the date to December of the previous year. We print out the previous month and year.
In the third part, we retrieve the last day of the previous month, and then print the first and last days of the previous month.
The tricky thing here is how we retrieve the last day. We run the unix cal function to return last month's calendar. We pipe it into an awk command, which prints the last field from each line. We pipe this to tail -1, which returns the last line of the awk output.
This whole pipeline is enclosed in back ticks (`) so that we can assign the final output to the variable lday.
Let's look at this, using the 9/2006 cal entry:
[578]-> cal 9 2006
September 2006
S M Tu W Th F S
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
The above cal output would go to awk, which would output:
S
16
23
30
This would be piped to tail -1, which would return 30.
Dynamically Setting the Unix Xterm Variable with Awk
A co-worker was trying to run her X windows server on her laptop, and then run an xterm window from a unix box.
She used to be able to do it, but something changed and the IP address she hard-coded in her display setting is not working. It looks like her VPN (Virtual Private Network) keeps changing her laptop's IP address.
So, I figured how to look up the address dynamically.
For example, instead of running:
xterm -display 192.184.90.168:0.0
I had her run:
xterm -display `who -m|awk '{print substr($NF,2,length($NF)-2)}'`:0.0
Let's analyze this. First, we are running the who -m command. It has an output like:
user pts/4 Mar 20 09:31 (192.184.90.168)
We pipe it to awk. With awk, $NF is the last field: (192.184.90.168)
We need to strip off the parenthesis. So, we use the substring function to choose the substring that starts with the second character, and is 2 characters shorter than the total string.
So, for example, (192.184.90.168) is 16 characters long. So, by selecting the substring that starts with position 2 and is 14 characters long, we return 192.184.90.168.
She used to be able to do it, but something changed and the IP address she hard-coded in her display setting is not working. It looks like her VPN (Virtual Private Network) keeps changing her laptop's IP address.
So, I figured how to look up the address dynamically.
For example, instead of running:
xterm -display 192.184.90.168:0.0
I had her run:
xterm -display `who -m|awk '{print substr($NF,2,length($NF)-2)}'`:0.0
Let's analyze this. First, we are running the who -m command. It has an output like:
user pts/4 Mar 20 09:31 (192.184.90.168)
We pipe it to awk. With awk, $NF is the last field: (192.184.90.168)
We need to strip off the parenthesis. So, we use the substring function to choose the substring that starts with the second character, and is 2 characters shorter than the total string.
So, for example, (192.184.90.168) is 16 characters long. So, by selecting the substring that starts with position 2 and is 14 characters long, we return 192.184.90.168.
Term Life Insurance
The two main categories of life insurance are term and permanent life. In this article, we will look at term life.
Term life is very simple to understand. A person chooses an amount ($500,000 for example) and a time period (for example 20 yr term) for the insurance to cover. The cost is then generated based on the person's risk factors - such as if he smokes, etc.
If the person dies during the coverage period, then the person's beneficiary(ies) will collect the money. If the period ends without the person dying, then the insurance can be renewed - but probably at a higher cost.
Term life is cheaper than many forms of permanent life (such as whole life) because the person is ONLY paying for the death benefit, while customers of the other kind also pay an investment portion. Also, permanent life insurance lasts for your entire life while, as mentioned earlier, term life has a set amount of time that it covers.
Usually, this extra investment portion is a waste, because most people would be better off keeping their insurance and investments separately. Insurance investments tend to lag the market and have high fees.
So, for example, rather than buying a whole life plan, someone may just choose 20 year term life insurance (because their children will be grown by then) and invest the difference in premiums in an index fund, and come out ahead.
Term life is very simple to understand. A person chooses an amount ($500,000 for example) and a time period (for example 20 yr term) for the insurance to cover. The cost is then generated based on the person's risk factors - such as if he smokes, etc.
If the person dies during the coverage period, then the person's beneficiary(ies) will collect the money. If the period ends without the person dying, then the insurance can be renewed - but probably at a higher cost.
Term life is cheaper than many forms of permanent life (such as whole life) because the person is ONLY paying for the death benefit, while customers of the other kind also pay an investment portion. Also, permanent life insurance lasts for your entire life while, as mentioned earlier, term life has a set amount of time that it covers.
Usually, this extra investment portion is a waste, because most people would be better off keeping their insurance and investments separately. Insurance investments tend to lag the market and have high fees.
So, for example, rather than buying a whole life plan, someone may just choose 20 year term life insurance (because their children will be grown by then) and invest the difference in premiums in an index fund, and come out ahead.
Awk's SPLIT Function
Awk has a split command, which takes a string and splits it into an array, and returns the number of elements. The default separator is white space.
As an example, let us assume that a line in a logfile consists of:
4/2/2003 11:23:18 This is a log entry with timestamp.
and we have an awk program like this:
{
split($1,DATE,"/")
n = split($2,TIME,":")
print "Month is "DATE[1]
print "Minutes are "TIME[2]
print "Time has "n" parts"
}
Running the program against the logfile line would result in the following output:
Month is 4
Minutes are 23
Time has 3 parts
Thursday, June 11, 2009
I'm Becoming Semi-famous!
| I guess I'm becoming known for teaching stock trading because I saw today that someone is bidding on my name in Google Adwords. If you do a Google search for Praveen Puri, their ad pops up with the headline "Avoid Praveen Puri" and then says to buy their stock trading system instead. That's so cool and I'm so flattered! |
Friday, June 05, 2009
Can I Borrow $25?
| A man came home from work late, tired and irritated, to find his 5-year old son waiting for him at the door. SON: 'Daddy, may I ask you a question?' DAD: 'Yeah sure, what it is?' replied the man. SON: 'Daddy, how much do you make an hour?' DAD: 'That's none of your business. Why do you ask such a thing?' the man said angrily. SON: 'I just want to know. Please tell me, how much do you make an hour?' DAD: 'If you must know, I make $50 an hour.' SON: 'Oh,' the little boy replied, with his head down. SON: 'Daddy, may I please borrow $25?' The father was furious, 'If the only reason you asked that is so you can borrow some money to buy a silly toy or some other nonsense, then you march yourself straight to your room and go to bed. Think about why you are being so selfish. I don't work hard everyday for such childish frivolities.' The little boy quietly went to his room and shut the door. The man sat down and started to get even angrier about the little boy's questions. How dare he ask such questions only to get some money? After about an hour or so, the man had calmed down , and started to think: Maybe there was something he really needed to buy with that $25.00 and he really didn't ask for money very often. The man went to the door of the little boy's room and opened the door. 'Are you asleep, son?' He asked. 'No daddy, I'm awake,' replied the boy. 'I've been thinking, maybe I was too hard on you earlier' said the man. 'It's been a long day and I took out my aggravation on you. Here's the $25 you asked for.' The little boy sat straight up, smiling. 'Oh, thank you daddy!' He yelled. Then, reaching under his pillow he pulled out some crumpled up bills. The man saw that the boy already had money, started to get angry again. The little boy slowly counted out his money, and then looked up at his father. 'Why do you want more money if you already have some?' the father grumbled. 'Because I didn't have enough, but now I do,' the little boy replied. 'Daddy, I have $50 now. Can I buy an hour of your time? Please come home early tomorrow. I would like to have dinner with you.' The father was crushed. He put his arms around his little son, and he begged for his forgiveness. It's just a short reminder to all of you working so hard in life. We should not let time slip through our fingers without having spent some time with those who really matter to us, those close to our hearts. Do remember to share that $50 worth of your time with someone you love. If we die tomorrow, the company that we are working for could easily replace us in a matter of hours. But the family & friends we leave behind will feel the loss for the rest of their lives. |
The Preacher
| A deacon is in the hospital and his good friend, a preacher, goes to visit him. The preacher notices all the medical equipment attached to the deacon. He kneels by the bed. The deacon motions to a pad and pen on the nightstand. The preacher hands his friend the pad and pen, and the deacon begins to write. Suddenly, the deacon dies. At his funeral, the preacher delivers the service. He says, "I was with him when he died, and as a matter of fact, I have his last thought in my coat pocket here." The preacher pulls out the paper and reads, "Please, get up. You're kneeling on my oxygen hose." |
Tuesday, June 02, 2009
Source for Mailing and Emailing Lists
I found out about a good source for mailing and telemarketing lists. It is a firm called "The List Company", and they have a database with millions of businesses and individuals.
Even more importantly, they focus on quality, and make a serious effort to scrub out invalid names and addresses.
Also, they collect a lot of data about each person or business, which lets them "slice and dice" from their database to pull out tightly targeted telemarketing lists for any niche - such as a mortgage mailing list or a list of dentists.
Together, the targeting and lack of invalid addresses should increase their customer's response rate - thus bringing their cost per lead and/or cost per customer down.
The bottom line is more money and for example, even lower priced items could be offered on your telemarketing list.
Even more importantly, they focus on quality, and make a serious effort to scrub out invalid names and addresses.
Also, they collect a lot of data about each person or business, which lets them "slice and dice" from their database to pull out tightly targeted telemarketing lists for any niche - such as a mortgage mailing list or a list of dentists.
Together, the targeting and lack of invalid addresses should increase their customer's response rate - thus bringing their cost per lead and/or cost per customer down.
The bottom line is more money and for example, even lower priced items could be offered on your telemarketing list.
Oracle Single Character WildCard
In Oracle, a "%" matches 0 or more characters. An "_" (underscore) matches 1 character.
For example:
Select * from table where name like 'p%';
Would select records that start with "p", such as:
p, peter, patrick
If you wanted to select records that had at least one character after the "p", you
would use:
Select * from table where name like 'p_%';
This would return: peter, patrick
For example:
Select * from table where name like 'p%';
Would select records that start with "p", such as:
p, peter, patrick
If you wanted to select records that had at least one character after the "p", you
would use:
Select * from table where name like 'p_%';
This would return: peter, patrick
Perl Hacking
JAPH stands for "Just Another Perl Hacker".
While surfing the net, I came across this article on Just Another Perl Hacker.
It seems that a tradition has developed among perl users to keep figuring out inventive ways to write a perl program of 4 lines or less that output: Just Another Perl Hacker.
Here is one of the simpler ones:
print "Just another Perl hacker," if "you can't think of anything better..."
This shows how perl gives you so many options (which isn't necessarily a good thing ;-) ).
Here, they are using the form
(action), if (condition)
Normally, it is more common for programmers (even in perl) to use
if (condition) then (action)
Anyway, since the condition is just a text string, it will always be non-zero (true), so the print statement will always work.
The article has more complex examples.
While surfing the net, I came across this article on Just Another Perl Hacker.
It seems that a tradition has developed among perl users to keep figuring out inventive ways to write a perl program of 4 lines or less that output: Just Another Perl Hacker.
Here is one of the simpler ones:
print "Just another Perl hacker," if "you can't think of anything better..."
This shows how perl gives you so many options (which isn't necessarily a good thing ;-) ).
Here, they are using the form
(action), if (condition)
Normally, it is more common for programmers (even in perl) to use
if (condition) then (action)
Anyway, since the condition is just a text string, it will always be non-zero (true), so the print statement will always work.
The article has more complex examples.
Subscribe to:
Posts (Atom)
