Showing posts with label Articles. Show all posts
Showing posts with label Articles. Show all posts

Monday, June 14, 2010

Malware: The Positive Aspect

Consider a life - Rules decided by the authority, People following them, Vigilant Guards at work 24X7... Too good a life to live. The future of such world -
Fools, crippled generation being born - quickly followed from law of Use and Disuse of the organ by Lamarck:
"In every animal which has not passed the limit of its development, a more frequent and continuous use of any organ gradually strengthens, develops and enlarges that organ, and gives it a power proportional to the length of time it has been so used; while the permanent disuse of any organ imperceptibly weakens and deteriorates it, and progressively diminishes its functional capacity, until it finally disappears".[source: Wikipedia-http://en.wikipedia.org/wiki/Jean-Baptiste_Lamarck]

Now consider our life - Struggle for existence onfile as well online, thanks to corrupt security government officials and ever enthusiastic and sharp hackers, Rules decided by the authority along with a backdoor!, People follow them as per convinience, Vigilant guards causing inconvinience...
Future - Evolved humans take birth, world civilises, OPtimisation of survival factor!!!

Clearly, the above pure world which is very nicely planned, a perfect dream world - is only fit for a dream as it is stagnant and therefore has almost negligible information and 0 entropy. Our world, on the other hand, may seem too messy, too problematic and disturbing but it is the one which is vivid, lively and bound to improve in existence level as there is always a scope of refinement to the current status. This is analogous to the river water, which keeps flowing indefinitely. It gets polluted on the way but it is pure where it emerged first and when it finally merged in the sea! The journey is its life and disturbance on the way is the spice of its otherwise monotonous flow...

Similar to this is our security professionals vs. Hackers game. The game is on only until hackers find another way to circumvent the current policies or find some vulnerability to exploit in the current setup. The malwares, worms, virus etc. may seem a nuisance on face but they are the driving force for all this security hype. Mind it the security professionals have a job only until hackers are interested in playing ;)
Therefore its a sort of win-win game. The security professionals are on a constant hunt for a best fit policy, secure software and the hackers are in constant search of vulnerability in the software and the trapdoor in the policy. You remove one cog the wheel stops and the future which we were imagining to be a storehouse of opportunities suddenly ceases to exist! All this malicious stuff is therefore the spice of a security profs food and the vulnerability in the operational system are the driving force for the hacker. Mind it a challenge interests only when it is difficult to crack.

With the limited knowledge i have of the field, I am fascinated by the way these people circumvent the rules and the policies to bring down the weak and vulnerable system and work constantly for improving it!

Sunday, April 11, 2010

Structure of Implementation (original One)

STRUCTURE OF IMPLEMENTATION:
I drew it as an ASCII figure in the proposal and something unusual happened with the whitespaces, thus the figure became a mess. Please use this one for further reference.

Tuesday, April 6, 2010

Implementation of lamport's clock in Python

Here goes the lamport.py------

p = dict()
event = dict()
def clock():
    """local clock update"""
    procsno = int(raw_input("enter the no. of processes.\n"))
    for i in range(procsno):
        print "enter the events in process",
        eventno = int(raw_input(i))
        event[i] = eventno
        for j in range(event[i]):
            p[i,j] = j+1
            print i,j,p[i,j]
    mes = int(raw_input("please enter the no. of messages sent"))
    for i in range(mes):
        psen = int(raw_input("sender process"))
        esen = int(raw_input("sender event"))
        prec = int(raw_input("receiver process"))
        erec = int(raw_input("receiver event"))
        p[prec,erec] = lamportclock(psen,esen,prec,erec)
    for i in range(procsno):
        for j in range(event[i]):
            print i,j,p[i,j]

def lamportclock(si,sj,ri,rj):
    """global clock update by message passing"""
    q = p[si,sj]+1
    if q>p[ri,rj]:
        return q
    else:
        return p[ri,rj]

All reviews and errors and bugs report are solicited. I would be very happy to know if it helps you in your struggle with C implementation!
This one is really bad in the output view, though the internals is OK.
A better will be posted if I did work on it :P

Tuesday, March 23, 2010

FOR DIE HARD UNIX AND C FANS

Most of the people who use UNIX instead of Windows, consider themselves to be smarter computer professionals and learned programmers. Not all, but some always keep an air of superiority around themselves...
But all this will fade off once you read this speech which the developer of UNIX- brian and Ken Thompson gave after the release of their OS. Here it is as extracted from the book UNIX HATERS' BOOK.

