Archive

Archive for the ‘Uncategorized’ Category

Nexus one for existing customers

January 9th, 2010 mahesh No comments

If you are an existing t-mobile customer and are planning to get a nexus one, you probably know by now that you have to pay $279 and not $179 (which is for new customers only). I just can not understand the reasoning behind this. Anyway, since my contract has expired, I thought I can just get on a new plan with a new account if required and get the phone for $179. Guess what, you can’t even do that. After researching on various forums and piecing together, I got my nexus one for just 20 bucks more instead of shelling out 100 bucks!

So, what I did was, I called  tmobile and told them I want to cancel the account and go to another network for 3 months and come back as a new customer. That way I save 100 bucks. I was ok waiting for 3 months to get my hands on that phone. I am excited about that phone but not THAT desperate. It is after all just a phone. But guess what, tmobile was like, it anyway costs 35 bucks or so to activate when I come back as a new customer, so they agreed to give me $45 credit. So, I really put in only 20 bucks more and got the phone! Isn’t that cool? :) Let’s see when google will ship it to me.

If you are an existing customer, try that and see if it works for you as well or if there is any other workaround, I will be curious to know! Well, not really, I already got mine ;)

Cheers,
Mahesh Murthy!

Categories: Uncategorized Tags:

Beyond my understanding!

October 30th, 2009 mahesh No comments

I had a bug in my application where the calculation was a little off from expected. After putting debug statements, I narrowed it down to an interesting behaviour in ruby. Fire up irb and try it out yourself!

irb(main):001:0> (6.725*60*24).to_i
=> 9684
irb(main):002:0> (6.725*24*60).to_i
=> 9683

wtf?

Categories: Uncategorized Tags:

Annoying rails date validation

September 13th, 2009 mahesh No comments

I spent a good amount of time breaking my head over why a date field wasn’t getting set in one of the model after retrieving it’s value from a form. It turns out that if you pass a random string and not an actual date, rails will silently assign a nil to that field without complaining.

For example, I have a class Fact with date fields called from and to. Notice what is happening.

Loading development environment (Rails 2.3.3)
>> fact = Fact.new
=> #<Fact id: nil, from: nil, to: nil, timeToCount: nil, val: nil, remarks: nil, cp_detail_id: nil, created_at: nil, updated_at: nil>
>> fact.from = "foo"
=> "foo"
>> fact
=> #<Fact id: nil, from: nil, to: nil, timeToCount: nil, val: nil, remarks: nil, cp_detail_id: nil, created_at: nil, updated_at: nil>
>> fact.from = DateTime.now
=> Sun, 13 Sep 2009 09:53:29 -0600
>> fact
=> #<Fact id: nil, from: "2009-09-13 09:53:29", to: nil, timeToCount: nil, val: nil, remarks: nil, cp_detail_id: nil, created_at: nil, updated_at: nil>

script/console

Loading development environment (Rails 2.3.3)

>> fact = Fact.new

=> #<Fact id: nil, from: nil, to: nil, timeToCount: nil, val: nil, remarks: nil, cp_detail_id: nil, created_at: nil, updated_at: nil>

>> fact.from = "foo"

=> "foo"

>> fact

=> #<Fact id: nil, from: nil, to: nil, timeToCount: nil, val: nil, remarks: nil, cp_detail_id: nil, created_at: nil, updated_at: nil>

>> fact.from = DateTime.now

=> Sun, 13 Sep 2009 09:53:29 -0600

>> fact

=> #<Fact id: nil, from: "2009-09-13 09:53:29", to: nil, timeToCount: nil, val: nil, remarks: nil, cp_detail_id: nil, created_at: nil, updated_at: nil>

When I assign a value foo, it doesn’t complain but just assigns a nil.  Only if it had complained, I could have saved so much of my brain cells and time. Sigh …

Now, you might ask why am I assigning a foo instead of date. Well, I am still developing and was just putting random values to get the form to work  :P

Anyway, I hope it will help some nOOb like me someday.

Have a good week,
Mahesh Murthy

Categories: Uncategorized Tags:

Upgrade your wordpress plugin

July 8th, 2009 mahesh No comments

If you use wordpress plugin for your website, make sure you are using the latest version of it. If you are lazy like me, chances are that sooner or later your site will be hacked. Yeah, mine was hacked because I had not upgraded in ages. Thankfully my database was intact, so I didn’t lose anything. Here is a good read: http://ocaoimh.ie/did-your-wordpress-site-get-hacked/

have a good day,
Mahesh Murthy

Categories: Uncategorized Tags: