Wednesday, March 30, 2011

Blood Donation Experience

I guess it's been almost a week since I wrote last time. Yeah, for the first time in my life I donated blood. Always wanted to do it though. During my engineering days I got one opportunity but blood group didn't match. For whatever reasons could never do it.

In my first year here in US I went to give blood after seeing an email request for blood donation. Funnily, I wasn't eligible as the rule says one should be here at least 3 years before donating. Crazily, after that 4 years passed and never got chance again.

Finally, yesterday I got another email with the same request. This time evrything went well and they took one pint of Manchu bloodline. After giving blood the one thing I absolutely didn't understand was the fear of some people about donating blood. Anyway, it was nothing. It took exactly 5 minutes for me to draw a pint of blood. By the way one pint is almost 500ml. If you don't know the amount of blood in human body would be around 6 liters.

People asked me whether I was feeling dizzy, etc. To be frank I didn't feel anything. Overall, it was very good expirience and for a good cause. I have decided to donate blood at least 4 times a year.

By the way, I forgot to add something. They give you some snacks along with some juice in case that helps. It seems in America 60 percent of the people are eligible to give blood, but only 2 percent donate. I guess it's social responsibility of everyone because in the end we are helping ourselves but not any other species. More over, there is no replacement for human blood and platelets.

Sent from my phone.

Wednesday, March 23, 2011

CC and BCC fields in Gmail

I'm not sure how many of you use these fields regularly when emailing people from Gmail. Being a user support specialist I got to use this very often.

I can always use the To field it self. But there is a purpose for CC and BCC fields. They stand for carbon copy and blind carbon copy respectively. To field is used for people who you intend to send. CC field is used to make other people understand you sent the email to the intended. For example, you can cc the emails to your boss to let him know that you are doing the duty. BCC is used when you don't want the person to know whom else you are sharing the email with and hence blind.

Coming to the point, like I said a while back I need to cc the emails to my group when ever I answer users' questions. I always use Apple mail client as I work in Mac environment. Recently, my university switched to Gmail. I don't have MobileMe subscrption with Apple. Which means I can't synchronize my mail clients on office and home computers which is a big nuisance. It costs $99 for year to have this subscrption. In a way it was a blessing in disguise that university switched to Gmail. Since it is a web interface I don't have to worry about synchronizing my laptop and desktop unless I want to store the emails for offline use. Even then it works but with some complicated setup which I will explain later.

In Apple mail CC field is always open. Where as in Gmail interface it's not. Which means I need to click everytime I want to cc the email to my different groups. I amsure you might be thinking what the heck. Right? Believe me you'd feel the same way if you are used to using keyboard all the time. You can do things fast if you are used to keyboard. So I wanted to have my Gmail compose window open up with cc field open whenever I want to write a new email or reply people. Fair enough. Unfortunately, it's not easy. Since Iike using keyboard I opyed for keyboard shortcuts in settings. Then if you press d the compose window opens up with cc field open. Great! But this shortcut doesn't work when you want to to reply to some email that's been there inyour inbox. Frustrating.

The next solution would be using some javascript. It's a nice solution since Gmail heavily uses javascript it is highly customizable. So before I started writing my own script with my not so co siderable javascript experience I wanted to google for it. First thing that came up was the solution I wanted. How exciting. Ha! Except that itdoesn't work with new Gmail user interface. So now I am determined to write it onmy own. I don't know how long it's going to take as I'vegot million things to do at my work.

I will definitely post it here as soon as I finish it. In the mean time I got to get off the bus before it goes beyond my place. Home sweet home.

Sent from my phone.

PATH's response

Yesterday I sent an email to PATH managememt about path cars not showing the time change. I was very surprised to see the prompt response. They wrote they had a software glitch because of which time change never updated. Fair enough as I can see that happening. Few years back time change used to be on the exact date all the time. Not anymore. Now it moves a week or two depending on some weather factors. I guess their software wasn't ready for that. Sounds silly but I do see a lot like this.

