Stop event propagation

Sometimes it’s annoying when say a checkbox has multiple actions binded to it which you are not aware of. Some parent elements may affect their child elements, thus making debugging and implementation so hard and confusing. Well, one technique can be used is to stop the event propagation. Basically the idea is, once the child element receives the event, as usual perform the appropriate actions, then stop the event from going up the DOM tree, thus avoiding all kinds of unexpected side-effects. ...

September 29, 2011 · 1 min · birdchan

Mighty Mouse's scroll ball

My mighty mouse scroll ball was fine for a month, but until recently scrolling up won’t work. At first I thought I was a software issue, but after updating everything and restarting osx, the issue remains. If that happens to you, don’t trash your mouse yet. Do this. Try pressing down the ball hard, then roll the ball a little in that position. Now try and see if your scrolling comes back. This works for me. ...

September 28, 2011 · 1 min · birdchan

osx mysql not working after a reboot

First and foremost, I am using Lion and running all latest updates as of today. I restarted my desktop system over the weekend as a usual practice. Then this morning I realized my local website isn’t working. Further tracking leads to MySQL not starting successfully. You can see the red text in the MySQL System Preference. Clicking on “Start MySQL Server” won’t help. At this point, ask yourself if you are using my.cnf. Usually, you don’t have to. But if you ever need to do any customization, you probably have copied this file over to /etc. If this applies to you, keep reading. Otherwise this fix may not apply to you. ...

September 26, 2011 · 2 min · birdchan

Splitting and joining files

So I bzipped a 40G file last night. I checked the timestamp and it took about an hour to finish with my 8-core cpu. Since the 40G file is a text file, the resulting file is only 1.4G large. Impressive, I went on to get my morning coffee, happy. Then when I got back, I realized a 1.4G file is still a little too big to transfer it at once. Network failure often happens, and I will need to chop up this file somehow. I did some searches and found that the old school way is to use the split command. I tried that but I got these funny xaa, xab, xac files… ok, fine, I can provide prefixes to them, but still. It’s not intuitive to know how to combine these files back. I suppose a “cat * > file” will do. But what’s the resulting filename? How am I supposed to remember after even just one day? I suppose I can keep a readme file… man, this is last century! ...

September 22, 2011 · 2 min · birdchan

Running bzip2 with multiple cores

I was trying to bzip a 40Gb file and it was taking forever. I then checked the Activity Monitor. It turns out the default bzip was only using one cpu core!!! If you really want to make use of your other cpu cores while doing bzip’ing, here is a nice way I found. Go to http://www.zhuk.fi/pbzip2-action/ and download PBZIP2 Automator action and workflow/service for Mac OS X. Once you have the tbz2 file, double click, then you will see a folder with two files insides. Double click on each file to install the necessary programs. ...

September 22, 2011 · 1 min · birdchan

How to cancel a Wells Fargo personal check?

This is how to cancel a Wells Fargo check as of Sept 21, 2011. Login to your WF account. Click “Account Services”, it’s among the top tabs the 5th one counting from the left. On the next page, Under “Account Services”, find “Stop Payment on a Check”, should be the 9th link. Then just follow the steps. You will need to have the info on the check #, the amount, payable to, and signed date. ...

September 21, 2011 · 1 min · birdchan

selecting checkboxes

Say you have a few checkboxes, defined as below: Item 1 Item 2 Item 3 Basic stuff. Now you want to get those that are checked. In PHP $cb_arr = $_POST["items"]; In javascript, or jquery var cb_arr = $(".my_cb:checked"); Notice the cb_arr above is not a js array. You need to use .each() to iterate through the items. To pass that to php via ajax, you can serialize it like this: var cb_arr_str = $(".my_cb:checked").map(function() { return this.value; }).get().join(','); My point here is this. The ids turn out to be quite useless when dealing with checkboxes. ...

September 16, 2011 · 1 min · birdchan

JQGrid Word wrap

While playing with jqGrid, I have no idea why word wrapping a line is so difficult to do. Here is a few steps to enable word wrapping in the cells. Open up ui.jqgrid.css Search for .ui-jqgrid tr.jqgrow td Change “white-space: pre;” to “white-space: normal;” You are done! ;) Ref: http://2centtech.blogspot.com/2009/12/jqgrid-header-and-cell-value-word-wrap.html

September 12, 2011 · 1 min · birdchan

US Debt Crisis

[youtube &w=560&h=345]

September 9, 2011 · 1 min · birdchan

File transfer

Ref: http://xkcd.com/949/

September 9, 2011 · 1 min · birdchan