Why should a person buy a computer?

An excellent interview with Steve Jobs by Playboy.
“Why should a person buy a computer?” the interviewer asks.

Remember, it is 1985. Computer is not as common and not as advanced as today. Normal human reaction toward changes is to resist, hence we fall back to what we know best, what we have been doing all along.

Whenever a new technology shows up, we quickly proclaim, “Who would want that? Who would buy that?”
“I can balance my checkbook faster by hand than on my computer. Why should a person buy a computer?”
We often overlook two things. Technology will improve and human will adapt, eventually they meet halfway. What perceived as totally unnecessary can become a necessity. Before the creation of mobile phone, we have no problem tolerate with waiting for someone on a street without the mean to check if that person is stuck in a traffic jam or just around the corner. Heck, we don’t even feel the need to tolerate; we simply don’t know there are other ways around.
Now, in hindsight, it felt comical that Steve Jobs have to convince the interviewer why someone needs a computer; some of the arguments are eerily prophetic though.

“So far, that’s more of a conceptual market than a real market. The primary reasons to buy a computer for your home now are that you want to do some business work at home or you want to run educational software for yourself or your children. If you can’t justify buying a computer for one of those two reasons, the only other possible reason is that you just want to be computer literate. You know there’s something going on, you don’t exactly know what it is, so you want to learn. This will change: Computers will be essential in most homes.”

“The most compelling reason for most people to buy a computer for the home will be to link it into a nationwide communications network. We’re just in the beginning stages of what will be a truly remarkable breakthrough for most people—as remarkable as the telephone.”

“A hundred years ago, if somebody had asked Alexander Graham Bell, “What are you going to be able to do with a telephone?” he wouldn’t have been able to tell him the ways the telephone would affect the world. He didn’t know that people would use the telephone to call up and find out what movies were playing that night or to order some groceries or call a relative on the other side of the globe. ”

I really like the invention of telephone as an example. Sometime even the inventor wouldn’t be able to tell us how his invention will change the world, how people will use it eventually, but just a sense that something very big is going to happen with it.

“I can balance my checkbook faster by hand than on my computer. Why should a person buy a computer?” You can replace “balance checkbook” and “computer”, and you get all the hysterical reaction towards any new tech/gadget/tools nowadays. We are too eager judging something new with our mind that already been clouded by the current state of how we do thing, and we forgot to just allow the new technology to ferment, to evolved, to let everyone get over the inertia and embrace it.

jekyll ruby

Jekyll on Windows

There are already guide out there to get Jekyll installed on Windows machine.

I have problem to start it after installation though, a long list of errors follow,

D:\ruby_projects\olla\jekyll serve
Configuration file: D:/ruby_projects/olla/_config.yml
Source: D:/ruby_projects/olla
Destination: D:/ruby_projects/olla/_site
Generating... Liquid Exception: cannot load such file -- yajl/2.0/yajl in _posts/2013-10-22-welcome-to-jekyll.markdown

And of course, solution is out there as well, make sure to read till the very end of the thread. Pre-compiled gem is not Ruby 2.0 compatible, if there is already x86-mingw32 version of yajl installed, make sure to uninstall it then follow these steps

D:\ruby_projects\olla>gem install yajl-ruby --platform=ruby      
Fetching: yajl-ruby-1.1.0.gem (100%)                             
Temporarily enhancing PATH to include DevKit...                  
Building native extensions.  This could take a while...          
Successfully installed yajl-ruby-1.1.0                           
Parsing documentation for yajl-ruby-1.1.0                        
Installing ri documentation for yajl-ruby-1.1.0                  
Done installing documentation for yajl-ruby after 2 seconds      
1 gem installed

If one decided to do development works in a windows machine, by faith you have to jumped over lot of hoops to make thing happen. Latest pygments gem just refuse to work

D:\ruby_projects\olla\jekyll serve                                                                                                 
Configuration file: D:/ruby_projects/olla/_config.yml                                                                              
            Source: D:/ruby_projects/olla                                                                                          
       Destination: D:/ruby_projects/olla/_site                                                                                    
      Generating... C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/posix-spawn-0.3.6/lib/posix/spawn.rb:162: warning: cannot 
  Liquid Exception: No such file or directory - /bin/sh in _posts/2013-10-22-welcome-to-jekyll.markdown

A little search show the solution in StackOverflow, just uninstall the latest pygments gem, and install version 0.5.0 as suggested. Tada, you can jekyll serve and point to localhost:4000 finally.

Now compare all those steps with this one

Can’t help but feel like developing in Windows environment waaaay more fascinating. Ha.

ruby ruby on rails

Testing in Sublime

Following railstutorial again, to strengthen my rails basic and pick up new shiny things in rails 4.

Getting sublime to run test directly is quite awesome, I mean you just need to highlight part of the test you wish to run, cmd + shift + R, boom you got your test result, all without needing to leave the comfort of sublime. Sweet.