Anyway, they said they had been trying to change time manually. Even then it shouldn't have taken more than a week. At least, I am glad that they know the problem and accepted it and trying to fix it. That's what I call professionalism at work. They asked me to send the car numbers if I didn't see the time update. I will I see one. The coach I got off just now was showing right time. Over all felt great.

Sent from my phone.

Hazy New York

Every day I get to see New York from the other side of Hudson river during my commute. It always amazes me. For some reason it never gets bored.

Today out of no where it snowed after a while. In fact, it is still raining here. From the bus just like I do everyday I looked at New York and I was in awe for a while. I couldn't resist from taking a picture. It's not a great pic as it doesn't depict how I felt and what I truly saw. Anyway, thought I should share it with you guys.

Sent from my phone.

Tuesday, March 22, 2011

Zoo: Prison for wild animals

I don't think any humanbeing would like to go to prison. I just don't understand the fascination of people to visit wild animals that are kept in the zoo. If you think about it straight you would feel sick. How would one feel if some other life comes along from some other planet and keep him or her in their zoos for others to see. I wish there was something like that. Please think twice before you going or taking your children to zoo. It just doesn't make sense to keep wild animals in the zoo as it takes off the meaning of being wild animal.

I don't remember where it happened but when people tried to send wild animals born in zoos back to wilderness those animals had no clue on how to survive. Most of them died. It's just like the way it works with people. You just can't teach language skills to some one who is never exposed to any language before. In fact it happened with some one in California.

Just a while back read something about zoo and thought of writing this. If someone is curious to see wild animals then in my opinion he/she should go to either safaris or watch documentaries like the ones from BBC. Please don't support zoos. If is just not humane.

Sent from my phone.

Leap Year

For me when I was child or for that matter until I got into engineering leap year was the year which was divisible by 4. This is what I was taught in my school. Everything was fine until one day I had to write a C program for finding whether a given year was leap year or not. In my exam I thought I wrote the program well and expected to get full marks. I think it was first mid term in my first year of engineering at JNTU, Hyderabad.

When I got back my answersheet with half mark out of 3 ( or 5, I am not sure), first I was like what the hell and then felt happy to think that I would get full marks. Then I went and asked the instructor to give me full marks. I still remember his expression on his face. It was a huge ridicule. He announced it loudly in the class that definition of leap year was not just divisible by 4. I felt very embarrassed. Definitely not because he ridiculed me but because I didn't know it.

Anyway, here is the actual definition. You might or might not be knowing it. Even if you knew it I'm not sure whether you know the actual reason behind it. So the definition goes like this.

The given year should be divisible by 4 and shouldn't be divisible by 100 or should be divisible by 400. So the logic is simple. In any programming language you can use logical operators to define this. As an example I wrote the C program and put it in one of my previous posts. Check it out. So in a way you can say that any year that is divisible evenly by 4 and not evenly by 100 or evenly by 400 are leap years. For example, 2004 is evenly divisible by 4 and not evenly by 100. So 2004 is leap year. How about 2100. Even though it is evenly divisible by 4 is not leap year as it is also evenly divisible by 100. So 2100 is not leap year. How about 2400? It is leap year even though first half of the logic fails. Because the second half of the logic works here. Logical operator OR comes into picture here. 2400 is divisible by 400 and hence it is a leap year.

Up to this point it was just academic stuff. But the good stuff comes now. At least for me the most interesting part was why we do follow something of this critical to find out whether the given year is leap year or not. There is a brilliant reason behind this.

These days thorough out the world we follow Gregorian calendar. In this calendar we have 365 days per year. Right? In reality this is 6 hours shorter than solar year. Solar year is nothing but the amount of time it takes for earth to finish one revolution around sun. So to compensate this lost 6 hours per year we put 4 of these 6 hours together to make one day and put it in the month February every 4 years. Which means February in that year has one extra day and a total of 29 days. We call this year a leap year. This explains the first of the leap year being divisible by 4. How about second and third part. Let's go to next paragraph.

