aasm_event :do_life

Record of MPs absent so far in the 11th Parliament (Singapore)

Over the past week after work, I've been working on a little side project to hone my ruby scripting skills and I'm ready to release it today.

I've written a script in ruby to parse through all the parliamentary reports from http://www.parliament.gov.sg/Publications/votes_11thParl.htm (at of time of processing 27th April 2010 report is the latest) and extract out the name, ward and date of absentee from each individual report and dump it into a SQLite database.

Some interesting facts:

1) Since the 11th Parliament started till the sitting on the 27th April 2010, there has been 928 absentee records.

2) The top 5 absentees in Parliament are:

Mr Lee Kuan Yew - 46
Dr Balaji Sadasivan - 38
Prof. Thio Li-ann - 38
Dr Loo Choon Yong - 28
Mr George Yong-boon Yeo - 25

3) Mr Low Thia Khiang (Hougang - Workers Party) have not been absent since the 11th Parliament commenced. Mr Chiam See Tong (Potong Pasir - Singapore People's Party) 13 times. Ms Sylvia Lim (NCMP - Workers Party) 6 times.

4) The top 5 wards which has the highest number of absentees in Parliament are:

Nominated Member - 146
Tanjong Pagar - 90
Pasir Ris-punggol - 75
Ang Mo Kio - 69
Aljunied - 62
West Coast - 56

5) The top 5 Parliament sittings with the most number of absentees are:

12th April 2007 - 28 (33.333% of Parliament)
24th March 2009 - 24
19th August 2007 - 23
20th August 2007 - 23
22nd Jan 2008 - 22

I'm releasing the database under the Creative Commons 3.0 license, so you are free to use the data for any purpose (analysis/data visualization/etc.) without any restriction :) Although I'd love it if you would share with me where are you using the data :)

Grab it in either formats:

SQLite

CSV

Update: Here's my ruby script for those who are curious. (If you run this on your own, you might notice that RAdm Lui's records are slightly misnamed. I had to manually edit those records to clean up the name for the released database. If you can improve on the script, I'll appreciate it too)

Disclaimer: Due to the nature of a computerized and automatic processing, there may be some inaccurancies in the data collected, although as far as I know it, the initial parsing doesn't seem to output any errors/discrepancy. If you've found something wrong, please contact me so that I can fix it.

Ubuntu - Setting locale failed? Reinstall packages then!

A quick note to self reminder.
If your newly minted Ubuntu box gives you the following error:

perl: warning: Falling back to the standard locale ("C").</div>
<div>
<div>perl: warning: Setting locale failed.</div>
<div>perl: warning: Please check that your locale settings:</div>
<div>
<span style="white-space: pre;"> </span>LANGUAGE = (unset),</div>
<div>
<span style="white-space: pre;"> </span>LC_ALL = (unset),</div>
<div>
<span style="white-space: pre;"> </span>LANG = "en_SG.UTF-8"</div>
<div>    are supported and installed on your system.</div>
<div>

Just reinstall the packages by:</div>
<div>
<div>apt-get install --reinstall language-pack-en

 

It should fix the problem

My thoughts on YouthQuake 7 - Can Young Singaporeans Afford Public Housing in Singapore

Some thoughts from YouthQuake 7 - CAN YOUNG SINGAPOREANS AFFORD PUBLIC HOUSING IN SINGAPORE TODAY?

Speakers:
Mr Leong Sze Hian
Mr Gerald Giam
Mr Pang Eng Huat
 
Mr Pang started the discussion off by sharing his experiences and thoughts on the current state of HDB housing and why it shouldn't be considered as an asset enchancing class. I didn't take notes so I probably have missed out quite abit of his points but the most memorable takeaway I got from him was how he reminded us that while the government encourages us to sell our property and upgrade to a more expensive flat-type, a home is more than just numbers but a accumulation of memories and experiences that is priceless.
 
Mr Giam came onto the podium to discuss his proposals to help make public housing more affordable for Singaporeans. I'll talk more about his proposal shortly below. I thought it was really friendly of Mr. Giam to approach every member of the audience personally to chat with them before the forum started formally. I look forward to being able to interact with you more some day.

Mr Leong, ever the statistician and analyst, shared with his thoughts on the statistical impact of some of the policies made in the recent years, as well as to discuss on the topic of the lack of transparency which prevents political parties from being able to come out with better proposals/solutions. You can read some of the articles he penned recently which he mentioned and quoted from the forum. (I have linked it at the bottom of the page)

I'm going to backtrack a little to point out Mr. Giam's proposals as I think that it is something that we should think about.


Mr Giam made a couple of proposals, namely for:

