About Archive Pages Tags

The Splat(*) Operator

18 May 2012

Learnt something new today.

When trying to split a multi-dimensional array, one could use the *(splat) operator.

a = [[1,2],[3,4]]
b = [[5,6],[7,8]]

In order to include b into a without breaking the array, you could do the following:

a = [[1,2],[3,4], *b]
# a = [[1,2],[3,4],[5,6],[7,8]]

And that’s the magic of *splat.


Net Neutrality comes to Netherlands

11 May 2012

This is a great step forward towards the goal of unrestricted and private internet access for all.

Netherlands has adopted a legislation that prevents Internet Service Providers from interfering with your internet connection. This means that Dutch ISPs are required by law to ensure data protection of your internet activities as well as prevented from tapping and intercepting your internet data.

This means that throttling of bandwidth by Dutch ISPs to prevent access or reduce access to internet services like Skype, or even Bittorrent is now considered illegal.

Singapore ISPs currently still practice bandwidth throttling to regulate internet speeds.

More at The Verge


Hello Tmux

28 Apr 2012

Been playing around with Tmux, the terminal multiplexer.

I’m now a convert.

Thanks Peter Cooper for the valuable introduction screencast. Really helped me a lot.

Now to try out remote pair-programming


Update: Amazon S3, Paperclip and a Curious Case of Singapore Buckets

25 Apr 2012

This is an update of my previous blog post, ”How to get Paperclip and AWS S3 Singapore and European Buckets Working”.

Since the post last year in December, Amazon had released its official AWS SDK for ruby which is now available as the ‘aws-sdk’ rubygem.

Paperclip had also made an update in its core to directly support AWS-SDK over marcel’s AWS-S3 gem.

This little guide is supposed to help you get quickly started uploading your images into S3 via Paperclip and the new gem.

This guide works for Rails 3.x and above.

Step 1: Get your Gems

# Gemfile
gem 'aws-sdk'
gem 'paperclip'

Step 2: Create your Paperclip Model

Step 3: Create your Amazon S3 credentials. In /config/s3.yml create:

#/config/s3.yml
development:
  bucket: <name>-dev
  access_key_id:
  secret_access_key:

test:
  bucket: <name>-test
  access_key_id:
  secret_access_key:

production:
  bucket: <name>-production
  access_key_id:
  secret_access_key:

Step 4: Rewrite your Paperclip Model to look something like this:

# app/models/somemodel.rb
  has_attached_file :photo,
     :storage => :s3,
     :s3_credentials => "#{Rails.root}/config/s3.yml",
     :path => "/:style/:id/:filename",
     :s3_host_name => "s3-ap-southeast-1.amazonaws.com"

As part of the move from aws/s3 to aws-sdk, there’s no longer a need to do interpolate for non-US buckets. The new :s3_host_name parameter is supposed to remove that need. The parameter :url hence is now no longer needed.

Step 5: ???

Step 6: Profit

And you’re done!

Again, I hope you guys find this useful. If you do, please pay it forward by sharing your own guides to getting things to work. You have no idea how incredibly useful they are to others.

[References]


The Perils of Freelancing

20 Apr 2012

Being a freelancer for the past 8 months had been one of the most exciting and simultaneously scary thing that have happened to me in a long time.

Even though I have been running my own small businesses since 2003, they have always been done under the safety and comfort of being a student and having some form of backup safety net that is my parents. I always knew that if something went wrong with the business, I’d still have enough money to eat and could always start again in the future. The only penalty? I’d have money for Starbucks.

Today, it is slightly different. I have financial obligations, parents to support, bills to pay and student loans to return. And all this while living in the cloud of unstability (of income). It is a little un-nerving. Not knowing when the next paycheck is coming or when my client is going to fire me, makes making financial commitments that much more difficult.

There’s always this lingering thought as a freelancer that I’m not making enough money and that maybe tomorrow, just tomorrow, I’ll have to resort to eating bread and water for breakfast, lunch and dinner.

I know that its not necessarily true, but its going to take a while to break out of that psychological frame of mind and this is the irony of freelancing. While it is supposed to free you to allow you more time to work on things that you enjoy, it also shackles you with the burden of making more money with what ever ‘free time’ that you have.