In an announcement that has stunned the computer industry, Ken Thompson, Dennis Ritchie, and Brian Kernighan admitted that the Unix operating system and C programming language created by them is an elaborate April Fools prank kept alive for more than 20 years. Speaking at the recent Unix World Software Development Forum, Thompson revealed the following:
   “In 1969, AT&T had just terminated their work with the GE/AT&T
   Multics project. Brian and I had just started working with an early
   release of Pascal from Professor Nichlaus Wirth’s ETH labs in Swit-
   zerland, and we were impressed with its elegant simplicity and
   power. Dennis had just finished reading Bored of the Rings, a hilari-
   ous National Lampoon parody of the great Tolkien Lord of the Rings
   trilogy. As a lark, we decided to do parodies of the Multics environ-
   ment and Pascal. Dennis and I were responsible for the operating
   environment. We looked at Multics and designed the new system to
   be as complex and cryptic as possible to maximize casual users’ frus-
   tration levels, calling it Unix as a parody of Multics, as well as other
   more risque allusions.
   “Then Dennis and Brian worked on a truly warped version of Pascal,
   called “A.” When we found others were actually trying to create real
   programs with A, we quickly added additional cryptic features and
   evolved into B, BCPL, and finally C. We stopped when we got a clean compile
   on the following syntax:
                      for(;P("\n"),R=;P("|"))for(e=C;e=P("_"+(*u++/
                      8)%2))P("|"+(*u/4)%2);
“To think that modern programmers would try to use a language that
  allowed such a statement was beyond our comprehension! We actually thought
  of selling this to the Soviets to set their computer science progress back 20 or
  more years. Imagine our surprise when AT&T and other U.S. corporations
  actually began trying to use Unix and C! It has taken them 20 years to develop
  enough expertise to generate even marginally useful applications using this
  1960s technological parody, but we are impressed with the tenacity (if not
  common sense) of the general Unix and C programmer. In any event, Brian,
  Dennis, and I have been working exclusively in Lisp on the Apple Macintosh for
  the past few years and feel really guilty about the chaos, confusion, and truly
  bad programming that has resulted from our silly prank so long ago.”

After having read this I was Laughing out Loud and Rolling on my stomach. Its true a genius can make a fool of the world!! Every bit of computers 0 or 1 seems ephemeral now. It was an enlightening event......

DISCLAIMER: This extract has been taken from the book only for entertainment and sharing purpose. Anybody wanting to cite it for his/her book or any other purpose must follow the norms of copyright law and seek permission from the authors of the book. 

Sunday, March 21, 2010

God Knows What?

Openoffice.org is not properly synchronised with blogger.blogspot.com.
Know what it sucks when you post some article you wrote during your offline moments in openoffice.org. What will you do? Copy from the org file and paste on blogger. But this won't do as every time you copy paste it will add some meta tag which will irritate you and the things will become incorrigible. Today I suffered hard posting an article I had written a long time. But I carried out patiently and completed the pasting and was formatting it when something wrong happened and I did ctrl+z.
Guess what the complete article disappeared from the template.................
I was blank, furious..... and the devil saved it quickly to the drafts as well no way to recover....
Again the same the process should be repeated now to post the article....
In the mean time this frustration note!!!!!!!!

Beginner's Python Tutorial-- Plot graphs using MATPLOTLIB

I attended a Python Workshop sometime back at IITK during Fosskriti organized by a dedicated faction called FOSSEE. Here I'll share some of the knowledge I gained in a series of three posts. Below is the first one in the series.
GETTING STARTED WITH PYTHON
lets hissssssssssss.......
Guide to install Ipython-Interactive Python shell.(on a linux machine)
1. Install ipython- interactive python shell
   sudo apt-get install ipython
2. Install matplotlib and the support libraries for it:
   sudo apt-get install python-matplotlib python-numpy python-scipy
3. Type now on your terminal
   ipython -pylab
4. You should be able to see the ipython shell started. Don't worry about the warnings. Just look out for In[1]: This is your prompt where you need to enter the commands. You should be able to see a window like this:
Now you are ready to talk and plot in python.
1. Lets say hello to the world first(convention)
      type: print "Hello,World"
   output: Hello, World
Note: Python breaks the semicolon convention prevalent in most programming languages. It can read the return character to know where the line ended, so be careful when you press enter, as a new line means a new line of action for python.

