Monday, February 20, 2006

Reverse Engineering

Long time no post!
Well, check out the article at Newsletter for a Reverse Engineering challenge. The answer is given on the site, but Ill try to crack it on my own, once I get back to Bombay. Ill post my solution here when and if I manage to do it.
Here is the link for the newsletter. See the "Code Challenge: CRACKME Application" on page 25.
If anyone reading is interested and can crack it, post your solution in the comments.

Sunday, October 09, 2005

Bout Google!

This is part of a conversation Thite and I were having bout Google.

Swapneel - If you want to work in a big company, learn how to hack Blub on Windows - says:
did u hear the news bout google goin to provide free wireless connectivity in san francisco?

Swapneel says:
pretty neat

Swapneel says:
beautiful example of wat joel spolsky was sayin in his microeconomics article

§ Hrishikesh | Whoa! says:

§ Hrishikesh says:
and there's more

§ Hrishikesh says:
Google is buying fibre

§ Hrishikesh says:
loads of it

§ Hrishikesh says:
maybe they are making an alternate internet

§ Hrishikesh says:
one with better standards

Swapneel says:

Swapneel says:
waddya mean an alt internet?

§ Hrishikesh says:
a network independent of the current internet

Swapneel says:

§ Hrishikesh says:
to allow for extremely insane speeds

Swapneel says:
they wanna replace the current standards?

§ Hrishikesh says:
mostly for ur multimedia apps

Swapneel says:
very ambitious...doubtful whether itll succeed

Swapneel says:
hope it does

§ Hrishikesh says:
live vid streams n stuff

§ Hrishikesh says:
it'll prolly b free too

Swapneel says:

Swapneel says:

Swapneel says:
but i guess itll take easily 5-10 years at minimum, for it to become common like wat we have internet today

Swapneel says:
did u hear bout the google-sun alliance?

§ Hrishikesh says:
think so, u mite as well remind

Swapneel says:
lets c how MS responds

Swapneel says:
basically, they're gonna promote each other...

Swapneel says:
google will promote openoffice....ppl who dload jdk, will have an option of dloadin google deskbar, etc

§ Hrishikesh says:
I don't really like SUN

Swapneel says:
“Initially, the agreement will involve Sun giving those downloading its Star Office and Open Office word processing, database and spreadsheet software the option of downloading the Google search toolbar as well.
In the long term, however, I'm sure it will be the other way round - Google becoming the primary distribution network for Sun's desktop applications, with Java at the centre of it all.”

Swapneel says:
y not?

§ Hrishikesh says:
dunno, jlt

§ Hrishikesh says:
it has a hidden propoganda

§ Hrishikesh says:
something in it does not feel good

Swapneel says:
bout the hidden propaganda...who doesnt? google? ms? cisco?

Swapneel says:
but yea...i think ur opinion is based a lot due to java

Swapneel says:
i agree with java sucking big time....when compared to ruby, py, lisp, etc...

§ Hrishikesh says:
right now, google hasn't done nething to fuck itself, or da industry

Swapneel says:
but the fact remains, for average ppl, java rules

§ Hrishikesh says:
actually it does not matter

Swapneel says:
fucking urself and hidden propaganda is diff na? or u tryin to mean something else?

§ Hrishikesh says:
da problem with hidden propagandas is that eventually, u fuck and get fucked

§ Hrishikesh says:
unless ur M$

§ Hrishikesh says:
cause dey are desensitised

Swapneel says:
lol...neutered u mean

Swapneel says:

§ Hrishikesh says:
euphematically speaking, yea

Swapneel says:
but its classical game theory....imagine how huge ibm wouldve been, if they werent stupid enuff and bill gates wasnt smart enuff with the DOS deal

Swapneel says:
someone's gotta lose out

Lemme know what u guys think. Comments are welcome.

PS: Joel Spolsky's article on MicroEconomics is a MUST READ.

Tuesday, August 23, 2005

A Sample Ruby Code

A few people were asking for a sample Ruby code, so here goes!