This journey is going to be a long and I better get used to it.


8 years of Gmail I'm finally out of space

13 Apr 2012

After my previous post about old emails and memories, I’ve received a notice from Google that my mailbox is almost full.

After a good 8 years, I’m finally out of space. All 7.7GB of it. It was a good run, and I’m actually surprised that I’ve even managed to stay within the quota for this long.

My “Hello Gmail” e-mail:

My first email on Gmail

Hi Mark, as it turns out, you were my first ;)

If you’re curious yourself, go to this URL:

https://mail.google.com/mail/#search//p99999

It will give you an ‘invalid search query’ error and then instantly loads the oldest page in your gmail for your reading.

Time to take out the credit card and start paying for my e-mails.

At $5/20GB, its still a pretty good deal.


Email: A Retrospective

12 Apr 2012

A friend of mine shared a screenshot of an email he wrote back in 2007 in a private WhatsApp conversation which got me interested to search back my own personal archives for the emails that I’ve used to send when I was much younger.

Luckily for me, I’ve been using GMail since it was still in beta and has never had the habit of deleting my emails. Searching through my sent emails through the years, I stumbled upon a couple of emails I’ve used to send to a private mailing lists and various other people back in 2005.

Its hilarious (at least to me) reading my writing style back then as well as my opinions on local current affairs. Comparing my views and actions then and now, so much has changed. You know the saying that you get mellow as you age, it appears that it may actually be true.

I was so much of an idealistic young 20-year-old, fresh into army, boy. I had great dreams, serious opinions on politics and I seemed to be on the verge of being totally disillusioned.

I don’t know if this change is necessarily a good thing but its refreshing to essentially ‘see’ 2005 me. Its also a little bit weird. 2005 was so long ago that it feels like I didn’t really write the things that I wrote.

But anyway, the question for you guys is, what is the biggest change that you’ve noticed about yourself from emails you sent out as long as you have kept records of?

Write your interesting comments below!


RSS Feeds for Jekyll

07 Apr 2012

Its been almost a month since moving this blog from Wordpress to Jekyll.

Note to self, to enable RSS feeds in Jekyll, follow the guide by the folks over at Recursive Design


We're lucky

05 Apr 2012

Looking at all the types of cases that our Members of Parliament receive on a daily basis and the hardships that their residents have gone through, it certainly puts things into perspective about how lucky many of us really are.

If you’re reading this, you probably already have a roof over your head, electricity powering your computer or device, clean and ample water supply to drink from and proper sanitation to relieve your self on.

But many others are not so lucky like you and I. No matter how tough the day was at work for us, it will eventually end and when it does, we would be able to go home, take a nice shower, and sleep on a nice bed.

Instead of relaxing in comfort after work, they have many other worries on their mind; Where are they going to shower? Where would they be able to sleep without rodents, rats or even the police harassing them?

So there’s no reason for any of us privileged few to complain about how tough our lives are. There are many others out there leading tougher lives and are still fighting to survive.

Let us be their helping hand and help them out however we can. Buy food for the homeless, give tips to the cardboard aunty who goes around trash-bins collecting cardboards and aluminium cans. Volunteer at a Soup Kitchen.

Give back to society for it has given us so many.


Don't estimate software

04 Apr 2012

Just read a great post by Dan Shipper which was posted on Hacker News.

In his article, Dan writes about how as humans we tend to be unable to estimate complexity and hence we make really bad estimation of how long it will take to do something.

Now let’s talk about software. When a non-technical person attempts to estimate software development time they come armed with their two basic heuristics: complexity based on size and complexity based on speed. But what they don't realize is that software is different. Software is by nature not physical. It exists in the ether. A tiny portion of it shows up on our computer screens from time to time. Because of this when it comes to building web apps (or any type of software for that matter) our basic heuristics break down.

I thought it was a very interesting read, especially for non-technical founders or business people looking to get an IT product/system out.

Countless times have I tried to explain to clients that is very difficult to give an estimate on the amount of time needed only to have them come out with a sweeping statement like,
"I'm sure it will only take you a few days to code!"

PS: noonespecial on HN wrote a brillant analogy that sums it up:
"You are in a closet, looking at a closed door. How big is the house?"