Category Archives: Articles

90 days of Summer

No, not a sequel of the movie ‘500 Days of Summer’. This is about my 3 month long internship at TradeHero.

I peaked my productivity chart once again after a very very long time (read, after 3 years). The last time i was this productive, was during my 3rd year at college. It all started with a long travel on 28th May, 2013 from Göteborg to Singapore via Köpenham and Zurich.

I reached Singapore on 29th and navigated myself to the booked accommodation at Jalan Bukit Merah. 30th May was my first day at TradeHero. Ajay was the first one i met, he introduced me to Abert, Tho, Arup, Brendon and every one else. Julien, Dominic, Gary and Maddy were at the conference room when i came in.  After meeting every one, Julien and Maddy helped me to set up the dev environment.

The thing i like more about TradeHero is, they are a lot like Facebook. They have very high goals and they move very fast. It was my first day and by after noon, i was asked to design a permanent solution for the bug i found before i joined and i had to explain it on the White Board, which i duly did.  Arup had some questions on the security of the Algorithm which was answered by me and Dominic (The CTO) gave the go.

I was a lot less productive during my first week, thanks to my addiction to vi and nano, that was the first time i used a proper IDE on a windows platform after VB6. I got up to a very slow start, .aspx, C# everything were new to me. If you know me, you would have known that i was more of a C/C++/Python/php/Linux/Apache/AWS guy. But the dev environment at TradeHero was like, C#/asp.net/IIS/Windows Server/Azure, It was a sharp learning curve and i’m really happy about picking up a couple of languages over the summer.

A couple of weeks onto my internship, i was already peaking my all time commit levels, i reached my  longest 8 day streak and when people ask me how did my internship go, i show them this

That’s 31,527 lines of code and 62 commits, i think that qualifies my internship experience to be mentioned in some sort of superlative tense.

[really_simple_share button=”facebook_like”]

Advertisements

Sinking Indian Economy

The below post is a comment made by me on one of my friend’s Facebook wall in reply to why Indian economy is sinking and what could we do to arrest it.

People’s Mistake:
I would say, we are saving too much on Gold. According to BBC[1], Indian House wives have 11% of the total world’s gold reserve. You have to note this 11% does not comes under India’s Gold Reserve (which is owned by the Reserve Bank). Majority of this 120 billion$ worth gold is sitting useless either in bank lockers or in house holds. This money must be put into some useful investments, either by buying government bonds or investing in private equities.

How it affects[2]:
With this much Rupee Idling, we have created a demand for Rupee within India, The government cannot print more Rupee like what Zimbabwe did, so they had to borrow externally. Borrowing outside, increases our already high fiscal deficit (Fiscal Deficit = Exports – Imports, wherein India; Imports >> Exports). To add up to it, few people ask relatives returning from outside India to buy gold since it is comparatively cheaper outside, what they don’t realize is, it increases our Imports, thereby the Deficit as well.

Possible Aftermath:
If Fiscal Deficit Increases beyond a certain percentage of our GDP, then rating agencies will downgrade our already low rating to Junk[3], and then all these FDI investments will be pulled out just like that.

Falling Rupee is not bad always:
When Rupee gets devalued against dollar, it means foreigners can buy Indian goods for a cheaper price and this gives an edge for our exporters in the global market. So countries often devalue their currency to gain market [Japan Yen few months ago which led to a huge gain in Toyota’s sales [4]]. But clearly what we have now is not this.

Problems/Solutions:
* Corruption: Our politicians are so corrupt that, they get bribes from companies that wants to invest in our country. So, many mid-sized manufacturing companies which doesn’t has much lobbying power circumvents Investing in India [But now our FM is literally begging investors[5][6] to invest in India during major economy summits, but that’s a different story].

* Bad Start: We are more of a reactive country than a proactive one. Our economy was liberalized only in early 90’s. Thanks to Nehru and his BS (No Offence) Licence Raj[7], the policy makers then thought that, if they allow Foreign companies to setup bases/invest in India, then it will become the story of English East India Company again. Then in 1991, when we were close to default, we let the shores open[8]. Had we did this so early, we could have been more richer than the likes of Singapore and Malaysia.

* Quality of Products: Most of our high quality goods (from tirupur) are being exported to global co’s[9] (like H&M) and local manufacturers don’t give a damn about the quality. So we people start buying products from those global co’s who bought their raw materials in India.

* The so called Freebies: First of all, nothing is free. The TV, Grinder and all the crap you got are bought out of yours or someone’s hard earned tax money. The government could have used that money to a more useful purpose like to set up more of these restaurants or in some infrastructure projects, instead of bribing you to get your votes.

