Dr. Nic has this article on using XSS which really rocks my socks.
Because, if only I could switch NowPlayingLyrics.com to use XSS it would kill the signature and JAR and which would be oh so damn super cool.
"What have we got?"
Powerman 500- That's Entertainment
Snorting brain chemical could replace place sleep
This is the last straw. Now officially when anyones' sleep goes away, it won't hurt anything but ego, which is not cool. Not cool at all.
def sort(arr, crit, i)
final = []
arr = arr.sort_by {|a| a.send(crit[i])}
hash = arr.slice_into_groups(crit[i])
sorted_keys = hash.sort_by {|k, v| k}.gimme_firsts
if i < crit.size - 1
sorted_keys.each do |key|
final << sort(hash[key], crit, i+1)
end
else
final = arr
end
return final.flatten
end
class Array
def slice_into_groups(crit)
hash = {}
self.each do |a|
hash[a.send(crit)] = [] if hash[a.send(crit)].blank?
hash[a.send(crit)] << a
end
hash
end
def gimme_firsts
self.collect{|a| a.first}
end
And Tests for the Array code.
class ArrayTest < Test::Unit::TestCase
def test_slice_into_groups
objects = Model.find(:all)
assert_not_nil objects.size
old_size = objects.size
grouped_objects = objects.slice_into_groups('attribute')
sum = 0
grouped_objects.each do |k, v|
sum += v.size
v.each do |obj|
assert_equal k, obj.attribute
end
end
assert_equal old_size, sum
end
def test_gimme_firsts
assert_equal [1, 2, 3, 4, 5, 6, 7], [[1, 2, 3],[2, 2, 3],[3, 2, 3],[4, 2, 3],[5, 2, 3],[6, 2, 3],[7, 2, 3]].gimme_firsts
end
end
This is basically to keep tests in place for MySQL order bys ... which I know make absolutely no sense, but if there's a requirement and someone changes something I like a test to break to tell them I didn't put the order by in there for nothing.
The index passing down the call stack is fairly ugly but I need to find a better way.
"Open your eyes"
Metallica - Invisible Kid.
Merry Christmas ... Please
I never knew you could have a horrible Christmas day, I just never knew.
So yes, it's been an injuringly long day, and I'm this close to falling off and falling asleep but I promised myself I'd blog today, so here we go.
One, it's insanely hilarious how I promise myself I'll blog about inane shit like today, and not blog about the stuff I'm doing technology wise, must make note to blog about:
1. Signed Javascript Apps.
2. Deploying them.
3. Making a Rails plugin.
Two, I cannot dance. I'm just not cut out like that. No I'm serious man, I'm sure I'm defective in that way, and my sweet sister has asked me to dance at her wedding on a grand total of four songs. I swear, I was going to fall down and die when I heard that. I mean, yeah four whiskeys later I'm doing all kinds of things on the dance floor, but you're talking about serious choreographer stuff here. I know I'm part of my family and all ... but ugh man, I suck at dancing. The problem is we Sindhis take out wedding dances very very seriously. I remember a time when I was a kid, and dancing used to be fun and I used to be able to do hand stands and be funny and that was acceptable. Now ... well let's not go into that. I know two songs I'll be dancing on so far. Bring It On and Partner. Wheee.
Three, New Years' I will be in Bombay partying it up with friends, so whopeee!!
Four, Christmas ... I did fairly nothing. I've been adding a custom search to the lyrics website and it's not working out well, so I need to work on that a tonne.
Five, I've been playing Devil May Cry 3. And it is damn damn damn kickass.
I think I'll sleep now. I want tomorrow to be a nice day. A merry and nice day.
"Let's put a smile on that face"
The Joker - The Dark Knight
I love Windows
I recently chose to Upgrade to Windows XP.
Actually I was always using XP, never going around to the proprietary BS of Vista, I got Windows pre-installed with the work computer, if Skype worked as well on Linux I would never ever use Windows ... except for the occasional game ... and www.nowplayinglyrics.com ... and the DVDs ... and yeah, that's it I just use Linux for work :)
"Dawn of a new day"
In Flames - Dawn of a new day
Why so serious - New Batman movie trailer
Why So Serious? - The Dark Knight Trailer
Heath Ledger is a crazy person, I'm convinced. It's either that or he's a damn good actor. But seriously, this one promises to be something much more.
Either which way Batman Begins will always be close to my heart.
"Imagine there's no heaven,
It's easy if you try"
Imagine - John Lennon
PS: Creepy lyrics I know, but it just goes well with the motif ... plus I can't stop listening to this song. Have a nice day, put a smile on that face!!
Why you shouldn't piss your voters off
Now Playing Lyrics
I wrote NowPlayingLyrics.com. Check it out. It grabs the Now Playing Song's lyrics for you.
"Zen"
Strapping Young Lad - Zen
No really, Rails 2.0 is here
*Jumps up, screams, runs around for a while with arms flailing in the air whilst sweating like a sprinkler. Assaults a two headed-lion, wins the battle, overthrows Ceaser (that little shit), ruins the Kingdom in general, runs into the wall of A-201, breaks the door of the Bossini showroom at Commercial Street in Bangalore. Barks for a day, sits down and installs Rails 2.0 ... because it's supposed to be that damn awesome (seriously read the new features they've pumped in, they even made fixtures better)*
Gift List ... Final
This time, ordered according to priority.
1. NYC vacation: No questions asked. This is and always will be number one.
2. MacBook Pro: I have decided I don't want to go to jail before the age of 30, hence killing Mr. Dude for his black MacBook Pro is not something I want to do.
3. iTouch: It's just so damn pretty. And plus music addiction is so my thang.
4. Books: Somewhat last on the list, because well ... I'm smart already, reading is for people who don't have MacBooks.
5. Uber - God like power: This I know I won't get. But what the hey. I want stuff like teleportation (most important), ability to read people's minds (very cool), super batting power (I'm Indian what to tell you), carrom skills (I just really suck at carrom)
So yes, beer makes me want gifts. You didn't know that did you?
>> a = StringIO.new("abcd")
=> #<StringIO:0xb6e1b354>
>> b = a
=> #<StringIO:0xb6e1b354>
>> b.read
=> "abcd"
>> b = a
=> #<StringIO:0xb6e1b354>
>> b.read
=> ""
Notice the hash signature for b is the same as the hash signature for a. Which is why even though you re-assign it to point to a it's already read the contents of the StringIO you created and hence nils out.
Now see this.
>> a = StringIO.new("abcd")
=> #<StringIO:0xb70570a0>
>> b = a.clone
=> #<StringIO:0xb7055994>
>> b.read
=> "abcd"
>> b = a.clone
=> #<StringIO:0xb7053464>
>> b.read
=> ""
The first time you clone a and point it to b, it creates the hash signature as "#<StringIO:0xb6d968ac>" and the second time you clone it it creates a different hash signature "#<StringIO:0xb7053464>". Hence, multiple clone calls actually still point to different memory space, but it's still the same variable?
Now see this.
>> a = StringIO.new("abcd")
=> #<StringIO:0xb7042240>
>> b = a.clone
=> #<StringIO:0xb7040bfc>
>> b.read
=> "abcd"
>> b.rewind
=> 0
>> b = a.clone
=> #<StringIO:0xb703d1dc>
>> b.read
=> "abcd"
>> b
=> #<StringIO:0xb703d1dc>
Apparently when I clone an object, it still retains the property that StringIO has been read. Which behaves uniquely for StringIO considering the read pointer concept. But yes, somethings amiss.
"I came in with my word,
I will leave with my word intact."
Al Pacino - The Insider
Gift Ideas For Me
Sammy Larby says it best at his blog
1. JetBrains' IntelliJ IDEA: Already have, use, love, adore.
2. Books:
a. Programming Ruby, Second Edition: Already have, read, slept with.
b. Code Complete 2: Not Read,
c. Agile Software Development: Live by.
d. Principles, Patterns, and Practices: Not Read.
e. My Job Went to India: THE IRONY!
g. The Branson Story: Personal Favorite.
h. The Kite Runner: Beautiful book.
i. The curious incident of the dog in the night time: Nice.
j. To kill a mocking bird: All time favorite.
3. Xbox 360: The office just bought one. So this is also off the list, although ... wouldn't mind having one at home.
4. MacBook Pro: I would kill for this. Like seriously, I might kill this guy I know. He's sitting five feet away from me on his black MacBook Pro, and dammit he keeps shoving his "my textdrive is so awesome and pretty for Rails" line in my face.
5. A Vacation: Now see. NYC, no questions asked.
But yeah, happy gift giving time. I'm gonna be saving up this time. This year has been great though, I'm in one of those resolution moods. *grin*
"A clear song rings in the blade
When steel meets hardened steel
I hear the sound of wood that breaks
A sword cuts through my shield"
Amon Amarth - Valhall Awaits Me
Would you put lines on your resume that essentially say:
"(bullet point) I am smart"
"(bullet point) I am awesome"
The premise initially is you would only add a line that says you're smart if you think people wouldn't think that when they read your resume or met you.
But, if that's common sense, then are you smart enough to realize that smart people don't put lines on their resume that say they're smart, for people who don't have enough time to assess that. So, are you smart enough to say you're smart, when all the smart people are really scared of looking like they're trying to hard.
The real question is should I work, or should I work?
I should work.
"Like a bull in a China shop,
But the shelves have all been cleared.
A thief in an empty vault,
The sheep already sheared
A screen door on a submarine,
An eagle with a broken wing,
Hope in a dead man's dream,
The sound of a bell
that will never ring
You're just wasting time "
Lamb Of God - Foot To The Throat
"I like smart, what I don't like is a smart-ass"
Raw Deal
PS: I love today.
The writer's strike is about the internet
Who put kryptonite in my tea?
Some days you wake up feeling like the man of steel. You feel like you take on a hail of bullets and have a Harry Potter to show for it.
Some days someone puts kryptonite in your tea. And you just want to kill something.
You know how some people just never have any luck ordering pizza. You know me then. I've never had a good experience ordering a pizza home, like ever! I don't know why I still do it. I just don't. Every single time I order a pizza it comes in late. So yeah, I can deal with it you know, I'm not exactly the kind of guy that likes to eradicate a people.
Pizza guys are great though, they do this thing with the "I'll give you a 50% off on your next purchase with us" which is so awesome!
Because well you get 50% percent off AND you have to be darft enough to order pizza home from the same idiots who got your pizza late to begin with. I never really followed up with the discount so I don't know if it would happen, but I'm willing to bet they would have got that late too.
What really gets to you though is when you throw your hands up and say:
"Dude, the pizza place is 10 minutes away from the office there really is no excuse for an hour and a half delay. I don't want a discount man, just do something about how you take your orders."
Now, somehow in some weird pigmy ass interpretation Mr. Pizza guy (nameless) interprets that as a "Please say something about discount offers that will insult me."
"Sir, I am prepared to offer you a 15% discount now .... or 50% off on your next purchase."
Honestly man, whoever came up with that kind of an offer should be shot. But more honestly, the guy who took either side of that offer should be mutilated.
Don't ever do that to anyone. Ever. It's just very very hollow. To incite that someone is being greedy is to err. But to incite that someone is being greedy and to make them choose between two options that both have "Sell your soul to me, because I deliver pizza late and throw money at people who complain" is just shit. Have some balls. Take some responsibility, it's okay to go hungry for one night but the satisfaction of telling the pizza guy to shove it makes my day anyday.
And one more thing, don't give in to the rickshawallahs ... ever! Stand your bloody ground, if you belong to Pune, make it your home. Don't let some asshole take it away from you because you're too lazy to walk a few minutes. Make the effort, it's always worth it.
"And then you'll know yourself."
Pantera - Goddamn Electric.
Here's some useful Unix tricks I use/should be using at work everyday.
Useful Unix Tricks
Useful Unix Tricks Part 2
Big props to Paul Gross
If you have code that uses DateTime.now you ask yourself "How's my test supposed to pass?" and your pair says "I'd peg it at 1 out of ten times" and if your pair is Rohan Kini you know you have a way out.
Let's set it up right. I have this object:
class User
def initialize
@time_of_birth = DateTime.now
@name = "The dude"
end
def take_over_the_world
p "#{self.name} is taking over the world"
end
end
The tests for which look like
def test_if_use_is_born_with_right_defaults
the_dude = User.new
assert_equal the_dude.time_of_birth, DateTime.now
assert_equal the_dude.name, "The dude"
end
Now obviously a few milliseconds might have past since the execution of User.new so odds are your test will fail even though they should pass.
Here's how you change things around a bit.
In your user class you need to abstract the DateTime.now bit, so you can override things in your test
class User
def date
DateTime.now
end
def initialize
@time_of_birth = date
@name = "The dude"
end
def take_over_the_world
p "#{self.name} is taking over the world"
end
end
And in your test override the new date method you created.
NOW = DateTime.now
class << User
def date
NOW
end
end
def test_if_use_is_born_with_right_defaults
the_dude = User.new # Will use now because you've overridden User::date in the context of this test
assert_equal the_dude.time_of_birth, NOW
assert_equal the_dude.name, "The dude"
end
If your using the Ruby plugin with Intellij which by the way is way feckin' awesome your should be suffering some performance issues. Intellij eats up about 300 to 400 megs easily and it's really deathly slow. Especially if you try running your tests out of IntelliJ.
Here's something to speed things up a bit. Open up #{idea_directory}/bin/idea.vmoptions and make it look like this:
-Xms300m
-Xmx512m
-XX:MaxPermSize=99m
-ea
-XX:+UseConcMarkSweepGC
-server
The first line specifies that idea should load up with 300 megs, this is good because it ensures idea doesn't go "allocate allocate allocate" because it has sufficient memory ot begin with.
The second line specifies max memory. You can up this number. My dell has only one gig hence I keep it at 500 megs.
The UseConcMarkSweep is way cool, because it's an alternate garbage collection algorithm which the JVM uses and is way efficient if your running a dual core.
The server argument to the JVM is good for long running processes because the JVM optimises it that way.
Thanks to Chris Stevenson for this life saver.
I know I haven’t posted in forever. But hey, I was busy :P
I’ve spent the past six weeks in Bangalore attending ThoughtWorks University which is their training programming for freshers like me.
I’ve learned loads of technology, not to mention agile methodologies. We got to spend a good amount of time with the Chairman of the company, who is by far the nicest boss I’ve met aside from my brother and previous Project Manager of course.
I’m at home now.
I’m also reading this book called "The curious incident of the dog in the night-time" It’s great!
You have a textarea and you're rendering the text you get from it on a page.
Textarea Input:
This is on the first line.
This is on the second line.
This is on the third.
Browser Output:
This is on the first line.This is on the second line.This is on the third.
Now that sucks.
@string = $F(TextAreaId).value
@string = CGI.unescape(@string).gsub(/\n/,"<br />")
And you're done!
PS: $() is prototype.js for getElementById()
"They make you drink your blood,
and tear yourself to pieces!"
Accept - Balls To The Wall
Firefox print preview eyuck!!
I mean, it's actually pretty nice, it's us who were screwing up but c'mon everyone keeps saying all these nice things about firefox it's about time someone played Devil's advocate!
Problem: Firefox's print preview ate up pages 197-200 pages of a 300 page print preview and for some reason rendered the rest as un-tabulated HTML even though in the HTML source the HTML was perfectly formatted, other browsers Safara, Opera (notice me not saying IE) displayed things perfectly.
The shakedown:
1. We were inserting page break's programmatically using CSSs'
<div style = "page-break-after: always;"></div>
2. Somewhere in the code there was a float: left and float: right trying to create a div that exists side by side on the same page like I do with my sweet brother. Unfortunately, and I can't stress this enough only one float can exist in this town bubba! Use a float and a margin if you like, it's good CSS, I learnt it from the O'Reilly book.
leftElement {
float: left;
}
rightElement {
margin-left: some_number em;
}
PS: Use "em" please ... don't use "px" be more in-support-of-resizing-fonts/usable/awesome. em is based on the font-size of the element and pixels are just poison if you resize.
Also, as the paranoid boy in me keeps insisting use a div with a style that clears everything to make sure you have no float's affecting something else's behaviour.
<div style = "clear: both;"></div>
3. Somehow the extra float: right killed the page-breaks we tried to insert ... how and why I cannot tell ... and will probably never be able to find out, but to gain something from this, try using the Firebug extension, it is seriously the shiznit of the time. So if your page-breaks aren't working as expected or anything isn't for that matter give it a shot, good stuff!
"We said we would return,
and here we are again"
Manowar - Warriors Of The World
Okay so you've all heard about the miracle of birth right?
Then again you haven't heard about the miracle of refactoring have you?! Yup, I'm going to tell you all about it now.
Or put up some links so you could just experience the niceness of it all.
There's a nice book on Refactoring Ruby that I want to read.
There's a couple of RailsCasts on refactoring I'm downloading as we speak.
Cheers to better, cleaner, more readable, faster way more kickass programming.
"Put an end to their fascist laws"
Six Feet Under - Victim Of The Paranoid
Titus used to be the funniest show around and then they suddenly stopped it, curse you Star TV!
I used to watch it like it was my religion *sigh*.
The part with the bulb used to be awesome. It's a shame I can't remember anything from my 11th grade Chemistry education though!
"Wir waren namenlos"
Rammstein - Los.
PS: As a plus check out Herzelied it's got a good catalogue of Rammstein's lyrics in English/German.
I'm a minister - Minister Engineer Sid
I have one of those colds which you leave out of dinner table conversation because well, it's funner to have your ankle hair braided and make up put on your face in your sleep and later mocked by your cousin sisters than dealing with this ... this fog in your head.
As far as home remedies go:
1. Chai/Tea preferably ginger is your best friend. I really mean this.
2. Hot soup, hot soup, hot soup ... mix it in rice if you like stewed rice. It's a nice delusion of grandeur, tastes almost like the real thing.
3. Hot water + honey + ginger = Awesomeness (thanks to my project manager for this)
4. Beat yourself senseless with a brand spankin' new leather belt.
Yes No. 4 is a lie.
"Warriors from hells domain
Will bring you to your death
The flames of hades burning strong
Your soul shall never rest"
Slayer - Hell Awaits
You call yourself a gangsta and you aint eva' heard of Gizoogle
It basically takes the page you type in and converts it to gangstah!
Eg:
But I guess I learnt some jazzy stuff about the configs.
Becomes,
But I guess I learnt some jazzy shiznit `bout tha configs and yo momma.
"Damn It Feels Good To Be a Gangsta"
Damn It Feels Good To Be a Gangsta - Geto Boyz
Movie you must see.
Hot Fuzz is one of those awesome Brit comedies that I frikin' love. Plus, the same guy who made Shaun Of The Dead made this one. I haven't seen the latter yet, but I've heard stories.
As an addage, it's a homage to out and out action movies like Bad Boys.
"Die Motherfuckers,
Die Motherfuckers,
Still Fool"
Ghetto Boys - Still.
PS: That's the song in the background when the guys from Office Space assault the Xerox machine, the gangsta way ...
Dis not proudest moment
Usually on a Ubuntu install you install rails via
sudo gem install rails
But, sometimes this leaves the symlinks in the vendor/plugins folder broken. You fix it as follows
sudo apt-get install rails
Who'd have thought you need to both eh? Well, the new Rails install guide for Ubuntu Fesity fawn tells you to do so, but not why.
Anywho, if you need by any chance to downgrade a version like I did. Apparently rake tasks that use ActiveRecord objects don't work quite well on Rails - 1.2.2 so I had to go down to Rails - 1.6.6
sudo gem install rails -v1.6.6
Go to http://packages.ubuntu.com and get the specific version of Rails from there.
EDIT:
The reason for this is, by default your server will first look for Rails inside your MY_APP/vendor folder, and since those symlinks are broken will complain since an install using gem doesn't put Rails inside the /vendor folder, it only creates symlinks.
A fix is just to delete what's in the MY_APP/vendor folder.
"Deadringers, Warmongers, Hypocrites,
Masquerade in Blood."
Sodom - Masquerade in Blood
So for the heck of it, a concept album is an album that's unified in theme by narration, instrumentation or anything else. King Diamond's Voodoo is such an album, a kickass album at that.
Anyone else likes Psych as much as I do?
Plus, new Simpsons movie, oh yeah!
I'm thinking of going down to Mumbai on the weekend. Been a while, since I've had a good time.
That, and here's a nice article about 12 programming languages that didn't really make it.
"I'll teach you to laugh at something's that funny"
Homer Simpson (while choking Bart)
My. Bug,
You have been found.
Now I will hunt you down and I will find every method possible to take you down, believe you me, if there is no way to do that I will divide and I will conquer.
You can hide, but it will be futile, from now on we are enemies, you and I.
cheers,
Siddharth Dawara.
"From now on,
We are enemies,
You and I."
Children Of Bodom - War Heart
Here's the shakedown, both essentially do the same thing, they take what's in the ActiveRecord, use the Model and take the information back to the database but there's one very important difference between the two.
Save incorporates all your filters (validates_uniqueness_of etc.) but update does not. So you say, oh pishaw big bloody deal! Well, I'll why this really is a big deal ...
Say you have a Model and a filter
my_models (
id int,
number int,
name varchar(200),
status boolean
)
validates_uniqueness_of :number, :scope=>:status
What this does is, is asserts the uniqueness of the combination of 'number' and 'status'. Yeah, yeah Mr. Fan, Manowar get on with it.
So you have a delete method which goes:
@model=MyModel.find(id)
@model.status=0
@model.save
Now, we assume that there is another entry into the my_models table which has the same 'number' as the entry we're trying to update but a different 'status' say false. And on deletion we're setting this 'status' attribute to false. The point to note is that the save method will fail on the validate_uniqueness_of callback filter, but it will fail silently, and that my men is what introduces a bug.
Use update in scenarios like that, it works out well.
"13, 13, 13,
Steps to nowhere"
Pantera - 13 steps to nowhere
So, you know I broke it again. But I guess I learnt some jazzy stuff about the configs. If you're using Rails and you keep getting these errors
Can't connect to local MySQL server through socket '/tmp/mysql.sock'(111)
Can't connect to local MySQL server through socket '/tmp/mysql.sock'(13)
Can't connect to local MySQL server through socket '/tmp/mysql.sock'(2)
You need to be editing your /etc/mysql/my.cnf as well as your /etc/mysql/debian.cnf and make them all point to either /tmp/mysql.sock or /var/run/mysqld/mysqld.sock whichever you feel works better with your Rails app.
A simple sudo /etc/init.d/mysql restart should work, if it doesn't you're a special special person with special special needs.
One more thing I've realized about myself, I can't drink coffee in the morning, very bad for me.
Interpreting the Rails Logs
You know how they say one man's blood is another man's wine. Well a while ago, I hated logs. Now I drink them dry.
So MySQL is no fun, if you can't fool around with it. Fool around with it enough, and you'll have to just get rid of /etc/mysql/* and oddly enough apt-get doesn't replace those files if you do a clean install.
Ergo:
sudo apt-get remove --purge mysql-server
and
sudo apt-get install mysql-server
If you play with fire, you're going to get hurt. That simple man. Just use Boronyl or Soframycin!
In other news, on the topic of temperature, I'm so not used to this whole air conditioning thing man. Two t-shirts everyday and I'm still bloody freezing.
Guide to backing up and restoring Ubuntu
Warning: Don't use Ghost, apparently it screws up ext2 and ext3 partitions.
So I'm going to to try this for sure. If any of you have tried this and like it, or hate it. Let me know, I'll add your comments to this post.
"Run to the hills,
Run for your life"
Iron Maiden - Run to the Hills
Ask yourself? When was the last time you truly had fun?
Me?
A year ago, we were trying to install Nokia 6230i drivers with DKU-2 drivers. That was some honest to God fun. Today, I broke my Ubuntu install by changing the permissions for the entire root directory to the current_user. That was fun.
Then when installing Rubygems I used some stow method, which I would not recommend because this method doesn't install the gems you're installing into the current path. Which is oh so sucky. Because then to add everything to your path, you need to keep editing the .profile file.
All in all, Monday suck my balls, because everything now works. HooHaa.
"Now I have a machine gun. Ho. Ho. Ho"
Die Hard.
This Saturday I was at the Pune Barcamp 3 and as usual it didn't fail to deliver. As a technology conference admittedly the Barcamps I've attended so far have been centered around the startup experience and mainly web technologies, but given that the people in these two spheres heavily rely on networking it's not surprising :)
There were some really interesting seminars that deserve a mention.
1. Ketan's seminar on how Eclipse is not just an IDE but can be used a plugin development IDE to develop tools that can do a whole diverse range of stuff.
2. Aditya Thatte's presentation on the upcoming Miscrosoft Silverlight. I think this one deserves a special mention for the quality of the presentation's delivery and response.
3. Freeman's presentation on open source education initiatives.
4. The presentation on how setting up base in the USA, UK and Singapore helps in terms of tax cuts. This one again deserves a special mention for the presentation as well as the content, quite an eye-opener.
Freeman said something very interesting on how the Barcamp community is almost a guild of techies who take care of each other. Cheers to that!
"Here comes the revolution,
Time for retribution"
Judas Priest - Revolution
I'm struggling with all these versions man. Everytime I install something using apt-get or even with IntelliJ or even with IntelliJ's Ruby plugin I end up with a version that is way below par. Man, why isn't everything just ... consistent!
And then there's the fact that when the install works, it's not like in the demo. Just not like in the demo.
Someone should hold me ... like NOW!
"No sense makes sense
You cant get bought without thought
Ahh... no sense makes sense
You cant get bought without thought inside
Your head now"
Pantera - Uplift
Skype doesn't have a release for 64-bit Ubuntu distributions. I'm running Ubuntu Feisty fawn that's Ubuntu 7.04. The .deb from the Skype for Linux download page doesn't work on a 64-bit architecture.
Here's some documentation on how to work around it.
The fix didn't work for me though :( All I got after installing was a "/usr/sbin/skype doesn't exist"
Creepy Happy People
Okay, so I removed my brand new Kubuntu install and went the old Creepy Happy People way.
Disclaimer: No matter what I say, I frikin' love Ubuntu.
So you ask me why I uninstalled Kubuntu? Because I'm now running the 64-bit Ubuntu! So you ask me why again ... two reasons:
1. The bum on this side of the screen didn't know that the Dell Latitude D620 runs an Intel Core Duo T2400 1.83GHz processor which can calculate the value of PI upto 2 million digits in 1m 21s has a 64-bit architecture! Well DUH!
2. I'm like that.
So yay for old times sake, one more Creepy Happy People pic.
Picture Time!
Warning: All subjects in the following pictures were first asked if I could photograph them, and then when they declined were politely persuaded :)
The Main Building
The TW Logo :)
The carrom break everyone took, this is how people chill :)
This is Ketan, he likes Eclipse :)
My work box, I was installing Kubuntu.
The Chronicles Of S.Dawara Jr : My First Day Of Work
All the most kickass and interesting chapters in my life will be labelled hereforth as "The Chronicles Of S.Dawara Jr."
So you ask what's so interesting about today? It seems like just another day, another Wednesday, another 4th of another July. Well, you would be damn wrong, oh so damn wrong!
Today is my first day at work at the ThougthWorks Pune office. I sit here on the laptop they gave me, a Dell latititude, worried sick about someone catching me blogging. Everyone around me is arguing and working, and a lot of people seem to be eating banana chips. I love those things!!!
I'm not working right now, because
1. I'm like that.
2. I'm actually going to be working on a Ruby project (dance dance dance) but the problem is the developer I'm supposed to pair with is not in town. He comes back on Monday ... till he gets back I'm a bum with a mission, setting everything up.
All I get to do is sit here and blog my ass raw. Sigh, all the good things in life elude me till I actually go out and get myself a job.
I will be posting some pictures from my first day here, so watch this space fo the shizzle mah main man!
Oh yeah did I forget to mention how awesome this place is? I mean seriously ... I can work in shorts. Pishaw to all you others who feel bad, go tear of your pants. GO!
The News.
I've been looking for an English version of these lyrics for ages, and well today I give back to the internet community. Mind you, this is not available anywhere. *Does immodest dance*
[Music: Ivar Peersen - Lyrics: Ivar Peersen]
[* = excerpt from Norwegian author Aksel Sandemose, book Vi pynter oss med horn]
Dei for ifra nord
Mot ei anna tid
Bak låg brende ord
Framfor dei ei ny strid
Dei såg såg stormar i det fjerne
Men haldt fram og beint
Inn mot jordas kjerne
Frå tidleg mot seint
I see a darkness overwhelming
I see that there is no light for me
I don't care if it leaves me blind
I don't care if I'm left behind
I see a white horse's head
I see it's dead stare fixed at me
I do not fear its eyes
Curse myself, return it twice
I see walls to high to climb
I see nothing on the other side
I should have roamed another space
I should have been another place
*Dei daue gror opp av havet og ropar så sårt mot land.
Dei ropar bak alle skuter, som kavar seg tungt forbi
I am among ghosts when I should rest
I cannot tell the worlds apart
I do not heed the words they say
There is no dream of another day
I hear a silence, deafening
Drowning the deserts, that is my destiny
I no longer wish to see
The threads they've spun for me.
Dei for ifra nord
Mot ei anna tid
Bak låg brende ord
Framfor dei ei ny strid
Dei såg såg stormar i det fjerne
Men haldt fram og beint
Inn mot jordas kjerne
Frå tidleg mot seint
The norse verse is translated as:
"We put on horns."
They came from north
towards another time (/era/reign).
Behind lay a burning word
ahead lay yet another toil (/feud/battle)
They saw storms in the distance
but persisted boldly and brave
into the earths core
from early to late (meaning: restlessly).
The two extra lines are translated as:
The dead rise from the water and wail scornedly to shore
Calling from behind all ships that ladenly crawls by.
Yeah, I like the Norse version better. Sounds like a kickass sailor's song. Thanks to *I will keep him anonymous* Norwegian dude form Orkut who knows Mixed Martial arts!
You should see the segment from the Metal, A Headbanger's Journey movie where the song plays. Beautiful stuff.
Being a victim of malware spread via USB, I felt this post is quite justified. Have you had the experience wherein you plugged in your USB drive and double-clicked on it and nothing happened ... and everytime from then on that you've tried to eject a drive didn't work. Well, people you've infected your drives and computers for long enough.
Here's how to deal with it:
1] For your drive, plug it into a Linux PC and delete the autorun.inf file or do it using a Windows PC without double-clicking on the drive icon. By not double clicking on the drive icon your basically not running the code in the autorun.inf file.
2] For your PC, a format and re-install is the best solution, but in case you're not infected and looking for a solution, here's what to do via Thushan Fernando's blog:
1. Start > Run, type in 'gpedit.msc' without the quotes, this will show you the Group Policy Editor.
2. Goto 'Computer Configuration' > 'Administrative Templates' > 'System' and select 'Turn Off Autoplay'
3. When the properties for the policy pops up, check 'Enable' and select 'All Drives' and hit OK.
Cheers and stay safe!
"Climbing down,
To Rule the Earth"
Satyricon - K.I.N.G
Ends and Means
There are three kinds of people in this world. Those that believe the ends justify the means, those that don't and then there's the types who could care less about the end.
It's all about the means.
Do something for the heck of doing it, not for the end result. It's quite liberating. More fun than liberating, really.
Dell to pre-load Ubuntu on laptops
See. Important people read my blog.
I seriously have the worst luck in the world!
(whole world's bad luck) / (no. of people in the world) = (cube root (my luck)) / (no. of people in the world who watch My Name Is Earl)
Hence,
my luck = (((whole world's bad luck) / (no. of people in this world)) * (no. of people who watch My Name Is Earl)) cubed
And since everyone in this world knows and watches My Name Is Earl.
my luck = (whole world's bad luck) cubed
Bad ass mathematics I know. I wanted to push some Contour Integration in there. But the formulae get by me.
"Metal Heart"
Dimmu Borgir - Metal Heart
Webaroo
The SMS applications are here, in India. And I'm betting it's to stay. Not everyone has a sexy GPRS phone, some of us have the ancient ones.
Here's to including all of us in your target market.
Ubuntu is the man
Okay, I remember I did this post when I was really frustrated with the whole Ubuntu scenario, but I gotta say ... I've really grown to love this OS. And here's why:
1] It takes me exactly half an hour to do a Ubuntu re-install as opposed to a crappy one or two hour windows install. Although reinstalling stuff on Ubuntu involves a lot of downloading, I guess one way around is to download all the packages you need and use an install CD. Will post about that.
2] It's FREE! I mean, I don't have to worry about ripping stuff, and breaking the OS. Btw, that's how I broke my last windows install, WMP 11 was just too tempting.
3] Breaking Ubuntu happens, but not as often and unexpectedly as breaking Windows used to happen. Plus, with Ubuntu mostly everything is transparent so the fixes are about 50% obvious, the times that they're not obvious the forums rule!
4] I agree Ubuntu doesn't look as sophisticated and slick as Windows does, but hey that's part of the charm.
5] Hardware support can be an issue, but hey if you're smart enough to try installing some esoteric device you're smart enough to make it work.
I would suggest switching to anyone who'se using a ripped copy of Windows ... it's a good feeling to know you're not breaking any laws :D
Whew!! A lot has happened over the past few weeks, and a lot really means a lot.
One, Rohit and I won first prize at the intechxication intra project competition and we won the prize for the best mobile computing project at the inter college competition... which is odd because ours really has no mobile computing as such, I think the college had trouble classifying our project.
We would or could have won the inter all the way too, but our second judge was a real asshole, he never even saw our demonstration :( Throughout our presentation he just kept nodding ... I was so enthusiastic about it, total turn off, but hey I put my best foot forward and at the end of the day, that's all that matters. Plus, we won 5k and we're entering another competition hopefully :)
Two, my project is finally over and done. It works great, exactly as expected which makes me immensely happy. This also renders me aimless in life, which is fun and sad at the same time. Odd feeling really, not having to think about it, but I guess there's a time and place for everything.
Three, I am so not good with details. From now on, I'm going to be that person who runs around with a pad and writes down things, like e-mail addresses especially.
Four, I had some stuff in mind to blog about as regarding technology ... but it's all just completely slipped out of my mind. The past three weeks have been really amazing that way, everything working and all. I guess I'll blog it out as it comes to me.
Five, I had an excellent time with the folks at ThoughtWorks at their family day!! I learned I am very very very BAD at bowling, and no this is not good bad, but bad bad. My second try I managed to smack the ball at the ceiling, yes ceiling. Temporarily, I think it would do me some good to put my bowling career on hold. That and I sprained my right wrist, very sad news I know, painful though. I had to draw up the charts for my project stall with that wrist. Feels better now, and I'm actually thinking of giving the whole bowling thing another go. :D
"There was a time and a place, where we won it all"
Rohit.
The post that follows is the honest truth and bear in mind, I know it sounds to good to be true :) But it isn't ... it's just awesome.
Every Friday the movies in Pune change in the theatres. Last Friday, the movie change was to 300. Now if you've been on the internet or been watching TV you would be affected by this buzz 110% The 300 is a gory movie about an epic David Vs. Goliath battle.
My point though is how I went for the movie. Now you must understand E-Square is one of the more popular multiplexes in town and going for a Friday night movie at 9:30 without prior bookings is unheard of!
But I did it.
Yes sir. I sadly even showed up five minutes late :) But my tickets were still there for me.
All thanks to the guys at BookEazy. BookEazy is a movie ticket booking service which allows you to book tickets online and pay for them on arrival at the theatre. You don't have to come early/wait in line ... none of that jazz, just book your tickets and enjoy your BookEazy movies as one of my friend eloquently puts it.
The service is awesome, in the sense you don't have to worry about advance bookings at all, just book online, as soon as you book tickets you get a confirmation SMS which you can show to one of BookEazy's special counters at the theatre of choice and get your tickets immediately :)
You can even check out show times for your favourite movies for free on the website.
Plus, you even get to know your seat layout and stuff, online :)
I couldn't emphasize this enough, how convenient this service has been. Trust me, how much ever I say it, it won't be enough. You have to go through it to believe it. I got my tickets at the theatre in under 10 seconds.
Frequent moviegoer or not, the convenience cannot be denied.
"This is not madness. This is Sparta BookEazy"
Leonidas - 300
For Me.
Okay, so I love Rails. But, Rails has an issue with scaling. A fresh install of Rails for instance comes with sessions implemented in the file system. That's all well and good for a development box, the issue arises when you're serving more than a small number of clients.
Serializing data shared by processes in a file is doable. You can use identity stamps and all that jazz, but it slows things down I imagine.
So the alternative is using my favourite ... tables! Or in our case ActiveRecord, the layer of ORDBMS on top of your database.
It's quite simple. All you need to do is find this line in your config/environment.rb and uncomment it.
After this is done, set up the tables by running.
rake db:sessions:create
rake db:migrate
Toggle the code!
Update:
Alrightie then, first rule of entrepreneurship, don't believe in technology (hype). Hmmm, so the ActiveRecord method of storing sessions that Rails ships with is not so good.
Rails is excellent to say the least in the development environment, but production on the other hand involves a lot of fun.
Right now, I'm going to settle for a 60GB hard-drive 1GB memory 15 inch wide screen Xubuntu production box.
Also, for production sake, the alternative's to the ActiveRecord method of storing sessions; you could use SQLSessionStore for sessions, or better still the better performing memcached.
I'm reading this article on how to deploy Rails on a mongrel cluster and Apache.
Toggle Code View.
I spanked out some Javascript, very useful albeit simple. It just toggle my code windows, some of them look pretty ugly. Especially the one associated with my Xubuntu-DKU2 post.
So this is what it looks like:
function toggleVisibility(obj){
if (obj.style.display=="none")
obj.style.display="block";
else obj.style.display="none";
}
Toggle this code!
Add that function to your template and this to your blog entry after the code div.
<a href = "#" onclick="toggleVisibility(getElementById('your_div_element_id'))">Toggle the code!</a>
Toggle this code!
Don't forget you're div element's id should match the id in the link.
"I'll break your will,
I'll break you good,
I'll treat you like a brute."
Lordi - Who's Your Daddy?
Apple's thoughts on DRM free music
Apple wants to sell DRM free music.
Superb business move. I laud it, with all my heart!
"Are you feeling happy?"
Mudvayne - Happy
As you can see I get an average of about 35 visitors per day. 80% of which are unique. Ergo I get about 28 unique visitors every day!
Six of the sources yesterday came from technorati ;)
Argument about BitTorrent.
Here's an argument and response by Bram Cohen and Marc Cuban about whether or not you can turn BitTorrent into a viable business by using paid for content.
"To get out,
Is no longer an option."
Lordi - The Kids Who Want To Play With The Dead
Web Spiders in Ruby
A cool PDF on web spiders in Ruby
I'm thinking of trying my hand at one.
Xubuntu woes.
Whenever I use Synaptic to upgrade my Firefox install or try to install some GUI like the MySQL Query Browser Synaptic tries to remove the following packages:
1. xwindow-system-core
2. xserver-xorg
3. xubuntu-desktop
When I remove these packages and restart my PC the XCFE GUI is gone, I tried restoring the packages using the shell apt-get but it didn't work. I had to re-install Xubuntu.
Someone help! I've posted this thread on the UbuntuForums
EDIT:
Problem Solved!!
Turns out, my Synaptic sources.list was jinxed. I fixed it by enabling the respositories using Applications Properties instead of manually adding them.
Cheers!
Okay, so I've been trying this since a long time and it wasn't working ... but I got some help and now it's working, thanks to Roland Bouman.
The end goal is as such:
Consider the tables inbox, ads, outbox. Everytime text is inserted into the inbox table a function should be called which analyses the inserted text and performs one of two operations:
1] Either the text should be inserted into the ads table, with correct specifications about what kind of ad it is.
2] The text should still be analysed and on the basis of that analysis a set of ads should be extracted from the ads table and this set should be pushed into the outbox table, to be sent out by an SMS gateway.
Now unfortunately for me, being the amateur that I am, I painted myself into a corner by selecting FLEX to generate the lexical analyser or text analyser. Never select technology without understanding the true meaning of flexibility. I would never have spent so much time against a wall, had I been able to re-write the (couple of thousand) lines of code the analyser is in, into MySQL code.
In technology terms I had to somehow ensure that a MySQL trigger would call the analyser code which would call further MySQL code.
1] MySQL Trigger - MySQL.
2] Analyser - C.
3] Further db processing - MySQL/C?
So the question arose how to go about accomplishing said goals.
MySQL UDF's:
These User-Defined-Functions allow you to install C functions as MySQL functions. It's really quite cool, kudos to the guys at MySQL for this beautiful extension mechanism.
MySQL UDF's.
MySQL C API:
Now the problem further arose, how could I pass on the results of the text analysis to MySQL code? The answer is obvious, write the MySQL db processing in the analyser itself! The UDF's allow you to return only pointers to strings, integers, doubles. No pointers to structures, unless I used some string typecasting...
MySQL C API
Problem that will "kill-you-till-you-die"
Now the problem that arose is that, everytime the MySQL C API would try to spawn a new connection it would return a "Cannot connect to server(111)" error.
I pegged it as "the client could not spawn a new connection from within the connection it was in".
According to the manual, the seventh parameter to the mysql_real_connect() unix_socket is not NULL, the string specifies the socket or named pipe that should be used. Ergo, it piggybacks the socket your already connected client uses instead of trying and failing to create a new one.
In my case, it was /tmp/mysql.socket
And now, problem solved.
A trigger on the inbox calls the function which analyses the text inserted into the inbox table and on the basis of that either inserts it into the ads table or retrieves a set of ads from the ads table and pushes an outgoing message into the outbox table.
VOILA!
"There's fighting on the left,
and marching on the right"
ACDC - The Razor's Edge
Today I become number 1
On the 28th of December I blogged that if you googled the words "manowar fan" this blog was number 6.
Number 6.
Today I'm at position number 1.
EDIT: As of today 28th January 2007, it went down to 2.
"And all who see ... shall believe."
Manowar - The Dawn Of Battle.
Javascript Regular Expressions
The Regexp.test(String) function in Javascript is called as:
/^[A-Za-z]/.test("abcd");
The above expression is to test weather a string starts with a letter or not.
This is NOT the same as:
var x = "/^[A-Za-z]/";
var y = "radio-gaga";
Regexp(x).test(y);
When you pass anything to the Regexp() constructor make sure it's not delimited by the '/'s. Ergo, what works is:
var x = "^[A-Za-z]";
var y = "radio-gaga";
Regexp(x).test(y);
You need to have installed the ActionMailer before doing this. You can do this by running:
gem install actionmailer
How to set up actionmailer to use a GMail account
Setting up ActionMailer for Ruby on Rails
"welcome in the visitors"
Lamb Of God - Terror And Hubris In The House Of Frank Polard
gcc -shared -o test_example.so `/usr/local/mysql/bin/mysql_config \
--cflags` test_example.c `/usr/local/mysql/bin/mysql_config --libs`
Assumes your filename is test_example.c and your output file will be test_example.so and you have MySQL installed in /usr/local/mysql/ with the --with-embedded-server option enabled when you configured the script.
"Murder, Mayhem"
Otep - Nein.
I would not recommend doing this. Use synaptic as far as possible, it's way cleaner and faster. In my case, I needed some additional configuration ergo I used source.
1. Step one download the source from the official MySQL downloads page. Pick the community server, and select the MySQL source tarball.
2. I referred to this wiki about how to install MySQL on Ubuntu from source most of the time, but somewhere down the line it failed me. Anyways, on with it. After downloading, extract it using:
tar xzvf mysql-yourversionnumber.tar.gz
3. Before you proceed you need to install three packages. build-essentials, libncurses5 libncurses5-dev. I used synaptic to do this.
4. Now, add a user and group allowing MySQL to run.
sudo groupadd mysql
sudo useradd -g mysql mysql
5. Now, change your directory to the one you just extracted into and use the following options for the configure script.
./configure \
--prefix=/usr/local/mysql \
--with-mysqld-user=mysql \
--without-debug \ (I didn't use this)
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \ (In case you want to enable dynamic loading use -rdynamic)
--disable-shared \ (I didn't use this)
--localstatedir=/usr/local/mysql/data \
--with-extra-charsets=none \ (I didn't use this)
--enable-assembler \ (I didn't use this)
--with-unix-socket-path=/tmp/mysql.socket
The options I used are as below, note, I used rdynamic for dynamic loading, so that I can call C functions within MySQL statements. I used the with-embedded-server option so that I can use the lmysqld library which compiles the MySQL C API which allows me to write MySQL code within a C program.
./configure \
--prefix=/usr/local/mysql \
--with-mysqld-user=mysql \
--with-client-ldflags=-rdynamic \
--with-mysqld-ldflags=-rdynamic \
--localstatedir=/usr/local/mysql/data \
--with-unix-socket-path=/tmp/mysql.socket \
--with-embedded-server
6. After this is done.
sudo make
sudo make install
The make took some time on my machine, at this point go read a book :)
7. Okay, now once this is done. What you need to do is setup the config file for MySQL giving it some default paramters for its connections.
sudo cp support-files/my-medium.cnf /etc/my.cnf
This is assuming you're still inside the MySQL-yourversionnumber directory you extracted the downloaded tarball in.
8. Now you've got to create the GRANT tables. This is easy just run a pre-provided script.
sudo /usr/local/mysql/bin/mysql_install_db --user=mysql
9. Now, you need to setup permissions. Here is where I messed up real bad, like took me two days to get it right after four OS re-installs bad.
So, the wiki says you need to do this.
sudo chown -R root /usr/local/mysql
sudo chown -R mysql /usr/local/mysql/var
sudo chgrp -R mysql /usr/local/mysql
Which looks all good, but my install didn't have a /usr/local/mysql/var directory and it erred here, which lead to another error in the next step. That is the step when you setup the MySQL daemon.
Instead, if the code above gives you an error. Go for this. Make sure you change to the directory you installed MySQL in, i.e. /usr/local/mysql/
chown -R root .
chown -R mysql data
chgrp -R mysql .
10. Once that's done. You need to start up the MySQL daemon (process which runs in the background)
/usr/local/mysql/bin/mysqld_safe -user=mysql&
If this doesn't say something bad like STOPPED then you're in the clear.
11. Set a password for the main user.
/usr/local/mysql/bin/mysqladmin -u root password 'new_password'
Login:
/usr/local/mysql/bin/mysql
12. Now, we setup the daemon to start itself automatically when your PC boots up.
sudo cp support-files/mysql.server /etc/init.d/mysql
sudo chmod +x /etc/init.d/mysql
sudo update-rc.d mysql defaults
Again, make sure you're still in the same directory that you extracted all the files in.
And you're done!
"Life goes on, and it's infuriating"
Lordi - It Snows In Hell.
One day in ...
*hums*
In the 12th standard I left 16 marks in my HSC English paper, I just turned over the question and didn't write 16 marks. I felt so sad after realizing what I had done, I took an hour of my day and thought it over. I vowed to crack the next paper, which was Chemistry a fairly difficult subject for someone of my memorizing capabilities.
I got a 98 in Chem. I'd never studied as hard as that.
Two minutes ago I broke a small promise. Eyaargh! I hate it when that happens.
The point is, sometimes I mess up, but where you're from matters hardly half as much as where you're going.
So now the question is, where am I going?
On a totally different subject I'm now reading Losing My Virginity - Richard Branson