Ok. In my previous paragraph I said the time of 365 days is 6 hours shorter than solar year. Right? Let me take back those words. The exact value is slightly smaller than 6. In other terms you can say every year we are going little bit ahead of solar year by considering 6 hours in stead of an exact value which is slightly smaller than 6. So people found that after 100 years the little bit extra time sums up to become one day, i.e., 24 hours. Now you can say how much extra time we are going ahead every year? Got it? yep it is 1/100th part of day, which is nothing but 14.4 minutes. So you can say solar year is 365 days + 6 hours - 14.4 minutes. This explains year not being divisible by 100 in the logic. It is just that we don't consider leap every 100 years so that we lose one day we went ahead by taking leap years every 4 years in those 100 years. Ok let's move onto next paragraph. It's not over yet.

In my last paragraph I calculated the solar year as 365.25-0.01 (6 hours is 1/24=0.25 days, 14.4 min=14.4/60/24=0.01 days). So the number is 365.24. Not exactly. It seems the number is slightly bigger than this. How big? It is big enough in a way every 400 years it equals one day. So by taking this number and not considering the exact number we are a day behind the solar year every 400 years. So you can say that solar year is 365.24+1/400 (it takes 400 years to become 1 day. So in one year it is 1/400 th day which equals 3.6 minutes). So the solar year comes to 365.2425 days.

After all this if you think you have got the right number for solar year I say you are wrong. It seems the solar year value keeps increasing. It never stays constant. For now the exact value for solar year is 365.242374 days. You can see that it is slightly shorter than our value by 0.000125 days. Which means in another 8000 years it becomes one day. So in 8000 years we got to come back one day to sync with calendar. Which means the year 8000 should not be leap year. Again there is another catch though. Like I said the solar year keeps increasing. The time it takes for earth to go around the sun is increasing little by little every year. So in a way in another 8000 years the solar year keeps increasing and this way both the calendar and solar year sync.

Overall the way calendar system works is amazing. Don't you think so? Best part is people figured it out. Always amazes me. Anyway, got to go. If you are interested in knowing more go ti wikipedia and they have wonderful stuff.

Spelling Alphabet

Back in 2003, for the first time, I went out of India to do my masters in Sweden. Soon I had to make lot of phone calls to different places and different people. I always had tough time whenever I had to tell them my name. They would ask me to spell it and they wouldn't understand any alphabet when I spelled it out for them. It used to take hell lot of time before I made them understood.

Eventually, I came to states for my Ph.D and over the time my English spoken skills definitely improved. At the beginning it was just as difficult as it was in Sweden. Gradually, some of the customer representatives had no problem at all in understanding my accent. Overall, I got tired of this and so started looking into spelling alphabet.

If you don't know what spelling alphabet are let me explain it to you here. In certain situations where it is hard to differentiate between different alphabet you spell some word for that specific alphabet like e for echo. For example, in the noisy situations, it's easy to say something using these spelling alphabet. They use this in navigation where decibel levels are high. People use them when they have to convey something to soldiers in the battlefield. You can see something like this in world war movies.

Anyway, coming back to my situation, I started spelling my name out to people on phone using these spelling alphabet. Whenever they ask my name I say: S for Sierra, R for Romeo, E for Echo, E for Echo, D for Delta, H for Hotel, A for Alpha, R for Romeo, M for Mike, A for Alpha, N for November, C for Charlie, H for Hotel and U for Uniform. Bam! They get it without any problems. If they don't get it even after this then Gold help us all.

Anyway here are the spelling alphabet in case you are interested. These vary from country to country. But overall these work well as these are NATO accepted.
A for Alpha
B for Bravo
C for Charlie
D for Delta
E for Echo
F for Foxtrot
G for Golf
H for Hotel
I for India
J for Juliet
K for Kilo
L for Lima
M for Mike
N for November
O for Oscar
P for Papa
Q for Quebec
R for Romeo
S for Sierra
T for Tango
U for Uniform
V for Victor
W for Whiskey
X for X-ray
Y for Yankee
Z for Zulu

