ask the manowar fan
Showing posts with label work. Show all posts
Showing posts with label work. Show all posts

ThoughtWorks, Chennai

Posted In: , . By Sid

ThoughtWorks Chennai

I've been staying in Chennai for the past three weeks, I've flown home for all weekends and am in the loo, where I blog at my best.

The Chennai office is at the Regus office complex in Guindy.

The weather in Chennai is summer-ish, which I like but it gets slightly intense in the afternoons which is alright considering everything is centrally air conditioned all the time.

We spent the first week interacting with the client as part of the inception of the first project here, and it's been one of the more kickass expriences I've had here at ThoughtWorks.

The codebase we're working on has been written by ThoughtWorkers from the UK office. It's got some really kickass aspects to it. For example, it uses jQuery all over the place, it also uses an adaption of the Presenter pattern, the view adapter pattern.

Overall it's been a fairly intense time, but I wouldn't trade it in for anything in the world :) The next four months promises to be interesting in n number of ways, which is nice. I like interesting times, makes me feel alive.

Plus, the office complex has a ridiculous set of rules which I love breaking with a big grin on my face.

That and Martin Fowler is apparently making a stop here for a couple of days, should be *ahem* interesting to meet with the guy.

 

Useful Unix Tricks I Stole

Posted In: , . By Sid

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

 

The return of the warlord

Posted In: , . By Sid

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

 

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

 

To Mr. Bug

Posted In: , . By Sid

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.

 

Blood and Wine

Posted In: , . By Sid

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.

 

MySQL purge configuration

Posted In: , . By Sid

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.

 





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

 

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.



 

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!