Amazon deals

Sunday, June 24, 2012

Choosing the right processor to buy

Computers and their parts are filled with millions of jargon's and specs making it difficult to understand them and find the right device for the right job. Let us shed some light into understanding the specifications of the core component of your computer - "the processor alias CPU"

The number of bits 32 bit vs 64 bit:
If you have not studied computer architecture this is definitely confusing for you. When you walk into buy a CPU the vendor will say that 64 bit is better than 32 bit, but you notice its costlier and you are unsure if you need it. Let us understand that by going for higher number of bits we have following advantages:

  • More bits means that data can be processed in larger chunks which also means more accurately.
  • More bits means our system can point to or address a larger number of locations in physical memory.

32-bit systems were once desired because they could address (point to) 4 Gigabytes (GB) of memory in one go. Some modern applications require more than 4 GB of memory to complete their tasks so 64-bit systems are now becoming more attractive because they can potentially address up to 4 billion times that many locations.

When should you actually buy a 64 bit CPU?

  1. You are going to buy/have a 64 bit OS (yes operating systems also come in variants)
  2. You are going to buy/are considering to have more than 4 GB of RAM
  3. You use/going to use 64 bit applications (eg: Adobe creative suite, Half Life 2)
  4. You are going to use virtualization and install multiple OS on top 
 Balancing the number of cores and the clock(GHz):
Go ask you friend who is a hardware engineer which is better a single core 3.2 GHz or dual core 1.6 GHz processor? If he is smart he will say the the single core one even tough the dual core one is effectively 1.6*2=3.2 because a considerable delay is caused because of needing to synchronize two processors. Don't agree? Try asking two people to work together on one person's job. If you enable Hyper-threading on the single core and change the two core configuration to 1.8 GHz and ask him what is better, I bet you he will scratch his head and say depends. A usefulness of a multi core configuration is dependent on the way you use you computer. So get a lot more cores (4-8) if you do the following

  • Watch a movie or play a game while there is some background work like video encoding going on on you machine
  • You are hosting multiple web/ftp/db servers on your machine that continuously take a lot of requests