It helped me like anything having learned these spelling alphabet. I am sure it would help you too in case you are not native English speaker just like me. In other words you have accent too.

Exit on interstate: Left or Right?

This is good one. Let's say you are on interstate and you don't know which side your exit is going to come for your town/city. Don't assume that it's going to be on right. Yeah most of the times that's true. Some times it does come on your left. So if you stay on right you are pretty much screwed.

So how do you figure it out? Solution is to look at the boards that show how far away your exit is going to be. For example, let's say your exit is going to come in another mile. The board shows the exit number in a small square on top of big square. Right? The big square shows the town/city name and how much distance is left for you to reach exit from there. Ok. So it has exit number, destination name and the distance left to exit. But it doesn't say anything about which side exit is going to come. Actually, it does. Just not explicitly.

Here is the clue. If the small square that has exit number on it stays on right side on top of the big square then your exitis going to be on your right. If it is on left side thenit comes on left. Simple, neat and effective. Right?

Sent from my phone.

House numbering based on direction

You guys ever wondered about house numbering system here in US. I did. You can easily determine which side the house or apartment is going to be if you know the direction you are walking.

If you are walking towards east even numbers come on your right and odd numbers on left. It is exactly opposite if you are walking towards west.

The same rule applies to north and south. North is like east and south is like west. As simple as that.


Sent from my phone.

Monday, March 21, 2011

PATH Trains: Time hasn't been changed

It's been more than a week since time change happened. Still these PATH trains haven't updated it yet. So much for saying we are fast.

Just now wrote them an email requesting them to update the time on the display screens inside the coaches. Hope they read the emails.

Let's see whether they oblige. Will let you know.

Sunday, March 13, 2011

Caffeine and InsomniaX for Mac OS X

I think I came across these two applications almost 2 to 3 years back. These are very useful in their own ways. First one, Caffeine, keeps your system screen from automatically dimming, going to sleep or starting screensavers. You can write a simple script to start and stop this application at certain times in a day so that it would come alive by the time you go to your office and turn off at the end of the day right before you leave your office. Check my previous posts for the scripts and setting up alarms through iCal.

The second application is InsomniaX. Did you ever wish that you could run your macbook even after closing the lid. I always until I found this as I don't like having any bit of light when I go to sleep and at the same time I always wanted to run some stuff on my mac while I went to bed. This is where this application came handy. Now you know what it is for. It just prevents the laptop from going to sleep even after you close the lid to keep the applications running.

I don't know how battery life would be affected because of these two applications. I don't like using Caffeine on my laptop as I think it would affect the battery life. But if you have desktop I highly recommend it. On laptops we might forget to turn it off and it eats the battery life off. I don't think this is the problem with the second one.

Just wanted to share. I'm sure you must be knowing about these apps but if you don't here you found it.

C program to check whether a given year is leap year

Program
/* This program checks whether the given year is a leap year or not */
#include <stdio.h> /* It's ok not to have space between include and <stdio.h> */

int main (void) /* It's ok not to have space between main and (void). You can drop void off too. */
{
 int year;
 
 printf("\nEnter the year: ");
 scanf("%d",&year);
 
 if ( (year%4 == 0 && year%100 != 0) || year%400 == 0 )
  printf("\n%d is a leap year.\n\n",year);
 else
  printf("\n%d is not a leap year.\n\n",year);
 
 return; /* "return ;" works too. "return 0" works too. "return (0)" works too.*/ 
}
Compilation, Run and Output
[sreedhar@manchu2 cprogs_work_machine]$ gcc calendar.c -o calendar
[sreedhar@manchu2 cprogs_work_machine]$ ./calendar 

Enter the year: 2000

2000 is a leap year.

[sreedhar@manchu2 cprogs_work_machine]$ ./calendar 