First the history - my Babylon Time Trial expired and I was looking for a good alternative with my GRE coming up. So I thought, why not code it in Ruby? So basically what my code does is, it queries the Google Search engine, uses the 'define' keyword and retrieves the page containing the definitions of the word entered at the command line. After retrieving, I use some Regular Expressions (here's where Ruby makes life sooo easy!!) to parse the page and remove the unnecessary html tags, etc and display just the definitions. The code follows ...

require 'net/http'

word = ''
text = ''
ARGV.each {|arg| word << arg; word <<" "}

res = Net::HTTP.get_response('', '/search?hl=en&q=define%3A'+word+'&btnG=Google+Search&meta=')

arr = res.body.split(/<\w+>/)
arr2 = []
arr.each { |g| arr2.push(g) unless g =~ /<.+>/}
arr2.pop if arr2.last =~ /Display definitions/
arr2.clear if arr2.last =~ /all words are spelled correctly/
puts "\n#{arr2.length} Definition(s) of #{word.upcase}\n\n"
arr2.each { |d| puts d+"\n\n"}

A brief explanation of the Code -
The first line includes the net/http module.
The third line take the word(s) entered at the command line and forms a string.
The next line retrives the page using the 'define' keyword at google.
The rest of the code is just parsing the page to remove tags etc.

Here's a sample output

C:\Ruby>ruby google.rb behoove

1 Definition(s) of BEHOOVE

be appropriate or necessary; "IT behooves us to reflect on this matter"

C:\Ruby>ruby google.rb ruby programming language


Ruby is an object-oriented programming language. It combines syntax inspired by Ada and Perl with Smalltalk-like object-oriented features, and also shares some features with Python, Lisp and CLU. Ruby is an interpreted language.

I think this code shows just some of the power of Ruby - in very few lines of code, we can achieve some AWESOME functionality! Till the next post ...

P.S. Im running a server at my place, check it out at

Its got loads of Ruby and Java Code, and i have also deployed a Ruby on Rails application on it (thats gonna be the topic of my next post). No URLs for the former, good luck searching for it!
The latter can be found at

Friday, August 05, 2005

Ruby: Programmer's Best Friend

I still cant remember how i got initiated into Ruby, but it definitely was a perfect example of serendipity! I do remember though, downloading and reading Programming Ruby aka the "The PickAxe" by Dave Thomas et al, and i was BLOWN AWAY!

Ruby is an Open Source Object Oriented programming/scripting language created by Yukihiro Matsumoto, a.k.a. “Matz” from Japan. In the foreward to the book, he writes -

"Man is driven to create; I know I really love to create things. And while I’m not good at painting, drawing, or music, I can write software.

Shortly after I was introduced to computers, I became interested in programming languages. I believed that an ideal programming languagemust be attainable, and I wanted to be the designer of it. Later, after gaining some experience, I realized that this kind of ideal, all-purpose language might be more difficult than I had thought. But I was still hoping to design a language that would work for most of the jobs I did everyday. That was my dream as a student.

Years later I talked with colleagues about scripting languages, their power and possibility. As an object-oriented fan for more than fifteen years, it seemed to me that OO programming was very suitable for scripting too. I did some research on the ’net for a while, but the candidates I found, Perl and Python, were not exactly what I was looking for. I wanted a language more powerful than Perl and more object-oriented than Python.

Then, I remembered my old dream and decided to design my own language. At first I was just toying around with it at work. But gradually it grew to be a tool good enough to replace Perl. I named it Ruby—after the precious red stone—and released it to the public in 1995.
Since then a lot of people have become interested in Ruby. Believe it or not, Ruby is actually more popular than Python in Japan right now. I hope that eventually it will be just as well received all over the world.

I believe that the purpose of life is, at least in part, to be happy. Based on this belief, Ruby is designed to make programming not only easy but also fun. It allows you to concentrate on the creative side of programming, with less stress. If you don’t believe me, read this book and try Ruby. I’m sure you’ll find out for yourself."

Ruby does all that Matz said it would and more! n lil wonder then, that its more popular than Python in Japan. The only surprising thing is why it hasnt caught on all over the pretty sure it will. Any good programmer needs to just work with Ruby for a few days and realise why its sooo much better than most of the other programming languages!

I told Hrishikesh ("thite" as we more commonly call him) bout Ruby and he too was HOOKED. Gautam (aka "geek") meawhile was learning Python.

So what is it that makes Ruby so gr8? Dave Thomas, in the preface of the book says -

"When Andy and I wrote the first edition, we had to explain the background and appeal of Ruby. Among other things, we wrote “When we discovered Ruby, we realized that we’d found what we’d been looking for. More than any other language with which we have worked, Ruby stays out of your way. You can concentrate on solving the problem at hand, instead of struggling with compiler and language issues. That’s how it can help you become a better programmer: by giving you the chance to spend your time creating solutions for your users, not for the compiler.”"

Having used Ruby for quite some time now, i havta agree. Whenever im writing code in Ruby, most of the thinking has gone into how to solve the problem rather than being stuck with the deficiencies of the language and how to get around them!

Ruby is a dynamically typed language (more on this in a later blog). Coming from a background of statically typed languages like C, C++, Java, etc. dynamic typing is soo beautiful, i wonder why ALL languages dont have it! Dave Thomas et al call it "Duck Typing" and say -

"In Ruby, the class is never (OK, almost never) the type. Instead, the type of an object is defined more by what that object can do. In Ruby, we call this duck typing. If an object walks like a duck and talks like a duck, then the interpreter is happy to treat it as if it were a duck."

Love that last line! :d

Well, i found duck typing pretty awesome as besides other advantages, it really helps incremental code development.

Another awesome resource for Ruby is Why's (Poignant) Guide to Ruby. Not only is it a fascinating read and a good source to learn Ruby, it also provides a unique take on Ruby. Read it to know more!

I hope those of you who read this blog feel tempted to give Ruby a try! Trust me itll change the way you code! Various downloads, source code, documentation, etc is available at the Ruby Home Page

Well, i think i should wind up this blog now! Examples of Ruby code and solutions to the Python Challenge in Ruby to follow shortly. Ill end by once again quoting Matz -

"The stone has started rolling. It will became a great mountain and fill the whole earth."
Yukihiro Matsumoto, a.k.a. “Matz”
Japan, August 2004
Preface to the Second Edition of "The PickAxe"