Take lot of cores if you multi task and/or use programs that use the multiple cores to work faster(most programs aren't that optimized yet).  Otherwise Dave one or two cores ought to be fine for you.
Power consumption:
Probably one of the most important spec that is mostly forgotten to check by people is power consumption. This is very important especially if you processor sits on a laptop. More GHz/cores implies higher power consumption and can really drain your battery quickly. So you should find the right balance between power and power consumption. So when you compare two similarly configured intel core i3 and an intel core two duo you will find that the intel core i3 has a phenomenal drop in power consumption (30W isn't at a small drop)
Cache size:
Probably the only part of the specification that follows the real higher the better moto. Read more about it here 

Saturday, June 23, 2012

Understanding closure of functional dependencies

Understanding functional dependencies and closure gives you great power in designing or analyzing database schema. If you are new to functional dependencies you can read them up from here.

What is closure?
The closure of a set F of functional dependencies is the set of all functional dependencies logically implied by F.
What can we do by knowing closure?

We can find out several things about the relational database by knowing closure properties. I will list a few of these:

  • Finding a key for the relational schema: If we go through the closures of all elements in the functional dependency, the element for which the closure encompasses all the elements of the relation is the database key
  • Finding if a relation having composite candidate key is in 2NF (we only consider the composite case because  when a 1NF table has no composite candidate keys (candidate keys consisting of more than one attribute), the table is automatically in 2NF): If we take closure of a part of the key then there must not be any element other than itself in it. This ensures that all elements are dependent on the complete key itself
How to find closure?
I have written a tool for this which you can pick up from github . Also you can read about it here and also go through the example below.

To understand closure let us take an example of a relational database that stores a employee information. Let the fields in this relation be EID, NAME, ROLE, DIVISION,SALARY

For this we can logically see the following functional dependencies:
EID->NAME #every employee has a unique id
ROLE,DIVISION->SALARY #An employee's salary is determined by where he works and his role
EID,NAME->ROLE #Employee can have only one role
EID,NAME->DIVISION #Employee can work for only one division

  1. Let us validate using closure of the field EID whether EID is actually the key. Since we start with EID, our closure is initialized with {EID}.
  2.  Going through all the functional dependencies we see that attribute NAME depends on EID which is already in our closure set. We can add this and update our closure set to {EID,NAME}
  3. Now going through all functional dependencies again we see that we have ROLE dependent on EID and NAME (both already in closure set) and add ROLE to closure set.
  4. Traversing again we see SALARY dependent on ROLE and DIVISION but we skip it as DIVISION is not in our set yet.
  5. We see that DIVISION depends on EID and NAME and add it to our closure set to make it {EID,NAME,ROLE,DIVISION}
  6. Traversing again we see that we can add SALARY now as both ROLE and DIVISION are already in the closure making our closure {EID,NAME,ROLE,DIVISION,SALARY}
  7. We end our traversal when we have no more additions to make
  8. Thus looking at our closure we see indeed that EID is fit to be the primary key.

Friday, April 27, 2012

Map Google drive to a real drive on windows

So you just installed Google drive and noticed that it syncs to a folder on your machine. Oh geez I thought I will get a cool new drive letter assigned for me, but now I have to traverse to the Google's folder every-time. You know you can put a shortcut to that folder and use it but its still not a drive :(

So we learn how to map a folder to a drive on windows.

-> Open command prompt by typing cmd in your run
-> Enter the following command

 subst X: <path/to/google/drive>

X is any free available drive letter on your machine

Voila u got a whole new drive!!! 

Wednesday, April 25, 2012

What a programmer needs to know about ordinary differential equations

[What are ordinary differential equations? Read my detailed notes here on Evernote:Math:ODE]

Solving an ordinary differential equation is computationally expensive. One of the most common approximation methods used to solve this is euler. Understanding this for non math buffs means a lot of effort.(Lets say "Ordinary.Differential.Equations_Tenenbaum_Pollard" has too many pages). So I wrote a python program that implements both euler and its more accurate form the predictor corrector method and thought I will share it.

What are we trying to achieve?
  1. Implement euler and corrector predictor method
  2. Plot them on a graph to understand their nature
  3. Compare the graph plots to visually understand the accuracy differences
What equation are we trying to solve?

dy/dx = x + 2y

What python libraries do we need?

import math
from pylab import *

Show me the code?
What are the results?

We can visually see from the following plots that
  1. Reducing step size increases accuracy
  2. The predictor corrector (shown with '+' ) is more closer to original equation (shown with '.' ) than the traditional euler method (shown with '*')
  • When we plot from 0 to 3 with step size 0.2

  • When we plot from 0 to 3 with step size 0.1

  • When we plot from 0 to 3 with step size 0.01

    -- Python
    -- Pure awesomeness :)

    Sunday, November 20, 2011

    How to effectively recognize SCAMs & SPAMS

    With lot of spams and scams lurking around and the con artists getting better and better all the time I thought I would compile up my set of warning signals. Feel free to comment anything I miss out.

    • You are offered prize for a contest you never participated.
    • You are picked in a lucky draw, and to claim the reward you have to pay some money. (You ll surely lose every penny you pay)
    • You are asked to pay for a chance to participate in a bid that might get you something at an unbelievably low price. (Its like lottery right? I may win or not, but then again how do you know that actually picks a winner?)
    • The website offers free membership, but to activate your account you need to fill out your credit card details. (Don't blame your insurance company that they 'll not settle your claims for some crap purchased of your card in Nigeria by a con man)
    • You are asked to participate in a marketing scheme, your earnings depending on number of people you join for the scheme. Warning sign: there is no real product associated in the scheme/the product associated with scheme doesn't have the profit margin equivalent to the membership fees applicable
    • You are asked to deposit money in an account via unsecure means (eg:direct bank transfer to account) before delivery of material
    • You are asked to deposit money in an account via unsecure means (eg:direct bank transfer to account) for delivery of a material illegal in your country
    • Overseas travel at your own expenses required to claim the prize
    • The email claims to be from ebay/amazon/your bank but the return address is from a free account from yahoo/gmail than the from the original domain
    • You do not know the sender or have any association with the organisation the sender claims to be
    • The sender is listed in
    • You are redirected to a login page that looks like your bank/email login page but the url is from some other domain
    • The website of the offer has millions of testimonials and statistics, but it is never mentioned in your circle of friends nor on any other public forum online
    • You are the 1000000th visitor of the site
    • The product claims to provide benefits only after a prolonged duration (few months to years) and is not certified by any credible agency
    • Shortened url depicting porn or sensationalized news posted in social networks
    • Websites requiring to enter username and password of other unrelated companies eg: google/yahoo/fb  (these use open id so you shouldn't be entering your credentials anywhere else)
    • You are one among 100s of email ids in the to field and there is no one group that relates you to them.
    Let me know your warning list!!!

    Saturday, May 21, 2011

    The (almost) perfect guide for buying a cellphone

    1. Can you live without a smartphone?

    If the only use of your phone is to make calls, text and grab a few snaps and you can live being ridiculed for the rest of the life for not having a smartphone by quipping I'm smart so i don't need my phone to be smart, well you might just survive. But if you really need on the move light weight access to your mail, your docs and want to kill your boredom on the move with really fancy top notch games, then definitely go buy one.

    2. Where do you live?

    The single most important factor that decides what kind of phone you buy besides the cost and your need is your geographic location. Say you live in one of the third world countries (read India) which is not likely to be covered by 4G network anytime soon you definitely don't need a 4G phone. (You can scratch out EVO4 and IPhone 4 from your list now) Now if you live in an rural area currently covered by 2G , do a gut check whether 3G will be available anytime soon. If yes then only go for a 3G phone. If no settle down for a 2G phone, i don't think you would require a smartphone even as with slower network connectivity because of old age technology like EDGE you smart phone would be practically useless.

    Services and speeds (courtesy:
     1G  2G  2.5G 
    Speedsn/aLess than 20Kbps30Kbps to 90Kbps
    (voice only)
    Voice; SMS; conference calls; caller ID; push to talkMMS; images; Web browsing; short audio/video clips; games, applications, and ring tone downloads

     3G  3.5G  4G and beyond 
    HSDPA (upgrade for UMTS)
    Speeds144Kbps to 2Mbps384Kbps to 14.4Mbps100Mbps to 1Gbps
    FeaturesFull-motion video; streaming music; 3D gaming; faster Web browsingOn-demand video; videoconferencingHigh-quality streaming video;
    high-quality videoconferencing; Voice-over-IP telephony

    *WiMax has been mentioned as a possible 4G technology, but no standards have been set.

    3. What kind of hardware should your phone have?

    The most important factors of the phones performance are its processor and its RAM. So you tend to think if the number of MHz (or GHz) of your phones processor is more then its certainly faster right? So what is there to think about it, you may presume? Well, you should really think about how much processing you require as faster the processor the more it drains your battery. If you would never play angry birds on your phone, and all you need are docs and email you dont really need to go for the 1, 1.2 Ghz monsters. But yes if HD games are for you then definitely check the spec sheet whether the phone has an add on GPU as well. And about RAM yes the higher the better (try the latest iNand maybe)

    4. The brand factor....

    So if the single factor that made you think you need a smartphone is that you want to show off to the gullible folks around  and you don't really care about performance, stop reading and go get a skin deep iphone.

    5.Which operating system should your phone have?

    a) Apps
    So you shelled 20-40K INR on your phone. Then you need apps to do all the fancy stuff the phone boasts it can do. So you log on to the app store and you see every app you need tagged with a 10$ fee. Damn irritating rite? If you don't have all the money on the planet to invest on apps and don't really want to bear the burden of piracy  settle for a droid which has lots of free apps and open source support. If you have the money, well decide you want to see the same windows that adorns your computer choose a winphone or you want something trendy read the brand factor :P

    b) Upgradability

    So the company manufacturing your phone added some cool stuff to the operating system. They made it smarter smoother and power hungry. And now they are putting it on all new phones and you can't get it on yours. Congratulations the brand new phone you bought 6 months ago is outdated. Now you wouldn't have to deal with this if you are an android user. You can always upgrade and if you are the one who doesn't like change often stick to a winphone or an iphone.If you are a total geek who wants to push more and more into your phone get a droid. {for example my HTC hero came with android 1.5( with no bluetooth support even darn) and today i run android 2.3.4 in it (Bluetooth stack, DSP sound effects etc are few new features that were never in my phone when i bought it)}

    6. Battery life

    This is something most people ignore but trust me its really painful when you are on the move and your phone runs out of juice. Other than making the right hardware choice also look for power saving features in the phone like automatic brightness control, wifi sleep policy controls and the like so that you can keep your phone running longer. You don't want it to switch off when you are expecting the most important call of your life right?

    7. Can you still make phone calls?

    There is no use having a phone regardless of  its smart factor if you can't make phone calls with it.
     IPhone Antenna Issue

    Sunday, April 24, 2011

    Hello world!

    Its all in the syntax, whats your favourite?


    include<stdio.h> main() { printf("Hello World");}


    #include <iostream> void main(){ cout<<"Hello World";}


    class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); //Display the string. } }


    print "Hello World!";


    puts 'Hello World!'


    Program Hello
        Print *, "Hello World!"
    End Program Hello


    WRITE 'Hello World!'


             DISPLAY 'Hello, world!'
             STOP RUN.

    package main

    import "fmt"

    func main() {
         fmt.Println("Hello World!");


    hello_world() -> io:fwrite("Hello World!").

    <script type="text/javascript">
          document.write('Hello World!');
    hello = writes "Hello World!";
    SHAKESPHERE (I ll never code in this ever )
    This is part of the standard "Hello World" program in SPL. The statements assign numerical values to the other character, and "Speak your mind" is an order to the other character to output that value as a character.
    Romeo, a young man with a remarkable patience.
    Juliet, a likewise young woman of remarkable grace.
    Ophelia, a remarkable woman much in dispute with Hamlet.
    Hamlet, the flatterer of Andersen Insulting A/S.
                       Act I: Hamlet's insults and flattery.
                       Scene I: The insulting of Romeo.
    [Enter Hamlet and Romeo]
    You lying stupid fatherless big smelly half-witted coward! You are as
    stupid as the difference between a handsome rich brave hero and thyself!
    Speak your mind!
    You are as brave as the sum of your fat little stuffed misused dusty
    old rotten codpiece and a beautiful fair warm peaceful sunny summer's
    day. You are as healthy as the difference between the sum of the
    sweetest reddest rose and my father and yourself! Speak your mind!
    You are as cowardly as the sum of yourself and the difference
    between a big mighty proud kingdom and a horse. Speak your mind.
    Speak your mind!
    [Exit Romeo]
                       Scene II: The praising of Juliet.
    [Enter Juliet]
    Thou art as sweet as the sum of the sum of Romeo and his horse and his
    black cat! Speak thy mind!
    [Exit Juliet]
                       Scene III: The praising of Ophelia.
    [Enter Ophelia]
    Thou art as lovely as the product of a large rural town and my amazing
    bottomless embroidered purse. Speak thy mind!
    Thou art as loving as the product of the bluest clearest sweetest sky
    and the sum of a squirrel and a white horse. Thou art as beautiful as
    the difference between Juliet and thyself. Speak thy mind!
    [Exeunt Ophelia and Hamlet]
                       Act II: Behind Hamlet's back.
                       Scene I: Romeo and Juliet's conversation.
    [Enter Romeo and Juliet]
    Speak your mind. You are as worried as the sum of yourself and the
    difference between my small smooth hamster and my nose. Speak your
    Speak YOUR mind! You are as bad as Hamlet! You are as small as the
    difference between the square of the difference between my little pony
    and your big hairy hound and the cube of your sorry little
    codpiece. Speak your mind!
    [Exit Romeo]
                       Scene II: Juliet and Ophelia's conversation.
    [Enter Ophelia]
    Thou art as good as the quotient between Romeo and the sum of a small
    furry animal and a leech. Speak your mind!
    Thou art as disgusting as the quotient between Romeo and twice the
    difference between a mistletoe and an oozing infected blister! Speak
    your mind!

    More comprehensive list->