AngularJS tutorial

Here is a very nice step-by-step intro tutorial for AngularJS, from the AngularJS official site. You will see how the angularjs code is added to the sample project and for what purpose. I highly recommend this tutorial for anyone wanting to try out AngularJS. http://docs.angularjs.org/tutorial At the end of the tutorial, there are more useful links for development. For example, the angular-seed project, and the AngularJS cookbook. Also, try out this ng-boilerplate project to kickstart your AngularJS projects. ...

May 23, 2013 · 1 min · birdchan

PHP on Google App Engine

You can follow the official install page to install Google App Engine for PHP, or follow my steps here. I am using osx 10.8.3 and I use brew instead of macport. First you will need to get php 5.4. What you have is probably 5.3. You can verify by php -v, and something like this comes out. PHP 5.3.15 with Suhosin-Patch (cli) (built: Aug 24 2012 17:45:44) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies That’s the default/latest php version for osx 10.8.3. To install php 5.4 using brew, according to https://github.com/josegonzalez/homebrew-php, do the following. ...

May 16, 2013 · 3 min · birdchan

AdMob error

I got this mysterious runtime error below while trying to integrate AdMob into my xcode project. 2013-03-21 22:02:32.646 my_app[41152:c07] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[GADObjectPrivate changeState:]: unrecognized selector sent to instance 0x95945e0’ \\\ First throw call stack:* (0x19a6012 0x1719e7e 0x1a314bd 0x1995bbc 0x199594e 0x217d2 0x2307e 0x20d87 0x90ce 0x6248c3 0x624323 0x632668 0x621b73 0x172d6b0 0x62d7b3 0x62f264 0x62feb8 0x1e7a53f 0x1e8c014 0x1e7c7d5 0x194caf5 0x194bf44 0x194be1b 0x27ae7e3 0x27ae668 0x66165c 0x2cbd 0x2be5) libc++abi.dylib: terminate called throwing an exception ...

March 22, 2013 · 1 min · birdchan

Excel to JSON

Here is my little side project to convert excel files to json objects. I mainly used the Google App Engine and the Python xlrd module. Feel free to try it out at http://excel2json.appspot.com/. curl -F f=@my_file.xls http://excel2json.appspot.com/2json All you need is just one line of code!

February 7, 2013 · 1 min · birdchan

Working with Excel files in Python

The libraries needed are: xlutils, xlrd and xlwt. They are all under the package called xlutils. So just issue the following command. sudo pip install xlutils To verify: localhost:~ birdchan$ python Python 2.7.2 (default, Jun 16 2012, 12:38:40) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import xlutils >>> Should have no error messages.

February 6, 2013 · 1 min · birdchan

Trigger a click event on a legend item in Highchart

Sometimes you have a few series in your chart and you want to turn off some of them, maybe because they are too big thus skewing the rest of the data. See below for example, the green bar is just too long compared to the other two. We know that mouse-clicking on a legend item can turn series on and off. Here after clicking on the green legend item, we see: ...

January 24, 2013 · 1 min · birdchan

Datatable clear filtering

Here is how to clear all filtering in datatable. function fnResetAllFilters() { var oSettings = oTable.fnSettings(); for(iCol = 0; iCol < oSettings.aoPreSearchCols.length; iCol++) { oSettings.aoPreSearchCols[ iCol ].sSearch = ''; } oTable.fnDraw(); } So to clear just one filter, do: function reset_filter_with_index(iCol){ var oSettings = oTable.fnSettings(); oSettings.aoPreSearchCols[ iCol ].sSearch = ''; oTable.fnDraw(); } Ref link: http://www.datatables.net/forums/discussion/997/fnfilter-how-to-reset-all-filters-without-multiple-requests./p1

November 26, 2012 · 1 min · birdchan

splitting and joining huge files

Today I wanted to sftp a 10Gb file over the wire. Knowing that the transfer would fail in the middle of it, I decided to split this file into small pieces beforehand. Below I think is the easiest way on osx. // to split my huge file into 100mb files, having the prefix "bak_" split -b 100m my_huge_file.ext bak_ // to re-construct my huge file cat `ls bak_*` > my_huge_file2.ext After running the split command, you will see some files named bak_aa, bak_ab, etc in your directory. These are the chucks of your original huge file. So just transfer these small bak_* files over the wire. ...

November 3, 2012 · 1 min · birdchan

PHP explode

Say you store a csv formatted string somewhere to represent an array. For example, Johnny has items “apple|orange|banana”. Then in your code, you may parse out the items as follows: $items = "apple|orange|banana"; // retrieve it from somewhere $my_arr = explode("|", $items); if (count($my_arr) > 0){ print "Johnny has something."; }else{ print "Johnny has nothing."; } It works fine as it seems. Well, actually, you will never see the “Johnny has nothing” print out. Surprisingly, even if $items is an empty string, explode will still return an array with one element. That array is: ...

November 1, 2012 · 1 min · birdchan

Formatting mysql datetime with php

Very useful, so posting here. Read the php date function page for more details. $mysql_datetime = date("Y-m-d H:i:s"); Ref: http://stackoverflow.com/questions/136782/format-mysql-datetime-with-php

October 23, 2012 · 1 min · birdchan