2. Lets plot a curve now:
Matplotlib is a toolkit of choice for most of the python programmers not only because of the publication quality graphs but also because of the extensive library and documentation.  It gives a tough competition to the one commercial tool in this scientific plot area- Matlab!
Matlab users are going to find this very similar. But then Y Python? Simple- Python is open source programming language and Matlab is a propertiery commercial tool. Rest has more to do with ur choice and comfortability ;)
Here's a small HOW TO PLOT GRAPHS IN PYTHON(Matplotlib based):
   a) We define the values of x for which we plot f(x) on the graph using
       linspace(start, stop, step)
        x = linspace(0, 2*pi, 50)
   b) Now command it to plot the curve you want using plot(x, f(x))
        plot(x, sin(x))
   c) You can set the labels using xlabel and ylabel and title.
   d) You can display the legend of the graph using
    legend('sin(x)', loc=center).
   e) Annotate the point on the plot typing  
    annotate('local max' , xy=(1.5,1)).
   f) Save your first plot or figure using savefig('sinusoidal.png').
       Note: You may choose extensions of your choice.
   g) Close the figure typing close() or the current plot area typing clf().

Note: You can explore more about these commands by typing linspace? on the shell to view its help. And you can thus learn about various colors and forms in which you can plot a graph by typing plot? or help(plot) on the shell..

For your reference a complete script that u can straight away peruse by copying and saving in your home folder with .py extension is:

x = linspace(-2*pi,2*pi,100)
y = sin(x)
plot(x,y,'g',linewidth=2)
z = cos(x)
plot(x,z,'r',linewidth=2)     #Plotting red line graph of double thickness
c=0*x
plot(x,c,linewidth=2)
z=sin(x+pi)
plot(x,z,'p',linewidth=2)
z=cos(x+pi)
plot(x,z,'p',linewidth=2)
annotate('origin',xy=(0,0))
legend(['sin(x)','cos(x)'],loc='best')
xlabel('x')
ylabel('f(x)')
title('waves')
savefig('waves.png')
show()

You'll see an output something like this:


3) Plot using lists like:
      a) x = [1,2,3,4]   #creating a list
   b) y = [7,11,15,19]
   c) plot(x,y,'r')     #Plotting a red line graph
   d) plot(x,y,'o')    #Plotting coordinates
You will view the following curve:

Exploring the magic commands of Ipython shell--
How to save the commands u've entered so far:

1. Use %hist (history) command of ipython.
2. Select the command no. u want to save.
3. Save using %save of ipython. For instance:

In[]: %hist
In[]: %save first.py 3-15            # use no.s as stated on the terminal.

4. Running the script saved or general python scripts, use %run -i

In[]: %run -i first.py

How to exit the Ipython shell
1. Type ctrl+D
2. It will prompt a question asking-"Do you really want to quit? [y]/[n]"
3. Enter 'y' if you want to quit.

Links you may like:

To those interested in plotting dynamic graphs on their web-pages using python the following link would be of interest:

other related links:

one particular link of interest for those who want to explore the wide choice of plotting toolkits:



session 2
(will follow soon)

Wednesday, February 24, 2010

Human Behaviour


All of us have met the two people who are the boundary elements of all humanity. The ones on the top, who we all admire; and the ones on the bottom, who we all despise. The one thing, apart from from the striking dissimilarity, they have in common, is INTEGRITY.
The ones at the very bottom the place where you might not be able to locate them even at an angle of depression equal to 90 degree..., are very high up on the moral ladder than most of us are! They value their values more than the pleasures of living, which on the face value seem satisfactory. These pleasures fool most of us. But these souls are never chasing the ephemeral honey, lust has to offer us..., which shakes the very floor on which our world stands!
These people compromise on these time-bound-happinesses in quest of their place in these world. Only a room, where they can have fun with themselves and their values over a cup of coffee! These people get mocking remarks in return of their nonchalance...
On just the other end of the line lie their counterparts, truly speaking the ones who have trodden the
path these so called burden on this earth or foolish people are walking on, long back. These are the people whom we adulate. We watch their interviews, follow their life-styles, mug up their quotations (only to reciprocate at some public gathering), paste them on our walls, buy out their autographs (to auction them) and what not...., try to pose to be them just by wearing their pants and forgetting to remove them before the very obvious, using the toilet :D
And now just look out how the TRP's of the news channels increase for the coming days with Sachin having given them the cow which sells not only its milk but also its skin.Without any actual logic the channels will correlate the stats and the numerology and the stars of Sachin with his double century and people will finally end up believing that it were just for stars and numbers he scored a double century else this is the same Sachin who's out many a times at 0. :D

 

