A place to breathe

Saturday, September 20, 2014

Why KL future MRT won't solve traffic issue, but eventually may find success

MRT is a successor of LRT. Did LRT solve KL traffic? No.

The idea of building MRT, if I understand this correctly, is actually to boost local economy through multiplier effect. It would solve public transport, but not for long. So it is correct that the traffic would be solved. But it is just a short term thing.

Why? Because when you have MRT, all people got so excited, they want to board MRT. Now, traffic at popular Klang Valley Highways such as LDP would become better. Less traffic, people enjoy.

Now, because the idea is to boost the economy, it is now the best time to prop up auto demand. Automakers would have some crazy deals and people would by more cars and drive car again. As car grow on the road, probably for a few years, the traffic will be built up. Ah.. now, we need another transport again. Maybe MRT phase 2. And we come back to where we were.

Efficient public transport is not enough. We need car control policies. I hate to say this but Singapore has done it well with their colorful number plates. If we don't want to be seen copying them, we can do something else.. like maybe, bumper stickers for weekend cars, etc.

Auto control policy. That's the key to success in controlling traffic. Less cars, less traffic. Simple as that.

But would that conflict with auto industry? That's why we still have traffic jams. Car makers. Yes. They're the one who make us buy cars and finally end up in traffic.

How to avoid ? Ask carmakers to expand overseas. Beat the Japanese, Germany, etc.

But then, when you ask, does that mean that we drive less in the future? Yes. Would you trade car control policies, which will ease traffic... but at the same time, lost your freedom to driving?

Yes? No?

Pick your choice. If you like to drive around, but at the same time can control your emotions during traffic jams, then you don't want to be controlled when or when not to drive. Means, you don't like car control policies.

If you are OK boarding public transport like most Singaporeans (I think), then, this is the time we ask for car control policies.

I seriously doubt that Malaysians like car control policies. They like to drive. They like to "Chilok". We love Touch and Go. We love cursing in traffic. It's our way of life. It defines our characters. It is also the time when we flash our new sport rims. Traffic jam rocks.

Which the reason why I think MRT project would be a success.



Wednesday, September 10, 2014

Development cycle for Middleman and Heroku

Just a few key steps for development cycle:

1. SSH to your VM:

cd /your/vagrant/vm
vagrant ssh

2. Develop in "source" directory

cd /yourapp/source

Edit index.html.erb, CSS, javascripts, etc.

3. Preview your changes locally

middleman build
middleman server -p 3000

4. Add your changes to git and commit to heroku

git add .
git commit -m "my awesome changes"
git push heroku master.

5. Rejoice and watch HBO !


Monday, September 8, 2014

Publishing your Static site on Heroku using Rails with Git, on top of Vagrant + VM

Why i use Heroku? Well, because it's said in the Middleman page that you can. (see my previous post on setting up Middleman),

No i am serious. I tried to run Rails by myself using Phusion Passanger and it is just .... horror.

So rather than doing it myself, i would trust heroku for now. For Now!

Ok enough. let's get working.

First, go signup at heroku.com, and after that, download Heroku toolbelt. Instead of downloading into your machine, go to ssh and install heroku there:

cd /your/vagrant/dir
vagrant ssh 
bash  (yes, do this please) 
wget -qO- http://toolbelt.heroku.com/install-ubuntu.sh | sh 

Heroku toolbelt is just a fancy words for some executables for Heroku. like installing some binaries somewhere in your directories. Now, you should have "heroku" executable so that you can login:

before your do anything, add the ssh key to your vm:
ssh-keygen -t rsa 

There are few steps that need to be done in order to run middleman page on heroku. One key thing is, you can use "puma" web server:

Heroku wants you to specify the "ruby" version so that it can grab the correct dependencies. If you fail to specify, most likely you fail to run middleman.

Now, let's push our middleman page to heroku:
git push heroku master 

Now when you push it, it will run your puma config that you specify in Procfile
web: bundle exec puma -p $PORT -e $RACK_ENV 

You should now see your middleman page at the specified URL given by heroku. if it returns error, use the following command and check why:

heroku logs



Saturday, September 6, 2014

Enter Middleman

Now that we have our Rails box setup, we can try a few simple static page deployment. Without complicating my life, I opted to run my static files on "Rackspace" server. You can think of "rack" as just makefiles for Rails. Rack can "compile" your static page and auto-publish for you. More on this later. An example of Rackspace server is Heroku.

So a brief overview of some latest web philosophy: Static page.

Because the traditional website queries database while loading, this is just bad. It makes the loading slower and you can loose out your audience attention. So some smart people came up with a smart solution: use static page with front end javascript to load things faster and interact up front with your audience, and at the same time, the static page go calls API of some remote server (that is, our Rails server in this context), to fetch some data.

The javascript front-end plays important role. It does some magical stuff like auto-update (as if the data exists, before even getting some data), do some animation or whatever. Up to you. The point is, don't wait for data to come before interacting with users. You can think of javascript as a receptionist who entertains you with a glass of lemon juice and giving you newspaper to read while waiting for her boss to come over to meet you to give you information on whatever you need from the boss.

Now that your know why we need static page with javascript front-end, we can turn our attention a slightly advance mechanism to "compile" our static page. The app is called "Middleman". Middleman enable us to generate static files and doing some cool stuff on static data and mark ups.

Now go to your vagrant box:

vagrant ssh 
cd /vagrant 

Install middleman

gem install middleman 
middleman init my_project
cd my_project

Check your gemfile inside my_project. don't forget to check your gem files to have :

'therubyracer'
'execjs'
'rb-inotify'

Actually, you can depend on your big Rails Gemfile but I just got errors this way. Run:

bundle exec middleman build 
bundle exec middleman server -p 3000 

Now, you need to run it with port 3000. This is because we have configured our box to display the port 3000.

After executing these commands, go to your browser:

http://localhost:3000. 

See something? Rejoice !










About Me

I'm currently a software engineer. My specific interest is games and networking. I'm running software company called Nusantara Software.