廣州用水泥料做鹼水麵!

[youtube &w=640&h=480] 【食在廣州】廣州用水泥料做鹼水麵!

April 27, 2012 · 1 min · birdchan

DonorsChoose.org

[youtube &w=640&h=480] If you ever want to donate to school kids, check out this DonorsChoose.org website! Here’s how it works: public school teachers from every corner of America post classroom project requests on DonorsChoose.org. Requests range from pencils for a poetry writing unit, to violins for a school recital, to microscope slides for a biology class. ...

April 25, 2012 · 1 min · birdchan

MySQL converting Text to Varchar

One incentive of converting a text column to a varchar column is that, you can index that column for quicker query. Before converting, you want to make sure you won’t be truncating anything. Run the following to make sure SELECT MAX( LENGTH( target_column ) ) FROM target_table As long as the returned length is less than your varchar length, you are good to go.

April 14, 2012 · 1 min · birdchan

Marathon Fundraising - American Brain Tumor Association

My friend Johnny is running for the SF Full-Marathon this summer for a good cause. Please visit his fundraising page for more details! Go Johnny!

April 9, 2012 · 1 min · birdchan

Project Glass

[youtube &w=640&h=360]

April 5, 2012 · 1 min · birdchan

DuckDuckGo

DuckDuckGo is a search engine much like google. I tried it with a few searches and it’s just as fast as google if not faster. For now it’s not a threat yet but who knows. I like how it gives you its traffic stats as well. ;)

March 30, 2012 · 1 min · birdchan

PHPExcel: the right way to open files

Just let PHPExcel figure out the file type by using PHPExcel_IOFactory::identify() $filename = 'your_file.xls'; require_once 'PHPExcel/Classes/PHPExcel.php'; // Create new PHPExcel object $filetype = PHPExcel_IOFactory::identify($filename); $objReader = PHPExcel_IOFactory::createReader($filetype); $objReader->setReadDataOnly(true); // set this if you don't need to write $objPHPExcel = $objReader->load($filename); // go through each sheet foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { ... }

March 27, 2012 · 1 min · birdchan

Packing form elements using json

Sometimes I don’t really want to pass form elements one by one in my ajax call, I just want to pack them all in one giant obj and send it over to the backend script. After looking for a while, I found the solution. See sample code below. json_str = JSON.stringify($('#my_form').serializeArray()); $.ajax({ url: 'do_something.php', type: 'POST', dataType: 'json', data: { form_data: json_str }, success: function(data) { // do something with data }, error: function(request, error) { alert('error: '+error+'nreadyState: '+request.readyState+'nstatus: '+request.status); alert('responseText: '+request.responseText); } }); Yea, serializeArray() will convert a form object to a javascript array. Notice this method can only apply to form objects. Then the stringify method will convert the array to a json string. ...

March 23, 2012 · 1 min · birdchan

PHPExcel

PHPExcel is a PHP library to handle both read/write from/to an excel file. Below is a short tutorial to cover reading data from an excel file. $filename = 'your_file.xls'; require_once 'PHPExcel/Classes/PHPExcel.php'; // Create new PHPExcel object $objReader = PHPExcel_IOFactory::createReader('Excel2007'); $objPHPExcel = $objReader->load($filename); foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { $sheet_name = $worksheet->getTitle(); foreach ($worksheet->getRowIterator() as $row) { $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if empty foreach ($cellIterator as $cell) { if (!is_null($cell)) { $cell_coord = $cell->getCoordinate(); $cell_val = $cell->getCalculatedValue(); if (preg_match('/^([a-zA-Z]+)([0-9]+)$/', $cell_coord, $matches)){ $col = $matches[1]; $row = (int) $matches[2]; do_something_with_this_cell($sheet_name, $col, $row, $cell_val); } } } } } For do_something_with_this_cell($sheet_name, $col, $row, $cell_val), you can either store the value into DB for later analysis, or look up a mapping array and determine what that cell carries. ...

March 23, 2012 · 2 min · birdchan

How to disconnect comcast TV

I got a bundle deal a few months ago with both TV and internet. After a while the discount expired, as I found out from my monthly statement. Since I really don’t have time to watch TV, I decided to cancel just the TV service. It took me a while to find out how to disconnect the TV service. Here is how. Call 1-800-266-2278. If you don’t have a residential phone number, just wait until they ask for your other phone numbers. For me, they have my cell phone number on file. ...

March 17, 2012 · 1 min · birdchan