On the next day though, suddenly it refuse to run, complaining

/bin/sh: rspec: command not found

Stackoverflow answer here go for this one. But a simpler solution below work for me, just go to ~/.config/sublime-text-2/Packages/RubyTest/RubyTest.sublime-settings file and set configuration option “check_for_rvm” to true and you have your mojo back.


python ruby

Trick that work in irb and python shell

This irb tip is from Natasha the Robot. Often we forgot to assign an expression to a variable, you could of course use up arrow to retrieve last command and then move all the way to the front, add a variable and equal sign to it, but that is a lot of troubles.

An easy way is just assign a variable to underscore, like this

text = _

Then you have your previous expression assigned to a variable called text. Magical.

What is more surprising is that just found out that this magical trick works the same in python shell! Even more magical.


Open up another terminal session at the same path

I often needs to open up multiple Terminal session on the same path, example, one to launch rails server, then another to actually working with it. There are a few tricks on the internet, but most involved writing some applescript to achieve that.

I prefer a straightforward solution hence I keep on looking, finally found this piece in the trusted stackoverflow as usual.

Just need to type

open -a Terminal "`pwd`"

Just take note that it is a backtick and not the single quote mark, then you should have another terminal session open up at the current path.

Even easier in Windows Command Prompt, just type “start” at wherever you are, another cmd windows pop up at the same directory. Wow.


Something I learn from a boring talk

Attended an information sharing session this morning.

One problem stood up. The person conducting the session is a bad presenter, not very fluent in English, and speaks with very heavy accent. Most of us are at a lost on what he tries to convey. Twenty minutes into his talk, half of the audiences already give up on trying to understand at all. Some play with their phone, some doodling on a paper, some just fall asleep.

The usual lessons learn here is presentation skill is really important. The thing strike me today is, how easily we give up even when those information is for our good. “They should present it better”, or “They should find someone with better English”, we often complain. It is not our fault that we don’t understand what he said, and we are fully entitled to turn off our attention. At the end we are the one wasting time pretending we are listening, but gain nothing at all at the end of the session.

Just as my mind about to wander around, I decided to stop it, and try, really try to figure out what he is trying to say. Looking at his slides, try to pick up the words he say, try to really pay attention. Then almost magically his words become slightly clearer, his talk becomes slightly more interesting, and instead of wasting two hours being mindless, I actually learn something from it.

If you decide to make the best out of a situation, then you can learn something from almost everyone. My thought.

ruby on rails

Getting paperclip, heroku and aws s3 non-us region bucket working together

As I have found out earlier, images uploaded via paperclip to heroku will go missing after each push of code to heroku.