Friday, February 19, 2010

HOCKEY WORLD CUP

HEY! People do you know the hockey world cup is being played in INDIA on 28 feb 2010....
and our public media which claims to be a highly unbiased in its coverage but just look guys! has anyone of us read any news about the Hockey World Cup... 
How come such a great event has missed the eagle eye view of the media.. The media which runs after the news and many a times create some of these, that too sensationalizing them to hyper extent has missed this event of national importance........
come people lets together promote this event by sending messages, writing blog, tweeting and buzzing!!!!!!!
Now we have the power of the media and are not dependent on these already sold out people......

Wednesday, February 3, 2010

Viral Song

Once in our life we all hear songs we particularly hate. We would have never agreed to hear these even in return of a lot of goodies. Its not because we don't have taste, rather its the exact opposite. Put the other way-If u have never despised a song in your lifetime; u surely don't have a taste....[:P]
If u have heard such a song then u must have also had a feeling to just tear off the thing thats playing it. Just peel off a cello tape and stick it onto the mouth of the singer, or kill the composer rather the recorder or more precisely the distributor. I, in fact, think where have those activists disappeared, why are they not opposing this song, why don't they launch a campaign against it and ban the playing of this song??
But then amidst all this turmoil something happens and I start finding a wall or a cello tape for myself, hang myself upside down.....Because leave apart the player I am now singing it...(oh!) It is played and replayed in me.. Almost congesting all thoughts and denying service to all thoughts which try to curb the playing of the song(DOS attack)... I am under the attack of the most malicious music!! A viral song has got into me and is now reproducing at its highest rate... Never felt like this? Hear this one then-
An example

Monday, February 1, 2010

When did future switch from being a promise to a threat?

When in the present of 2006, I got a gift wrap of “NOT SELECTED” JEE score card, my future switched to being a threat from promise. Until then future for me was a bright, glossy promisory note, but not anymore; as now the promise bearers had disowned it.

Since childhood I had studied hard, always stood first in class, as it was believed to be a practice with highest ROI.
Take coaching, study hard and smart, 36 hrs in a day of 24, get into IIT and live a life beyond imagination........
So we invested in money, year (after 12th) and faith in the bubble called IIT-JEE. But the bubble had gone bust and now I was facing The Great Depression of 1931 in 2006.

This depression unlike the true economic one started recovering soon, as I managed to secure admission in HBTI(considered next to IIT Kanpur, it actually is ;) and one among the top 50 engineering colleges of India). Soon after being admitted, bound by Schumpeter's economic cycle my future boomed, as again I secured a very promising percentage in first semester. So,
B.Tech in Hons., job in an MNC, great package.......
Again the bubble started building but this time I didn't blow air in to this bubble, I stayed away from it. “This bubble could not fool me again”, I said to myself.

Now when by the end of 2008, once again the economic carriages went out of control, into the slump under the gravity of greed and mismanaged decisions of the investors, disturbing the equilibrium of the economic forces of supply and demand, in short the bubble went bust again; I sit peacefully in my room, unperturbed......
This doen't mean I am mean or indifferent towards the world or any hermit etc. I am no anomaly to the current structure.

Through the past experience I have learned that this future is analogous to the 'stories of sheikhchilli' we heard in our childhood. In these stories he never bought any milk but did manage a flood of tears for spilling it.
Thanks to Chuck Palahnuik, to present this question before the world, which transformed it into a million dollar question but forgot his real billion dollar quote-

“ We are not special. We are not crap or trash either, we just are. We just are and what happens just happens!! ”

So, we must stop speculating on the promises or the threats of the future and start excelling in the tasks in hand, as it is rightly said- “A bird in hand is worth two in the bush.”

Sunday, January 31, 2010

Philosophy of Life Klotski style!


Yesterday night I was playing snowdrop of klotski. A thought struck me today morning while I was rising up from the bed. Life is similar to klotski as it doesnot allows for any undo or redo move, you go on just playing. there is a striking similarity between our life and klotski, look at this:

1. One game, until u alt+F4/ctrl+R, is a life.
2. F1 is your teacher, similar to the real life teacher.. boring theory ;)
3. Each stage is a stage in life, getting difficult ever..
4. In "only 18 steps" you are an adult, irrespective of the fact that you actually have grown- mentally ;)
5. You are offered three ways to play(live) klotski(life) viz, stick to play until you win(live life) or ctrl+R(consult doctor and start afresh, costly decision) or alt+F4(commit suicide).