* Education: This is one of the important thing, there must be some sort of school for giving a crash course to Politicians or make them hire a bunch of goddamn MBAs for each and every Ministry.

[1] http://www.youtube.com/watch?v=IpdoRUMeshw
[2] http://articles.economictimes.indiatimes.com/2012-03-25/news/31234318_1_gold-imports-gold-demand-import-bill
[3] http://www.hindustantimes.com/business-news/WorldEconomy/S-amp-P-warns-India-of-rating-downgrade/Article1-1061685.aspx
[4] http://www.businessweek.com/articles/2013-04-25/japan-needs-more-than-a-devalued-yen
[5] http://timesofindia.indiatimes.com/business/india-business/Chidambaram-promises-fair-transparent-regime-for-foreign-investors/articleshow/21016727.cms
[6] http://www.moneycontrol.com/news/economy/chidambaram-arrivesus-to-pitch-for-investmentindia_914799.html
[7] http://en.wikipedia.org/wiki/Licence_Raj
[8] http://en.wikipedia.org/wiki/1991_India_economic_crisis
[9] http://articles.economictimes.indiatimes.com/2013-06-30/news/40286848_1_knitwear-exports-crore-worth-rs

What went wrong!

Welcome to my series of articles on Finance and Economy. I don’t know how i got my interest in Economics suddenly, but it gives a turing feel when you see something coming from a mile away.

The Sub-prime mortgage crisis and the Lehman Brothers Collapse:

The story beings with the low interest rate set by Federal Reserve of the USA. Due to the low interest rate (1%), investors who were buying treasure bonds were not making sizable profits and they have to think of alternative investment plans. On the other hand, low interest rates means, banks can get more credit from the Federal Reserve with a 1% interest, which is a super deal for them.

The usual way:

Families who want to buy a house contacts a mortgage broker, who in turn sets them up with a mortgage lender (usually a bank which got credit at 1% interest from the federal reserve). The family agrees for a down payment and the mortgage lender issues them a mortgage  monthly. In case the family failed to pay their mortgage, the bank can claim the house and sell it for a higher price, since the housing prices were rising.

Investment banks saw this as a good place to invest their investors money, and they thought it was risk free as housing prices were sky rocketing.   So, Investment banks like Lehman brothers and Goldman Sachs, contacts the Mortgage lender to buy mortgage contracts which the lender has issued. The investment bank buys a bunch of such mortgage contracts from many mortgage lenders. They pile up all the obtained mortgage contracts and classify them into three  (Safe, low and risk). The classified mortgage contracts are called as CDO (Credit Default Object). They sell this CD’s to their investors. So every one in the system were making good money and in case a CDO failed (if some one didn’t pay their mortgage), the investor can claim their house, sell it and still make profit.

The Greed:

The investors were very happy with their investment on CDOs, so now they want more such investments. But, how come?.  All the people who could afford a house, already have a house. So, to have profits, the mortgage lenders started offering mortgage for people who weren’t qualified, for people who didn’t had any proper job and lesser financial stability. This kind of mortgages are called as sub prime mortgages. Again the cycle continued, the Investment banks payed large cash to rating agencies to rate these risky subprime mortgage as AAA and BBB, so that they are can be sold easily. Every ones life was normal till the bubble  burst. Many subprime mortgages started to fail. Investors, claimed the houses and decided to sell them. This resulted in lots of houses in the market against the demand, which pushed the housing price down. Since now housing prices were falling down, people who were paying mortgages properly started to move out, because they are paying for a $300,000 house which now costs just $100,000.

The Aftermath:

Investors soon realized that CDOs are not safe option now, and they started saying no thanks for CDOs offered by investment banks. But the investment bank is already sitting on a stock file of horse shit CDOs and no one wants to buy it.  With almost no money to repay the credit they obtained from the federal reserve they started filing bankruptcy.

 

Cloud Computing with Amazon EC2

Cloud Computing with Amazon EC2

Audience criteria: This article is written for beginners in cloud computing so if you are a pro I would recommend you to skip this article

Cloud dem(y)istified

Wherever I go I hear people around me using the term cloud computing but their understanding of the concept is barely Minimum. Here is the popular youtube video which shows how much cloud computing is being misunderstood due to its catchy name.

An unorthodox definition to cloud computing would be “ The method of computing in which the physical machine which processes or gathers your data is present in the cloud. ” Cloud is nothing but The Internet