1) HDB to refocus back on its mission to provide affordable housing for Singaporeans, rather than on increasing value of their homes.
2) The creation of a new class of HDB flats that is pegged to the annual median household income of the relevant flat type (ie. 2 room, 5 room etc.) by 3 times.


He calls this new type of HDB flats as 'Affordable Class' and he proposes that this scheme of flats will run along side with the existing flats.

This will be done by selling AC flats at prices pegged to three times the relevant median annual household income. For example, if the median annual household income of all current 3-room flat owners is $32,000, the median price of a 3-room AC flat should be $96,000, with up to 25 per cent adjustment made for location, orientation and storey height.

He acknowledges that with the introduction of the AC flats, property value for existing flats (not under this scheme) may dip slightly but he maintains that this is for the better in the long run.

As for the cost of this scheme, without transparency from HDB about the cost of building each flat, it is hard to compute the exact cost. However, based on HDB’s current selling price of new 3-room flats, each AC flat will be at least $45,000 cheaper. Depending on the number of such flats that may be sold each year, we could be looking at the government spending a few hundred million more per year to implement this scheme. In my opinion, this is a worthwhile expense—and definitely affordable for the government!

During the Q&A session, many interesting new suggestions came from the floor.

Donaldson Tan from New Asia Republic suggested that there should be the creating new segments in the private housing market by allowing communities to pool together resources and form a housing association to build homes collectively like in the United Kingdom.

Housing Associations in the UK are independent and non-profit social organizations that build low-cost houses for the poorer segment of society, giving them an option to either rent a unit or opt to join a shared equity scheme where they can purchase a share of their home even though they cannot afford the mortgage.

I agree with the principal of having communities pool resources to build housing although I'm not too sure if it would be feasible in urban and land-scarce Singapore.

Another member of the public suggested that another alternative is to look at HK's public housing schemes which heavily subsidizes the poor for rental apartments.

 
There were also many suggestions and questions from others in the audience but unfortunately as I didn't have my notepad with me to write notes on, I couldn't remember most of it.
 
All in all, I thought this forum was extremely engaging and I liked how the audience were very participative with their ideas on how we can improve public housing in Singapore. I really like Mr. Giam's proposal as it seems to be something that can be implemented easily within our system although I do have a couple of questions like how the figure of pegging 3x the annual median household income was determined whether a more detailed analysis of the financial impact of such a scheme can be obtained.

I enjoyed myself and I look forward to attending the next YouthQuake. Thanks WPYW Exco!

[2] Singaporeans' rights to social security and public housing - Leong Sze Hian

There's no difference anymore

Media_httpdilbertcomd_gzmcx

Sometimes its funny how even though you're in management (of a extremely small startup), you still experience the same thing.

Getting Integrity up and running w/ email notification and test database raking

Screenshot-new_project_integri

After spending a couple of hours trying to get integrity setup, I thought I'll
share and document my process for future reference.

So what is Integrity?

From their website:

"As soon as you push your commits, Integrity builds your code,
run your tests and makes sure everything works fine. It then reports
the build status using various notifiers back to you and your team so
everyone is on the same page and problems can be fixed right
away."

In a nutshell, Integrity is a Continous Integration Server which helps to ensure that your codebase is
properly integrated and working at every stage of your development.

Integrity's website> is pretty
straight-forward and simple to understand, head on over to their
webpage at http://integrityapp.com and follow the instructions on the
page. The bottom part of the page is pretty confusing so what I
basically did was to:

 
$ gem install bundler 
$ git clone git://github.com/integrity/integrity 
$ cd integrity 
$ git checkout -b deploy v0.4.1 
$ bundle install 
$ bundle lock 
$ rake db 

Open up the default init.rb and add in the following lines in
between the Integrity.configure block

 
c.user "username" 
c.pass "password" 

What this does is tell Integrity to set a HTTP Authentication check
for the application so that only people with the proper credentials
can access your application.

So here's where the confusion starts. The tutorial over at
Integrityapp.com makes no mention about how to get your database.yml
file copied into the builds/ directory. If you're like most developers
(and I hope you are), your database.yml file will not be injected into
your repository, so how do we setup Integrity such that it would be
able to copy the proper .yml file and configure it according to your
settings?

First, setup a rake task that does the magic of copying. In your
/lib/tasks create a .rake file and copy the following:

 
namespace :test do 
 task :move_test_db_config do 
   require 'ftools' 
   File.move(RAILS_ROOT+"/config/database.yml.test", 
RAILS_ROOT+"/config/database.yml") 
 end 
end 

This rake task will copy the file database.yml.test to database.yml,
so you're going to need to create a database.yml.test file in your
/config directory.

You don't have to put in other information like your
development/production settings since all integrity needs is your test
environment.

Here's mine:

test: 
 adapter: sqlite3 
 database: db/test.sqlite3 
 pool: 5 
 timeout: 5000 

