Codes from my life

I came across this a few days back when my colleague showed me this. I was really fascinated with the patterns it was generating.

So after coming from office I sat down to write it finally. Read this(http://en.wikipedia.org/wiki/Conway’s_Game_of_Life) so that you can understand it properly. Then see the demo here: http://roshansingh.in/code/gameoflife/

Keep clicking the random button, you may get to see some wonderful patterns :)

Find the code here: https://github.com/roshansingh/gameoflife

 

 

Interesting bits

I have added a page to my blog where I will post interesting problems that I come across on my blog.

Check it out: http://roshansingh.in/blog/interesting-bits/

On recommendation of a colleague,  I watched this movie ‘The man from earth‘ yesterday.

The movie is based on a conversation between some people. The protagonist, John Oldman(who is a professor), was packing stuff to move on to a new place, when suddenly some of his colleagues from the university dropped by to say good bye. They were curious about where and why John was leaving all of a sudden. Then finally John opened up and said that he was a caveman and he had lived for 14000 years. And he moves to a new place every 10 years as people around him see that he does not age.

Curious? Go and watch the movie. Its really a brilliant piece. It has been rated 8.0 on IMDB. I was so amazed by the movie that I watched it twice back to back. The Story is written by Jerome Bixby who has also written few episodes of Star Trek.

The conversation is so captivating that you wont move at all. If you enjoy science fiction you will love it. I would rate it a perfect 10/10.

I recently changed my router’s password and even changed the authentication type. Now after that Network Manager started crashing. And thanks to the new GNOME 3 network manager, I was not able to manually change the password, I was not even getting where they had hidden the previous Network Connections window which used to list all the interfaces.

After googling for a while I found the command.

$ nm-connection-editor

Cheers!

I installed cygwin on windows today. Its really incredible, gives the same feeling of a linux terminal on windows, though you may need a little tweaking.

  • I have installed an additional shell called mintty which gives a putty like interface, as in the default terminal you cant copy/paste things.
  • You will need to create a shortcut for mintty to make it usable.
  • But when I started vim in mintty, arrow keys were not working and backspace also behaved weirdly in insert mode, reason being cygwin does not create .vimrc by default. Execute this to fix this issue

cp  /usr/share/vim/vimXX/vimrc_example.vim .vimrc

  • Also by default mintty, will land you to /usr/bin, but you will want to land up at your home i think ;) . So change the link to target this

C:\cygwin\bin\mintty.exe c:\cygwin\bin\bash --login -i

  • ssh will piss you off I dont know why, ssh host does not work by default. How ever /bin/ssh host works as expected. So you might want to set an alias.

With these little tweaks I find cygwin usable now. I recommend using mintty as the default shell las very basic features.

Enjoy the power of linux shell on windows!

Update:

  • clear command is absent by default in cygwin, you may install the ncurses package or just hit Ctrl+L if you use bash.

Few days back when I was writing some PHP, I found out that

 header( 'location: xyz.php' );

was not working on my hosting. The problem was headers were being sent by the server before processing the entire php. So I added this function at the top of the php file to buffer the output stream,

ob_start();

and the below function at the bottom of the php file to flush the buffer.

ob_end_flush();

This solved my problem.

After a long time, today I finished packaging the newer versions of artha and gscribble for Fedora. The updates have been pushed to update-testing.

The new versions will be available in the updates repositories soon.

Posted from GScribble.

Nonameconf [Day 1]

I had missed FOSS.in again due to some reasons, so I had planned to go to Nonameconf. I went with vignesh. While I was trying to find the building where it was supposed to be, I saw a bike tripping over. I had never seen an accident like this before. I immediately rushed towards them, had no clues what to do. I helped the person get up. The pillion rider was hurt, he was not able to stand also. Some people came with water to help them. After a while I left.

I will still clueless about the venue. I called up Vignesh, he said that he would come in a while. Then we tried to find the venue. Finally when we reached the venue. I saw a very small Nonameconf sticker pasted, I must say this was a very poor arrangement. The venue also was not proper for a meeting like this, but I do not think blame them as it was a free of charge event with no sponsors.

Later I noticed that they had no clear idea as what was to be done. I met with a lot of people there, some coders, others FOSS activist of FSMK. Shreyank had arrived by then, I met him for the first time since he left college. Later I found that there were some entrepreneurs also there mostly startups. Now some person had come up with a website (i forgot the name of the person and the url as well), which would serve as a meet up point for freelancers and startups. Nice idea indeed, but the question was will he be able to sustain the idea, I am rather unsure about this. But the discussion was nice indeed, what startups needed and what freelancers/interns need.

Then we went to CCD to grab some coffee. Then we walked from there to UB City mall. The mall was nice, we were having random discussion on what we need in life and how we should do. After a while Shreyank proposed to write a small app that would pull the latest image from xkcd feeds and save it as desktop background. He took out his laptop to see if there was wifi available. To my amazement it was! There was some paid network available which would charge 50 bucks for 60 mb. He tried to registered but failed. Then we went to S.P. Road, Viggy had to buy adapter for his router. Finally after roaming a lot, I came back.

It was refreshing to meet them. Since I had moved in to Bangalore I have been living with people who do not like coding at all. Every time I would go out with them, they would discuss on cricket, football, politics and so on, none of which interest me. For the first time, I felt like I should start doing something again :) . Hope I can sustain this energy.

Posted from GScribble.

Stack Vs Heap

Some very good discussion here on stack vs heap. Read it entirely. Though it sounds theoretical they are very important when you get to real world problem solving
http://stackoverflow.com/questions/79923/what-and-where-are-the-stack-and-heap

And some more over here for stack overflow: http://stackoverflow.com/questions/26158/how-does-a-stack-overflow-occur-and-how-do-you-prevent-it

Mutex Vs Semaphore

The title seemed to bug me a lot, until today when i found a really good explanation. If you google for the difference between Mutex and Semaphore you will see in most of the places it is mentioned that mutex is a binary semaphore.

But mutex is not actually a binary semaphore.

See these links to understand the difference:
1. http://blog.feabhas.com/2009/09/mutex-vs-semaphores-%e2%80%93-part-1-semaphores/
2. http://blog.feabhas.com/2009/09/mutex-vs-semaphores-%e2%80%93-part-2-the-mutex/
3. http://blog.feabhas.com/2009/10/mutex-vs-semaphores-%e2%80%93-part-3-final-part-mutual-exclusion-problems/