Note: The above mentioned definition is completely unorthodox and you’ll definitely not get 2 marks if you write this answer in Anna University examination.

Example for cloud computing:

Note: This is a very basic example, if you have a basic idea of cloud and its example i would recommend you to skip this paragraph.

Knowingly or unknowingly every one of us use one or the several features of cloud computing in a day-to-day routine, the best and simplest example for a cloud based service is Gmail. The service offered by Gmail is SaaS [ Software as a Service]. It means Gmail offers its software for people over the cloud. Now lets do a bit of substitution, what software does Gmail offer? A web based email client. What is a cloud? It’s the Internet. So after substituting the answers to these questions we get this “ Gmail offers its web based email client over the internet. “ All the emails in your account are physically stored in google’s data centers which is in the cloud aka hooked to the internet and you are accessing it from your computer via internet.

Why Cloud ?

I’ll walk you through this question using a case study. Lets take Anna University results publication as our example. http://results.annauniv.edu is the web server maintained by Anna University (Ramanujam Computing Center, i guess) for publishing its affiliated college’s semester examination results. Every one will experience the bottleneck effect at least for the first 6 hours  right after the results are published. Though Anna University hardly cares about this effect, lets presume Anna University as a more of student friendly university and it plans to do something about this bottleneck effect during results.

The Problem

   The problem here is too simple to identify, the HTTP requests from ferocious students eagerly expecting their results flood the TCP queue of the server (See DDoS). So a logical solution is to add a Load Balancer and widely distribute the requests to some 3 or 4 servers depending on the results [Some times 3rd to 7th semester results are published at same time, which will definitely need more than 2 servers to handle the load; one the other hand some times these results are published individually so 1 or 2 server would be enough to handle the requests at peak time.]

Solution A proposed by some leet Admin at Anna University:

Buy a Load Balancer                        –      Apprx cost $2000

Lower High-end Core i7 server with 6 Gigs RAM  X 4   –  900$ X 4 =  3600$

Power charges for these machines                –  xxx$

Consolidated cost  =    5600 $ + xxx$ per month + Network Maintenance charges + Server Upgrade Charges   ~ 7600$ per year

 

Solution B – The cloud way

2 * Rent a Extra Large Hi CPU on Demand Instance from Asia Pacific Zone for the first 24 hours  -0.76$ per hr

Change the Extra Large Instance to  Small on demand instance for the rest period –  $0.095 per hr

EBS storage  –  $0.1 per GB – month. At the max  our data won’t cross 10 GB mark so lets assume – $1/mo

Imagine EBS as a block of storage (HDD) attached to your instance

Load Balancer cost  – 0.025$/hr

Consolidated cost =   36.48$ + 68.4$/mo + $1/mo + 0.6$  = 37.08$ + 68.4$/mo

Results are published twice a year, so 2 days in a year we will be needing the 2 Extra Large instance with load balancer and for the remaining days a small instance is enough for handling the traffic.

For a year the cost will be =  2 * 37.08$ + 68.4$ * 12 = 74.16$ + 820.8$ =  894.96$

Solution B can serve the University 7 to 8 years with the cost spent on solution A

 

Pros on Solution B

  • Terrible cost cutting method
  •  Completely scalable architecture

“ Say if the university decides to publish the result for 3rd semester students alone separately then according to solution A we can’t save anything as the hardware is already up and running, but according to solution B we can opt for a Medium Hi CPU on Demand Instance or something more corresponding, we could add and remove memory just in few clicks or even we could automate the process using amazon’s api.”

  • Going Green.  ( I Don’t want to speak more about it in this post )

Cons on Solution B

  • Remember the Virginia Zone  Amazon Data Center’s Blackout, which pulled several famous sites along with it. So wise decision would be to host your instance in two different zones or at least have a mirrored EBS volume of your instance in some other zone for redundancy.

Multi-Threading

I’ve been learning ” Operating Systems and Systems Programming ” Online for a while. I use University of California, Berkley’s Online Webcast lectures and Operating Systems Design and Implementation by Andrew S.Tanenbaum as reading material.

I’m blogging here something which is a simple concept though, performs complex working.

Multithreading is a concept, which makes an illusion of  one or more threads running in parallel. To put up in a simple way, only one thread runs at a time, after a specific threshold time the 1st thread stops and 2nd thread continues running, again after the threshold time 2nd thread stops and 1st resumes running thereby creating a illusion of two threads running at same time.

I’m diving straight into the topic, as the basic concepts are out of scope to this article.

Here is an extract from Prof. John kubiatowicz slide