Enter the year: 2001

2001 is not a leap year.

[sreedhar@manchu2 cprogs_work_machine]$ ./calendar 

Enter the year: 2004

2004 is a leap year.

[sreedhar@manchu2 cprogs_work_machine]$ ./calendar 

Enter the year: 2100

2100 is not a leap year.

[sreedhar@manchu2 cprogs_work_machine]$

C program to print fibonacci numbers

Program
#include <stdio.h>

int main()
{
 int a,b,temp,n;

 printf("\nEnter the number upto which you want fibonacci sequence: ");
 scanf("%d",&n);
 
 printf("\nFibonacci Sequence upto %d:\n",n);

 a=0;
 b=1;
 printf("\n%d, %d",a,b);
 while (b <= n)
 {
  temp=b;
  b=a+b;
  a=temp;
  if (b <= n) printf(", %d",b);
 }
 printf("\n\n");

}
Compilation, Run and Output
[sreedhar@manchu2 cprogs_work_machine]$ gcc fibonacci.c -o fibonacci
[sreedhar@manchu2 cprogs_work_machine]$ ./fibonacci 

Enter the number upto which you want fibonacci sequence: 21

Fibonacci Sequence upto 21:

0, 1, 1, 2, 3, 5, 8, 13, 21

[sreedhar@manchu2 cprogs_work_machine]$

C program for bubble sorting

Program
#include <stdio.h>

#define SIZE 5

int main()
{
  int a[SIZE],b[SIZE];
  int temp,i,j;

  printf("\nBubble Sorting\n");
  printf("\nEnter the %d numbers: ",SIZE);

  for(i=0; i<SIZE; i++)
    scanf("%d",&a[i]);

  for(i=0; i<SIZE; i++)
    {
      for(j=SIZE-1; j>i; j--)
 {
   if (a[j-1]>a[j])
     {
       temp = a[j-1];
       
       a[j-1] = a[j];
       
       a[j] = temp;       
     }
 }
    }

  printf("\nSorted numbers: \n");
  for(i=0;i<SIZE;i++) printf("%d ",a[i]);

  printf("\n\nIf you need to sort more than %d numbers, change SIZE in porogram\n\n",SIZE);
  
}
Compilation, Run and Output
[sreedhar@manchu2 cprograms]$ gcc bubble_sort.c -o bubble_sort
[sreedhar@manchu2 cprograms]$ ./bubble_sort 

Bubble Sorting

Enter the 5 numbers: 8 3 16 24 19

Sorted numbers: 
3 8 16 19 24 

If you need to sort more than 5 numbers, change SIZE in porogram

[sreedhar@manchu2 cprograms]$ ./bubble_sort 

Bubble Sorting

Enter the 5 numbers: 6 3 15 27 1

Sorted numbers: 
1 3 6 15 27 

If you need to sort more than 5 numbers, change SIZE in porogram

[sreedhar@manchu2 cprograms]$

C program to print prime numbers in a given range

Program
#include <stdio.h>

int main()
{
  int a,b,num,n,i;

  printf("\nEnter the number range (a b) (a > 1 and b > 1): ");
  scanf("%d %d",&a,&b);

  n=0;
  for(num=a;num<=b;num++)
    {
      for(i=1;i<=num/2;i++)
 {
   if (num%i == 0 && i != 1 && num != 2 && num != 3)
     break;
   else
     {
       if (i == num/2)
  {
    printf("\n%d is a prime number.\n",num);
    n=n+1;
  }
       continue;
     }
 }
    }
  
  if (n == 0) printf("\nNo prime numbers in the range %d - %d\n",a,b);
  else printf("\n%d prime numbers in the range %d - %d\n",n,a,b);

  return 0;
}
Compilation, Run and Output
[sreedhar@manchu2 cprograms]$ gcc prime_range.c -o prime_range
[sreedhar@manchu2 cprograms]$ ./prime_range 

Enter the number range (a b) (a > 1 and b > 1): 2 50