there are generally no explicit constraint on the no. of moves in later stages, so u can play at ur ease and peace of mind. what happened yde was while playing that I went on playing for long and every now and then after certain moves I would feel I was about to crack, but no.... again I was stuck.. there were 3 choices- stick, ctrl+R, alt+F4. I stuck. This stage I had cleared in 67 moves a week back, how was it that this won't clear now? I was determined to do it, however long it took... so, with 132 moves I finally cleared it. I was now promoted to red donkey stage. This is just like the life, one who never quits is regularly presented with a new challenge. With each challenge he gets all the more stronger and wiser.

At all point in klotski you can reach back to the point where you started, you are never die or finish your energy, unlike other games. You don't have to fight others in klotski, only let loose your mind horses and stray in the field with blue chocolates of various sizes and orientation, controlling the temptation to eat them :P Don't worry about your neighbor and don't quit.. you'll always find new ways to bring the green block out...

To Be or Not To Be!



God is just one letter short of good.That too a zero if you see... When the creator is good then how can the creation ever be bad? Just hold on to the faith intensely and patiently,... without waiting for the result and you will sure find the thing you were looking for... I have seen very deep rooted firm believers and mark it- its really easy to choose a path and walk on it if only, you don't think twice or reflect upon its utility or why you chose it or is it good for you and blah blah...... If you just do and keep on doing ways open themselves! They may look as unknown though, but mind it, they are not unknown to your true self. They are just there, waiting for you.
In your heart, deep within, you know you too are aspiring for them but you don't know whether the road you choose will lead you there. But my dear! thousands of rivers converge in a sea and all seas are one; though may have different names. Similarly all paths converge! to one supreme place; though may look different on surface. Don't think after choosing as once. You've chosen. The time to think has gone. Its time to act now and when while choosing you never acted then after choosing? You shouldn't think friend! ACT!!!
Time comes and it goes never repeats; so never repent on a decision made or think twice on a path sought cause when after you'll reach ahead you will start realizing that this was only the one you were looking for. A river was never taught the road it should take or the path, which would be best for it and the river never looked on the path rather enjoyed the path it took and instead of taking something from the path it gifted it-- "GIFT OF NILE".
When Ganges may have emerged from the Gangotri it might have asked various rocks and plains to give it the path but they all being silent could not answer to her and thus she decided to turn silent herself too; and flow, rather than talk to anyone on her way to the ocean. She took the way herself, through the northern region leaving behind Rajasthan and Maharashtra and did not reflect back on the decision- 'Whether it would lead to the Bay of Bengal or the Arabian Sea?' Not once out of any confusion or perturbation did she change her course... Just rolled ahead with all her might. On her way she established plains and coasts and most fertile regions of the country and we know she did meet her destination. Though the optimal or the best path, in our language of computers, may have been to the Arabian Sea. Quick and Short...
So don't think after you choose and don't take long to choose... ;) Play it time bound when you have the most energy during the UPPER COURSE just flow; and when in the MIDDLE COURSE you start settling, remember your goal; by the time you reach the LOWER COURSE you will have gained so much that who ever comes in your way will get enriched. Just as a DELTA gets best of the sediments. You will sure, reach your destiny.
Life, Dear! is not a race and you have no competitors... Its a one man's play. His quest. Its not about where you reach, but about the way you took to reach and how enriched you are by the lower course! Remember hold on fast and strong to just one faith; in that matter, it can be anything but as experienced, God is the easiest and safest but difficult at times, as he silently takes all the blame on himself and never preaches you about himself; so its easy to get lost! Move ahead. Don't compare and contrast. Don't try to store huge data in your small brains and do data mining operations of, studying associations and correlations. These operations are very expensive both in space and time ;)(remember, some polynomial time complexity for just the database of the size of gbs). Your memory which stores a lot of data and has limited computation power as compared to supercomputers, computer theorists say, these operations themselves will take many lifetimes...

Walk buddy! The road is waiting for you to traverse.. It had been there, since you were born and has been preparing itself to get your warmth...

Saturday, January 30, 2010

Blind Spot in Human Eye!

The blind spot, in the eye explains why many a times though an object is in front of our eyes but invisible.

Just as this spot may go unnoticed by most of the rays that fall on our eye; it is correct that a ray which falls on this spot goes unnoticed too...... thereby explaining the fact our look of the world is biased and skewed!!!
Every one of us is blind, some to complete others to limited extent, depending on the size of this blind spot...