A bit of js flavor in ruby’s hashes

I’ve become frustrated writing a bunch of [:] lines working with ruby’s hashes.

hash = {:foo => 'bar'}   # so ugly...
=> {:foo=>"bar"}
hash[:foo]  # again...
=> "bar"

Sure there’s the openstruct thingy but it’s completely useless.

So i’ve gone against the rules and extended Hash, ending up in a dangerous (choose keys wisely) but so much more confortable syntax:

class Hash
  def method_missing(m)
    k = m.to_sym
    return self[k] if self.has_key? k
    super
  end
end

In action:

hash = {foo: 'bar'}
=> {:foo=>"bar"}
hash.foo
=> "bar"

Math problem

I came across an interesting math problem as I was reading Hacking, the art of exploitation v2. It took me a while to figure it out:

Use each of the numbers 1, 3, 4, and 6 exactly once with any of the four basic math operations (addition, subtraction, multiplication, and division) to total 24. Each number must be used once and only once, and you may define the order of operations; for example, 3 * (4 + 6) + 1 = 31 is valid, however incorrect, since it doesn’t total 24.

The illusion of phone security

My phone has become my everyday tool. I use it to check my mail, write blog posts, check my bank accounts, play games, perform transactions. I use it so much I often forget that it holds so much sensible data. If you were to get your phone stolen by someone, what passwords or accounts would he have access to? My phone checks my mail automatically on all my accounts. Very convenient. But I realized today that this convenience is an expensive asset. You think your paypal account is safe? Anyone can ask for your password to be reseted. If that someone has access to your automatically-checked mailboxes, he has access to your bank account, your facebook profile, and pretty much your entire digital life.

All of that digital life in the palm of my hands or in my backpocket is a danger I tend to overlook.

Some of you may have some locking mechanism such as a 4-digit phone pin… But really, when was the last time you made sure noone was looking as you entered your pin #… (even worse: most people choose the same pin # on their phone as their credit card pin #) I personnally think it’s better not to have any locking mechanism on your phone and behave like it has absolutely no security rather than believe in the illusion of its security.

I need to find another way to authenticate myself to my mail servers on my phone.

Eclipse current debug line background color

Tough find on another counter-intuitive ui design from the guys at eclipse: anyways it is in General\Editors\Text Editors\Annotations page. section “Debug Current Instruction Pointer”.

Make sure to mark both "General\Editors\Text Editors\Annotations\Debug Call Stack" and "General\Editors\Text Editors\Annotations\Debug Current Instruction Pointer" the the same color