2 is a prime number.

3 is a prime number.

5 is a prime number.

7 is a prime number.

11 is a prime number.

13 is a prime number.

17 is a prime number.

19 is a prime number.

23 is a prime number.

29 is a prime number.

31 is a prime number.

37 is a prime number.

41 is a prime number.

43 is a prime number.

47 is a prime number.

15 prime numbers in the range 2 - 50
[sreedhar@manchu2 cprograms]$

C Program to check whether a given number is a prime number

Program
#include <stdio.h>

int main()
{
  int num,i;

  printf("\nEnter the number: ");
  scanf("%d",&num);

  if (num == 1) printf("\nNumber 1 is neither primie nor composite.\n");
  void exit();

  for(i=1;i<=num/2;i++)
    {
      if (num%i == 0 && i != 1 && num != 2 && num != 3)
 {
   printf("\n%d is not a prime number.\n",num);
   break;
 }
      else
 {
   if (i == num/2) printf("\n%d is a prime number.\n",num);
   continue;
 }
    }
  return 0;
}
Compilation, Run and Output
[sreedhar@manchu2 cprograms]$ gcc prime.c -o prime
[sreedhar@manchu2 cprograms]$ ./prime

Enter the number: 24

24 is not a prime number.
[sreedhar@manchu2 cprograms]$ ./prime

Enter the number: 23

23 is a prime number.
[sreedhar@manchu2 cprograms]$ ./prime

Enter the number: 2

2 is a prime number.
[sreedhar@manchu2 cprograms]$ ./prime

Enter the number: 1

Number 1 is neither primie nor composite.
[sreedhar@manchu2 cprograms]$

The Next Three Days

Watched this movie just now. Loved it. Russel Crowe was simply awesome. I wish Elizabeth Banks' role was played by some other woman. Luckily, she doesn't have that big role even though whole movie revolves around her. Believe me it would make you tense. Yeah, it will. But, it's for good. RedBox has it now. So go and get it soon before you postpone forever.

Saturday, March 12, 2011

C Program to print armstrong numbers in a given range of numbers

Program
#include <stdio.h>

int main()
{
  int num,n,m,digits,sum,a,b,i;
  
  printf("\nEnter the range (a b): ");
  scanf("%d %d",&a,&b);
  
  num=0;
  for(i=a;i<=b;i++)
    {
      if ( i == a)
         {
            digits=0;
            m=i;
            while (m != 0)
               { 
           digits++;
                  m=m/10;
               }
          } 
       
       if ( (i != a) && (i/power(10,digits) == 1)) digits++;
          

      sum=0;
      n=i;
      while (n != 0)
 {
   sum=sum+power(n%10,digits);
   n=n/10;
 }
      if (sum == i)
 {
   printf("\n%d is an Armstrong number\n\n",i);
   num++;
 }
    }
  printf("\nThere are %d Armstrong numbers in the range %d - %d\n\n",num,a,b);
  return 0;
}

int power(int x, int y)
{
  int xpy,i;
  
  xpy=1;
  for (i=1;i<=y;i++)
    xpy=xpy*x;
  
  return(xpy);
}

Compilation, Run and Output
[sreedhar@manchu2 cprograms]$ gcc armstrong_range.c -o armstrong_range
[sreedhar@manchu2 cprograms]$ ./armstrong_range 

Enter the range (a b): 11 1000000

153 is an Armstrong number


370 is an Armstrong number


371 is an Armstrong number


407 is an Armstrong number


1634 is an Armstrong number


8208 is an Armstrong number


9474 is an Armstrong number


54748 is an Armstrong number


92727 is an Armstrong number


93084 is an Armstrong number


548834 is an Armstrong number


There are 11 Armstrong numbers in the range 11 - 1000000

[sreedhar@manchu2 cprograms]$

C Program to check whether a given number is an Armstrong number

Definition: Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits.

Program
#include<stdio.h>