Yeah, dead simple.

With that said and done, all you need to do now is to start the app,
access the app, and create a new project.

In the 'build script' field, replace it with "rake
test:move_test_db_config" and you're done!

As for notifications, just follow the instructions at Integrity :)

protip: Make sure you give the user that is running the webserver
(apache/thin) access to the remote git repository that you want to
track. Use SSH key authentication for best results.

Source:
[1] http://integrityapp.com
[2] http://locomotivation.squeejee.com/post/109227509/ruby-on-rails-integration-t...

Getting your git repository to send out e-mails upon receiving updates

Here's a useful tip for those who wants to be updated everytime someone pushes code into a shared git repository.

There's a hook that comes with git that sends out an email to a defined e-mail address with information about a commit that has recently been pushed. It tracks the author, the commit message, the commit log as well as displays the changes made.

To get started,

1) In your /remote_git_repo_path/.git/hooks (depending on how you configure your repo, you may not have a '.git' directory),

 mv post-receive-sample post-receive chmod +x post-receive 
Your post-receive should look something like this:

 #!/bin/sh 


# An example hook script for the "post-receive" event. 
# "post-receive" script is run after receive-pack has accepted a pack
# and the repository has been updated.  It is passed arguments in through 
# stdin in the form 
# For example: 
#  aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master 
# see contrib/hooks/ for an sample, or uncomment the next line and # rename the file to "post-receive".
#. /usr/share/doc/git-core/contrib/hooks/post-receive-email 


3) Ensure that you have the file /usr/share/doc/git-core/contrib/hooks/post-receive-email. If you do, uncomment the line in your post-receive file

 #. /usr/share/doc/git-core/contrib/hooks/post-receive-email . /usr/share/doc/git-core/contrib/hooks/post-receive-email 

4) If you don't have it, don't fret, copy the contents from here into a readable directory and call the file 'post-receive-email'. Point to that file with its full path in your post-receive script.

5) Once that done, all you need is to configure the repository to send the email to the correct address. Still in your remote repository, edit the .git/config file and add the following:

[hooks]
mailinglist = whatever@email_address_here
showrev = "git show -C %s; echo" 

git show -C %s;echo 
# will ensure that the full git diff will be embedded in the e-mail 

And you're done! Now in your local repository, make your changes and push it up. You should receive an e-mail in your configured e-mail address.

Extra Tip - To get rid of the 'UNNAMED PROJECT' line appearing in your email subject line, in your remote repository edit .git/description with whatever you want to appear.

Hope this helps :)

Config files on github

http://github.com/davidchua/config-files

Finally decided to upload my vimrc, gitconfig and bashrc config files onto a repository on github.

If you guys got any extra tips or must-have configs, please share :)

Preventing accidental discarding of git commits

The other day, a colleague of mine accidentally force-pushed his commits onto our remote git repository, accidentally discarding my one day's work of code commits. To his defence, he was pretty new to git and Git for Windows made it so easy to do things like this.

That incident made me realize that I needed to enforce a stricter git workflow to ensure things like this doesn't happen again. After talking to the guys over at #git (irc.freenode.net), most recommentation was to activate the update git-hook which was supposed to check if the code was force-pushed before accepting it into the repository. I've since added that hook but I'm curious, how are you guys managing your git repository and enforcing your workflows?

Configuring Gmail SMTP with Actionmailer

Just a couple of reminders for myself, in case I spend wasted time trying to get gmail smtp working on actionmailer again.

To get your ActionMailer configured for gmail:

# in config/environments.rb 
 # add the following lines AFTER your Rails::Initializer.run block

  email_settings = YAML::load(File.open("#{RAILS_ROOT}/config/email.yml"))

  ActionMailer::Base.raise_delivery_errors = true
  ActionMailer::Base.perform_deliveries = true
   ActionMailer::Base.delivery_method = :smtp
  ActionMailer::Base.smtp_settings = email_settings[RAILS_ENV] unless email_settings[RAILS_ENV].nil?

# in config/email.yml (if its not there, create it)
 
# add the following for each rails environment

development:
  :enable_starttls_auto: true
  :address: smtp.gmail.com
  :port: 587
  :authentication: :plain
  :user_name: <whatever@domain.com>
   :password: <password>
  :domain: gmail.com

# remember the extra ':' before the yaml key. This is what wasted my time

And magic.

There's no need to install any new smtp/tls libraries as there's already built in support for tls authentication within ActionMailer. Just make sure to set 'enable_starttls_auto' to true.

Comparing elements of two arrays for similarity

When checking two arrays for similar elements, use:

(a & b).any? or (a & b).empty?

* 'or' in the snipplet above, is not an operator, but a geniune 'or'

From The Momoro Hoax

14
To Posterous, Love Metalab