Consider two threads S and T. Consider S is running. A and B are the routines in each thread. After a specific threshold time or  some boundary value or why not, sometimes even after receiving a interrupt signal the running thread (Thread S) makes a yield call. The yield returns the control of execution to the kernel. The kernel checks for waiting threads i.e the threads in runnable state [sometimes based on priority] and makes a call to switch routine, The sweetest of all.

Switch routine accepts two inputs [current thread pointer and new thread pointer]. The basic functionality of switch looks like this.

Seems simple enough, Registers of current thread [Thread S] is saved to TCB[tCur].regs.rx and the values of new thread’s registers TCB[tNew].regs.rx is over written to the CPU registers CPU.rx. The overwritten registers include stack pointer and return address. After the switch performs its process the control is shifted back to the kernel and the kernel hands over the control to the routine whose address is stored in newly overwritten Instruction pointer. In our case thread T starts running. As instructed by Prof.john kubiatowicz, i had a look at the nachos source code for switch.

Switch.S is written in assembly. It has 4 subroutines [MIPS,SPARC,HP RISC,INTEL], each subroutine is called in specific to the CPU architecture. I’ll discuss here the INTEL’s subroutine alone.

/* void SWITCH( thread *t1, thread *t2 )
**
** on entry, stack looks like this:
**      8(esp)  ->              thread *t2
**      4(esp)  ->              thread *t1
**       (esp)  ->              return address
**
** we push the current eax on the stack so that we can use it as
** a pointer to t1, this decrements esp by 4, so when we use it
** to reference stuff on the stack, we add 4 to the offset.
*/
        .comm   _eax_save,4
        .globl  _SWITCH
_SWITCH:
        movl    %eax,_eax_save          # save the value of eax
        movl    4(%esp),%eax            # move pointer to t1 into eax
        movl    %ebx,_EBX(%eax)         # save registers
        movl    %ecx,_ECX(%eax)
        movl    %edx,_EDX(%eax)
        movl    %esi,_ESI(%eax)
        movl    %edi,_EDI(%eax)
        movl    %ebp,_EBP(%eax)
        movl    %esp,_ESP(%eax)         # save stack pointer
        movl    _eax_save,%ebx          # get the saved value of eax
        movl    %ebx,_EAX(%eax)         # store it
        movl    0(%esp),%ebx            # get return address from stack into ebx
        movl    %ebx,_PC(%eax)          # save it into the pc storage
        movl    8(%esp),%eax            # move pointer to t2 into eax
        movl    _EAX(%eax),%ebx         # get new value for eax into ebx
        movl    %ebx,_eax_save          # save it
        movl    _EBX(%eax),%ebx         # retore old registers
        movl    _ECX(%eax),%ecx
        movl    _EDX(%eax),%edx
        movl    _ESI(%eax),%esi
        movl    _EDI(%eax),%edi
        movl    _EBP(%eax),%ebp
        movl    _ESP(%eax),%esp         # restore stack pointer
        movl    _PC(%eax),%eax          # restore return address into eax
        movl    %eax,4(%esp)            # copy over the ret address on the stack
        movl    _eax_save,%eax
        ret

4(esp) points to thread S and 8(esp) points to thread T, thread S’s address is pulled to eax and all the registers viz ebx,ecx,edx etc are stored with respect to eax.   ex: register ecx gets stored to _ECX(%eax) . Then 8(esp) is loaded to eax, and all registers of thread T are loaded to cpu register. ex: register _ECX(%eax) is loaded to %ecx. The return address of each threads are saved and exchanged respectively.

ps: The diagrams were taken from Prof. John kubiatowicz‘s slides.

Plagiarism

Yes My work got plagiarized, Before going further i can blindly say that plagiarism is a global phenomenon but more often i find Indian people getting attached to it closely. Right from Ankit Fadia to some teen sitting in the dorm room copying articles by others and posting on his/her blog for gaining reputation among the masses.

We can attribute the boom of  Engineering education in Tamil Nadu to the mass plagiarism in the south. I, with the help of my friends had published a article on mass copyright infringement which happened in a technical symposium of a engineering college in Chennai. you can find the report here. The responsibility lies on the event organizer to cross check the received papers/articles for copyright infringement , however as  most of the  organizers themselves being a Asst.Prof doing Ph.D in Anna University who publishes plagiarized work for getting a Ph.D doesn’t bothers about plagiarism at the Under Graduate level. I wish to quote one of my friend’s comment on Anna university Ph.D’s