int main()
{
  int num,n,m,sum,digits;
  printf("\nEnter the number: ");
  scanf("%d",&num);

  digits=0;
  m=num;
  while (m != 0)
    {
      digits++;
      m/=10;
    }

  sum=0;
  n=num;
  while (n != 0)
    {
      sum=sum+power(n%10,digits);
      n=n/10;
    }
  if (sum == num)
    {
      printf("\n%d is an Armstrong number\n\n",num);
    }
  else
    {
      printf("\n%d is not an Armstrong number\n\n",num);
    }
  return 0;
} 

int power(int x, int y)
{
  int xpy,i;
  
  xpy=1;
  for (i=1;i<=y;i++)
    xpy=xpy*x;
  
  return(xpy);
}
Compilation, Run and Output
[sreedhar@manchu2 cprograms]$ cc armstrong.c -o armstrong
[sreedhar@manchu2 cprograms]$ ./armstrong

Enter the number: 152

152 is not an Armstrong number

[sreedhar@manchu2 cprograms]$ ./armstrong

Enter the number: 153

153 is an Armstrong number

[sreedhar@manchu2 cprograms]$ ./armstrong

Enter the number: 1634

1634 is an Armstrong number

[sreedhar@manchu2 cprograms]$ ./armstrong

Enter the number: 54748

54748 is an Armstrong number

[sreedhar@manchu2 cprograms]$

Starting and Quitting Applications on Mac OS X through AppleScript and iCal

This time some useful stuff here unlike my previous posts which were nothing but useless ramblings on my life. At my job I need to be on Adium application all the day. If you don't know what Adium is it's nothing but free IM client for Mac OS X that supports multiple IM networks like Google Talk, Yahoo Messenger, etc.

Early in the morning, as soon as I go to work I don't have problems to remember to log on to Adium. But most of the times I tend to forget to log out of it before I leave at the end of the day. So, I thought of making it automatic through some script. Since my OS is Mac OS X I thought it would be better if I used AppleScript. So started my foray on to it.

My script looks like below to start and quit application Adium. You can pretty much start and stop any application like this by replacing Adium with it's name.

Script to start the application
tell application "Adium"
    activate
end tell

Script to stop the application
tell application "Adium"
    quit
end tell

I don't think there is any need to explain the script as it is self explanatory. This is a very trivial script. You can do crazy stuff with this AppleScript. Just google for it and you find tonnes of pages.

As you can see it doesn't tell anything about the time it's going to start and stop Adium. Good catch! The trick is to use iCal for this purpose. Create a new event and under alarm options choose "run script". It let's you choose your saved above script. In the event you can specify at what time everyday it should start. For example, I set up two recurring events on week days. First event starts at 9AM and runs the first script. I named the script as start_adium. The second event runs at 5PM and runs the second script through alarm settings which I named it as stop_adium.

That's it. Now it's automated to start and stop Adium on every week day. Cool. Ha! But there are disadvantages to it too. Even if you are not on time to the office script gets run exactly at the specified time. Which means people think that you are there in the office. Again I don't care about this and it works for me. I'm sure there must be ways to write a script to make it start and stop as soon as you unlock and lock the screens. I guess no one forgets to lock the screen if he is a system admin. Right? Since I have this idea right now I'll try to look into this and let you know if I find something.

Note: Use shortcut "Command + Space bar" to initiate Spotlight and type applescript. As you type you would see AppleScript Editor next to applications. Hit enter and you see an AppleScript editor to write your script. Just for start, you can copy my script on it and run it to see what happens. Use some other application name in the place of Adium if you don't have it on your system. Hope this helps someone.

PBS Script Generator: Interdependent dropdown/select menus in Javascript

PBS SCRIPT GENERATOR
SH/BASH TCSH/CSH
Begin End Abort

About Me

LA, CA, United States
Here I write about the battles that have been going on in my mind. It's pretty much a scribble.

Sreedhar Manchu

Sreedhar Manchu
Higher Education: Not a simple life anymore