One way to keep images uploaded via paperclip permanent is to use a 3rd party storage service like s3 or keep it on a ftp server. I went for s3, mainly want to learn dealing with Amazon Web Services, might turn to ftp server later on if needed. If you would like to go the ftp server way, there are gem like FTP Storage for Paperclip and PaperclipFTP to make life easier.

  1. Add paperclip and aws-sdk to your gemfile
    gem 'paperclip'
    gem 'aws-sdk'

    Follow by the usual

    bundle install
  2. To start working with s3, first you need to signup for an aws account.
  3. Once you have an account, login then go to My Account/Console > AWS Management Console
  4. Select s3 from a host of services
  5. Create a bucket
    “A bucket is a container for objects stored in Amazon S3. When creating a bucket, you can choose a Region to optimize for latency”, that is what mentioned in the guide, so I chose Singapore as it is closest to my location.
    Now if you have chosen “US standard” region, things will work out much straightforward, any non-us region will need some tweaks in the configuration. The documentation in heroku did mentioned that some international users may need to override the default URL structure and place the bucket’s name “domain-style” in the URL. Following that guide didn’t solve my problem though. I googled around, found a few more useful guides

    • Stackoverflow on setting env variables
    • Techspry on s3 configuation
    • DCChua on how to get Paperclip and AWS-S3 Singapore (and European) buckets working

    Coupled with the heroku documentation, I finally get my setup working combining them and change a bit here and there.

  6. Get your aws access key and secret access key from the Security Credential option
  7. In ./config/production.rb, defined this environment variables
      config.paperclip_defaults = {
    			    :storage => :s3,
    			    :s3_credentials => {
    			      :bucket => ENV['AWS_BUCKET'],
    			      :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
    			      :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
    			    :path => ":class/:id/:basename_:style.:extension",
    			    :url => ":s3_sg_url"
  8. Then set them by doing these in terminal from your apps
    heroku config:set AWS_BUCKET=your_bucket_name
    heroku config:set AWS_ACCESS_KEY_ID=your_access_key_id
    heroku config:set AWS_SECRET_ACCESS_KEY=your_secret_access_key

    You can of course set these values in the ./config/production.rb file, but then it is not protected if your repo is not private.

  9. In ./config/initializer, create paperclip.rb, and add these lines
    Paperclip.interpolates(:s3_sg_url) do |att, style| 

git commit, push and then push to heroku, images uploaded from your apps should now store in s3.


why attr_accessor

I keep bump into this problem, where I pick up some basic long ago, after a while, get too used to it and forgot the reason why something is done in a particular way.

If I have written about it, then I have a better understanding and longer memory. Like the collection_select method which I drawn a illustration and post about it sometimes ago, it stuck in my memory till now.

This idea is not really new, you learn by teaching, or at least write or blog about it. All that help to clarify your thought.

And so, to help me internalized the reason behind attr_accessor, I quickly googled and read thru this from stackoverflow, yet, am gonna write about it as a process of internalization. Ha.

You keep writing attr_accessor, one day you totally forgot why we did attr_accessor at the first place. Why attr_accessor?

class Human
  def name=(str)
    @name = str
  def name

You do that to assign variable to a value, then call the value. This is common repetitive task. Programming is all about eliminating repetitive tasks. So you can do this in ruby

class Human
  attr_reader :name
  attr_writer :name

where attr_reader replace name method part, and attr_writer replace the name=(str) method. Still, often attr_writer and attr_reader often come in pair, why not just do it in one step.

class Human
  attr_accessor :name

I created a diagram hopefully could better illustrate this in one glance.

Evolution of attr_accessor
Evolution of attr_accessor

That is it. Already felt that now this tie deeper into my memory.


A marathon, not short sprint

A marathon, not short sprint
A marathon, not short sprint.
Image from stock.xchng, author

I wish by now I have something positive to write as a fitting part 2 to the post wrote last year, you know, happy ending or something like that. The sad fact is, after numerous try, despite seemingly getting closer each time; I am still here one year later, still looking every possible ways to work with rails or web development work, full-time, oh, actually even part-time (So ping me if you have any web development works, especially ruby or ruby on rails stuff)

I have Interviewed for 4-5 opportunities, learned a lot, and got to meet some local startup people, developers, etc *but* none of that lead to anything, so far.

My first ever rails freelance gig was developing a simple web apps for a client. It was cancelled like 3 weeks into development. The client decided to look for a local developer instead. He said it is not my problem just that he preferred to work with a developer from local. One year down the road, the site is still not up. I guess the client decided not to pursue with his idea anymore.

Then another freelance gig come knocking, I was required to sign a NDA even. I was so thrilled with the opportunity, their idea is cool, it is like another facebook in the making. The core teams were working on the main features, and I was told that I would involve real soon. Now it is almost a year later, nothing happen still, haven’t heard any news from the team, their site haven’t changed for months. Not sure if they still working on the project.

Finally a local startup opening for Rails, not freelance gig but a chance of full-time employment, wow! So off I go for interview, we overcome the usual stumbling block by cutting down my salary (of course, not before serious discussion with the stakeholder – my wife, always grateful for her understanding), I offer to work with them for a few weekends in advance, so both sides can see if we are a fit. Think you can guess the outcome by now. 2 weekends down, and I got a sorry message, it is not something to do with me, but their internal decision. That is what I’ve been told at least. They did offer to pay up for my time, though I rejected.

There are one or two more freelance opportunities in between, that didn’t materialized. The common theme here is, “It is not your problem really”. The project just got cancelled, or stagnant, or fading out, or because of some internal decision I was not hired. But I refuse to buy the “It is not your problem” statement. There is no benefit in believing it is just plain bad luck, there is no benefit in believing it is just some internal decision to not hire. That is like admit defeat and say, okay, there is nothing I can do with it now. I can only work on things that I can control, which is *me*. I haven’t made myself so good, that there is no excuse at all not to hire me, of course that is my problem.

Stay positive, working on my own projects, writing even more codes, reading even more codes. Keep doing all that. This is a marathon, not short sprint. Even if no one take a chance on me, the effort I put in will lead me to somewhere.

I have to believe in that, cause there aren’t any other options anyway. Ha.

ruby on rails

Uploaded images go missing in heroku

No doubt heroku is the greatest thing since sliced bread, with easy deployment and stuff, and it is free to start with. Perfect for stingy developer like me. So I am working on a rails apps, deployed to heroku, with paperclip for image upload. Things work fine, except images I uploaded keep on missing. I thought heroku wouldn’t store image for free user, ha.

A quick search around internet, sure enough it is stackoverflow come with an answer top in the list. It turn out that only images in the commit and pushed to heroku are kept, example logo or icon used in the apps. Uploaded images will be removed with each push to heroku, clearly images uploaded via paperclip fall into the latter category.

Solution is to use a 3rd party storage, like Amazon Simple Storage Service. Of course, aws is free to start with as well, a free account includes 5Gb storage, 20k Get requests, 2k put request, yada yada, another great thing for stingy developer, hurray!