Ordinary persons like you and me will never be able to see the extra-ordinary intellectual capability of “THE” Anna Univ Phds 😛 U should be a Anna Univ Phd yourself to be able to recognize their immense contribution to research! 😛

Well said. OK enough rants, let me arrive at the point. The Research paper which my friend varun and i published at NIT-T [check out the computer science tab] and at packet storm got plagiarized by someone here. I’ve done a cross check and she seems to be 2o12 batch CS student from KLN college of Engineering, Madurai. I had just posted a comment on her blog.

Edit: The issue is resolved after having a conversation with that person

Peace 😀

Hosts File

HOSTS FILE:
Most of you users would have noticed the existence of Hosts file both in Linux(/etc/) and windows(/system32/drivers/etc/).The host file acts like a inbuilt local DNS to a computer.To say lucidly DNS is nothing but a server which maintains a list of IP address and their corresponding Domain names.Usually all ISP’s have their own DNS which could be checked by nslookup command.

DNS servers are categorized into primary,secondary and so on.if the primary dns doesn’t have the correspoding ip which u ask for,it contacts the secondary dns and the process goes on untill a match is found.Then all the DNS in the stores the result so that it could not query thse servers again.well these are beyond hte scope of the article.

The host file in windows is extenstion less it could be edited by any text editor indiscriminate of privilages(XP and below).but in linux root access is required to edit the host file.

A host file in windows looks something like this
Code:
# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

127.0.0.1 localhost
::1 localhost
How could hosts file be used?

1.Giving domain names for intranet servers.

For example in colleges and schools intranet servers could be given domain names by editing the hosts file of each machine connected to the lan or by configuring all the systems to use a proxy server and changing the hosts file entry of that server alone will do the work for us.
Code:
127.0.0.1 localhost
::1 localhost
132.147.170.201 http://www.pec-library.com

2.Website blocking.
It could be used by administrators to block any website by redirecting it to 127.0.0.1
it could be also used to block some adservers.some adblocking softwares work under this principle

3.Crackers.
Intruders could change the hostsfile of any compromised system and redirect them to any malware sites or to any
pr0n sites just for fun..
Code:
127.0.0.1 localhost
::1 localhost
87.123.134.55 http://www.google.com
some antivirus softwares like kaspersky alerts the user that the host file is going to be changed…

And this is the end of this article..Comments and suggestions are welcomed.

Linux vs Windows

I hope most of you might heard of LINUX,Its nothing but a fantastic Open Source Operating System which could run on low resources (low end hardware) and could deliver a performance par better than windoz..The most important feature of Linux is it is very much secure than windowz, 95% of the Computer Viruses in the world made are either .exe or .vbs files targeting windoz users. These virus programs could not be able to run on linux….

I knew a guy who reinstalls his windows XP atleast 20 times a year due to frequent virus infections (i suppose if we ask him what is his hobby he’ll say “installing windows” LOL )

Thats enough for describing the security feature of Linux,…Linux is very much good for budding software developers,being a open source operating system they could view the source code of entire operating system and they could learn from it & modify it too….

Nothing is easy till we get practiced,If we had thought using a computer is difficult you wouldn’t be reading this and i wouln’t  posted this info, “Practice is the best teacher”..

I would recommend new users to install linux especially ubuntu on a Virtual machine and play with it a little….

I’ll post a tutorial on how to set it up soon…..   🙂

This article is in nomeans to derogate windows, windows  finds its advantages in many places in many ways.

Who a Hacker is ?

The term hacker really doesnt means the person who intrudes into your computers, cause panic across the world etc etc, Those persons are called as crackers….A hacker is a person who is a expert in his field,Expert in the sense means that he could create new things he could find the weakness in his newly created things and he could be able to modify those things….

Various movies like Hackers,Wargames etc portrayed hackers as criminals who intrude into goverment networks.The stereotypical image of a computer hacker, as portrayed by the media, is one of a shadowy figure, alone at a computer, stealing secrets and money.,This causes panic among the people…

By using words like h4x0r 1337 one could not become a hacker,one could develop his hacking skills by having a deep knowledge of the subject..There are many forums on the internet providing Dumbass tools like Password Finder PRO V 1.0.0.2 [lol] and load your computer with malware shit…There are some people using these pre-made tools,RAT’s etc to get into others computer without knowing how it works/what the damn thing they had performed,These persons are called as Script Kiddies. On the otherside there are some forums on the internet which  teaches some ethics to you and converts even a dumb script kiddie into a knowledgable person.One among them i would refer is http://www.haktstudios.com