<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Brian Chan&#039;s blog</title>
	<atom:link href="http://birdchan.com/home/feed/" rel="self" type="application/rss+xml" />
	<link>http://birdchan.com/home</link>
	<description>Birds of a feather flock together</description>
	<lastBuildDate>Sat, 19 May 2012 00:57:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Adding shadow to wp-codebox</title>
		<link>http://birdchan.com/home/2012/05/18/adding-shadow-to-wp-codebox/</link>
		<comments>http://birdchan.com/home/2012/05/18/adding-shadow-to-wp-codebox/#comments</comments>
		<pubDate>Sat, 19 May 2012 00:55:11 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2853</guid>
		<description><![CDATA[Too bad wp-codebox contains two divs namely wp_codebox_msgheader and wp_codebox, we cannot simply give the box-shadow to one single div. After playing with this a bit, here is my parameters. The css file is located at /your-wp-root/wp-content/plugins/wp-codebox/css/codebox.css. ?View Code CSS1 2 3 4 5 6 .wp_codebox_msgheader &#123; box-shadow: 6px 14px 11px #808083; &#125; .wp_codebox &#123; [...]]]></description>
			<content:encoded><![CDATA[<p>Too bad <a href=http://wordpress.org/extend/plugins/wp-codebox/ target=_blank>wp-codebox</a> contains two divs namely wp_codebox_msgheader and wp_codebox, we cannot simply give the <b>box-shadow</b> to one single div. After playing with this a bit, here is my parameters. The css file is located at <b>/your-wp-root/wp-content/plugins/wp-codebox/css/codebox.css</b>.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2853code3'); return false;">View Code</a> CSS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p28533"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p2853code3"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.wp_codebox_msgheader</span> <span style="color: #00AA00;">&#123;</span>
        box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">6px</span> <span style="color: #933;">14px</span> <span style="color: #933;">11px</span> <span style="color: #cc00cc;">#808083</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.wp_codebox</span> <span style="color: #00AA00;">&#123;</span>
        box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">7px</span> <span style="color: #933;">10px</span> <span style="color: #933;">10px</span> <span style="color: #cc00cc;">#888</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>The overlapped area seems smooth with this setting. </p>
<p>I also added bottom margin to the codebox, see if you like it.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2853code4'); return false;">View Code</a> CSS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p28534"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p2853code4"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.wp_codebox</span> <span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/05/18/adding-shadow-to-wp-codebox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Ruby on Rails in osx</title>
		<link>http://birdchan.com/home/2012/05/18/installing-ruby-on-rails-in-osx/</link>
		<comments>http://birdchan.com/home/2012/05/18/installing-ruby-on-rails-in-osx/#comments</comments>
		<pubDate>Sat, 19 May 2012 00:23:36 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2845</guid>
		<description><![CDATA[Install Xcode first. You will need the one from the Mac App Store. You will need version 4.3 or above. Then install homebrew. Go to this link (https://github.com/mxcl/homebrew/wiki/installation) to find the installation command. As of May 2012, the command is: ?View Code CMD1 /usr/bin/ruby -e &#34;$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)&#34; Then after the process finishes (it took [...]]]></description>
			<content:encoded><![CDATA[<p><b>Install Xcode first</b>. You will need the one from the Mac App Store. You will need version 4.3 or above. </p>
<p><b>Then install homebrew</b>. Go to this link (<a href=https://github.com/mxcl/homebrew/wiki/installation target=_blank>https://github.com/mxcl/homebrew/wiki/installation</a>) to find the installation command. As of May 2012, the command is:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code22'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284522"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2845code22"><pre class="cmd" style="font-family:monospace;">/usr/bin/ruby -e &quot;$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)&quot;</pre></td></tr></table></div>

<p>Then after the process finishes (it took like 30 seconds), run</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code23'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284523"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2845code23"><pre class="cmd" style="font-family:monospace;">brew doctor</pre></td></tr></table></div>

<p>This is just to make sure your environment is good to move on. If your Xcode is old you will get a complain here like the following:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code24'); return false;">View Code</a> ERROR</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284524"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p2845code24"><pre class="error" style="font-family:monospace;">$ brew doctor
&nbsp;
Error: You have Xcode 4.1, which is outdated.
Please install Xcode 4.3.</pre></td></tr></table></div>

<p>I have installed the mcrypt lib myself, and I got warnings about that (see below). If that happens to you just ignore it.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code25'); return false;">View Code</a> ERROR</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284525"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p2845code25"><pre class="error" style="font-family:monospace;">Error: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
&nbsp;
Unexpected dylibs:
    /usr/local/lib/libmcrypt.4.4.8.dylib
Error: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
&nbsp;
Unexpected .la files:
    /usr/local/lib/libmcrypt.la
Error: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
&nbsp;
Unexpected static libraries:
    /usr/local/lib/libarmdis.a    /usr/local/lib/libAstrisAPI.a</pre></td></tr></table></div>

<p><b>Then Install git</b> by:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code26'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284526"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2845code26"><pre class="cmd" style="font-family:monospace;">brew install git</pre></td></tr></table></div>

<p>You can make sure git is successfully installed by issuing:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code27'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284527"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2845code27"><pre class="cmd" style="font-family:monospace;">git --version</pre></td></tr></table></div>

<p><b>Then install MySQL</b>. Now, I believe you already have it if you are using Lion. Type the following command to see if you have mysql installed.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code28'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284528"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2845code28"><pre class="cmd" style="font-family:monospace;">mysql -u root</pre></td></tr></table></div>

<p>If you get a mysql prompt, then you are good. If not, install it by issuing:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code29'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284529"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2845code29"><pre class="cmd" style="font-family:monospace;">brew install mysql</pre></td></tr></table></div>

<p>You can alternatively install <a href=http://www.mamp.info/ target=_blank>MAMP</a> if you like, as MySQL will be one of the packages inside MAMP. </p>
<p><b>Then install RVM</b>. This is the Ruby Version Manager. It will make your life so much easier down the road.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code30'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284530"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2845code30"><pre class="cmd" style="font-family:monospace;">bash &lt; &lt;(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)</pre></td></tr></table></div>

<p>After installing rvm, edit your <b>~/.bash_profile</b> file to include the following line. Make sure it&#8217;s there.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code31'); return false;">View Code</a> BASH_PROFILE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284531"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2845code31"><pre class="bash_profile" style="font-family:monospace;">[[ -s &quot;$HOME/.rvm/scripts/rvm&quot; ]] &amp;&amp; source &quot;$HOME/.rvm/scripts/rvm&quot; # Load RVM into a shell session *as a function*</pre></td></tr></table></div>

<p>Then source your bash_profile file as you always do.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code32'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284532"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2845code32"><pre class="cmd" style="font-family:monospace;">source ~/.bash_profile</pre></td></tr></table></div>

<p>Now <b>Install Ruby</b>. Lion already has 1.8 but we are going to install the latest 1.9.3.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code33'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284533"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2845code33"><pre class="cmd" style="font-family:monospace;">rvm install 1.9.3</pre></td></tr></table></div>

<p>It will start downloading and installing. Just wait until it&#8217;s done, all automated. Isn&#8217;t it nice? </p>
<p>After installing check your ruby version by issuing:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code34'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284534"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2845code34"><pre class="cmd" style="font-family:monospace;">ruby -v</pre></td></tr></table></div>

<p>You should see something like <b>ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]</b>. </p>
<p>Then lastly <b>install Rails</b>.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code35'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284535"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p2845code35"><pre class="cmd" style="font-family:monospace;">gem install bundler
gem install mysql2
gem install rails</pre></td></tr></table></div>

<p>Now that we have rails installed, it&#8217;s time to test it out! Let&#8217;s create a simple test app in our home directory.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code36'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284536"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p2845code36"><pre class="cmd" style="font-family:monospace;">cd
rails new mytest</pre></td></tr></table></div>

<p>All your new projects files are inside the newly created directory called <b>mytest</b>. Now to run this app issue:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code37'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284537"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p2845code37"><pre class="cmd" style="font-family:monospace;">cd mytest
rails server</pre></td></tr></table></div>

<p>You will see something like the following:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2845code38'); return false;">View Code</a> CONSOLE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284538"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p2845code38"><pre class="console" style="font-family:monospace;">$ rails server
=&gt; Booting WEBrick
=&gt; Rails 3.2.3 application starting in development on http://0.0.0.0:3000
=&gt; Call with -d to detach
=&gt; Ctrl-C to shutdown server
[2012-05-18 17:09:11] INFO  WEBrick 1.3.1
[2012-05-18 17:09:11] INFO  ruby 1.9.3 (2012-04-20) [x86_64-darwin11.3.0]
[2012-05-18 17:09:11] INFO  WEBrick::HTTPServer#start: pid=7008 port=3000</pre></td></tr></table></div>

<p>So open a web browser and type in <b>http://0.0.0.0:3000</b> into the location bar. If you see the rails welcome page, then congratulations! You are on Rails now! </p>
<hr />
<p>You can find more very useful info on the rails official site at <a href=http://guides.rubyonrails.org/getting_started.html target=_blank>http://guides.rubyonrails.org/getting_started.html</a></p>
<p>I heavily borrowed much content and edited some portions from <a href=http://thinkvitamin.com/code/ruby-on-rails/installing-ruby-rails-and-mysql-on-os-x-lion/ target=_blank>http://thinkvitamin.com/code/ruby-on-rails/installing-ruby-rails-and-mysql-on-os-x-lion/</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/05/18/installing-ruby-on-rails-in-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check the existence of an element in jquery</title>
		<link>http://birdchan.com/home/2012/05/16/check-the-existence-of-an-element-in-jquery/</link>
		<comments>http://birdchan.com/home/2012/05/16/check-the-existence-of-an-element-in-jquery/#comments</comments>
		<pubDate>Wed, 16 May 2012 18:18:09 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2841</guid>
		<description><![CDATA[When dealing with dynamic creation of DOM objects, sometimes you need to check if a certain element exists. Below is how you check: ?View Code JS1 2 3 if ($('#my_element').length &#62; 0){ // it exists! } If you need to check whether a dropdown has any options, here is how ?View Code JS1 2 3 [...]]]></description>
			<content:encoded><![CDATA[<p>When dealing with dynamic creation of DOM objects, sometimes you need to check if a certain element exists. Below is how you check:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2841code41'); return false;">View Code</a> JS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284141"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p2841code41"><pre class="js" style="font-family:monospace;">if ($('#my_element').length &gt; 0){
  // it exists!
}</pre></td></tr></table></div>

<p>If you need to check whether a dropdown has any options, here is how</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2841code42'); return false;">View Code</a> JS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p284142"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p2841code42"><pre class="js" style="font-family:monospace;">if ($('#my_dropdown option').length &gt; 0){
  // contains options
}</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/05/16/check-the-existence-of-an-element-in-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Breathing Observation Bubble (B.O.B.) in Hawaii</title>
		<link>http://birdchan.com/home/2012/05/09/breathing-observation-bubble-b-o-b-in-hawaii/</link>
		<comments>http://birdchan.com/home/2012/05/09/breathing-observation-bubble-b-o-b-in-hawaii/#comments</comments>
		<pubDate>Wed, 09 May 2012 17:45:51 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[fun]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2836</guid>
		<description><![CDATA[This apparently is a new &#8220;water tourist thing&#8221; in Hawaii. Looks interesting!]]></description>
			<content:encoded><![CDATA[<p><iframe width="640" height="480" src="http://www.youtube.com/embed/w3n4D_VyXN8" frameborder="0" allowfullscreen></iframe><br />
This apparently is a new &#8220;water tourist thing&#8221; in Hawaii. Looks interesting! </p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/05/09/breathing-observation-bubble-b-o-b-in-hawaii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Short History of the Modern Calendar</title>
		<link>http://birdchan.com/home/2012/05/08/a-short-history-of-the-modern-calendar/</link>
		<comments>http://birdchan.com/home/2012/05/08/a-short-history-of-the-modern-calendar/#comments</comments>
		<pubDate>Tue, 08 May 2012 20:56:46 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[fun]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2833</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><iframe width="640" height="360" src="http://www.youtube.com/embed/kzprsR2SvrQ" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/05/08/a-short-history-of-the-modern-calendar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What does &#8220;al dente&#8221; mean when cooking pasta?</title>
		<link>http://birdchan.com/home/2012/05/05/what-does-al-dente-mean-when-cooking-pasta/</link>
		<comments>http://birdchan.com/home/2012/05/05/what-does-al-dente-mean-when-cooking-pasta/#comments</comments>
		<pubDate>Sat, 05 May 2012 17:04:46 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[life]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2825</guid>
		<description><![CDATA[Al dente is a fancy term for pasta that&#8217;s fully cooked, but not overly soft. The phrase is Italian for &#8220;to the tooth,&#8221; which comes from testing the pasta&#8217;s consistency with your teeth. [wikipedia] How does one cook pasta &#8220;just right&#8221;? According to the National Pasta Association: Boil 4 to 6 quarts of water for [...]]]></description>
			<content:encoded><![CDATA[<p><img src=/images/pasta_dish.jpg style='float: right; width: 400px; padding: 10px 20px;'>Al dente is a fancy term for pasta that&#8217;s fully cooked, but not overly soft. The phrase is Italian for &#8220;to the tooth,&#8221; which comes from testing the pasta&#8217;s consistency with your teeth. [<a href=http://en.wikipedia.org/wiki/Al_dente target=_blank>wikipedia</a>]</p>
<p>How does one cook pasta &#8220;just right&#8221;? According to the <a href=http://www.ilovepasta.org/resource-center/cooking-tips/preparing-perfect-pasta target=_blank>National Pasta Association</a>:</p>
<ol>
<li>Boil 4 to 6 quarts of water for one pound of dry pasta. (You can divide this recipe depending on how much pasta you are cooking.)
<li>Add the pasta with a stir and return the water to a boil.
<li>Stir the pasta occasionally during cooking.
<li>Follow the package directions for cooking times. If the pasta is to be used as part of a dish that requires further cooking, undercook the pasta by 1/3 of the cooking time specified on the package.
<li>Taste the pasta to determine if it is done. Perfectly cooked pasta should be &#8220;al dente,&#8221; or firm to the bite, yet cooked through.
<li>Drain pasta immediately and follow the rest of the recipe.
</ol>
<p>So next time you can appear to be cultural at an Italian restaurant by saying to your waiter, &#8220;May I have my pasta al dente please?&#8221; &#8230; Um&#8230; actually nevermind. <img src='http://birdchan.com/home/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/05/05/what-does-al-dente-mean-when-cooking-pasta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find out the physical memory size in osx</title>
		<link>http://birdchan.com/home/2012/05/02/find-out-the-physical-memory-size-in-osx/</link>
		<comments>http://birdchan.com/home/2012/05/02/find-out-the-physical-memory-size-in-osx/#comments</comments>
		<pubDate>Wed, 02 May 2012 20:22:37 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2821</guid>
		<description><![CDATA[Far too often I accomplish this by clicking on the apple icon on the menu bar, then click &#8220;About this Mac&#8221;, then just read from the popup window. This is perfectly fine and all, until one day I was given only a shell and I needed to get that info. Well, here is how you [...]]]></description>
			<content:encoded><![CDATA[<p>Far too often I accomplish this by clicking on the apple icon on the menu bar, then click &#8220;About this Mac&#8221;, then just read from the popup window. This is perfectly fine and all, until one day I was given only a shell and I needed to get that info. </p>
<p>Well, here is how you can do it in command line:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2821code44'); return false;">View Code</a> SHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p282144"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2821code44"><pre class="shell" style="font-family:monospace;">sysctl -a | grep mem</pre></td></tr></table></div>

<p>Then look for <b>hw.memsize</b> in the list. The number is in byte size, so you will need to do some conversion in your head. For example, if you see <b>hw.memsize = 12884901888</b>, that&#8217;s actually 12 * 1024 * 1024 * 1024, which is 12Gb. </p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/05/02/find-out-the-physical-memory-size-in-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>English is a crazy language</title>
		<link>http://birdchan.com/home/2012/05/01/english-is-a-crazy-language/</link>
		<comments>http://birdchan.com/home/2012/05/01/english-is-a-crazy-language/#comments</comments>
		<pubDate>Wed, 02 May 2012 04:24:15 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2816</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div style='margin: 0 auto; text-align: center;'>
<img src=../blog_files/2012_05_01_english/english_is_a_crazy_language.jpg>
</div>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/05/01/english-is-a-crazy-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nest Learning Thermostat</title>
		<link>http://birdchan.com/home/2012/05/01/nest-learning-thermostat/</link>
		<comments>http://birdchan.com/home/2012/05/01/nest-learning-thermostat/#comments</comments>
		<pubDate>Tue, 01 May 2012 20:52:34 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[DIY]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2813</guid>
		<description><![CDATA[Interesting thermostat from Nest. The website also has an installation tutorial video.]]></description>
			<content:encoded><![CDATA[<p><iframe width="640" height="360" src="http://www.youtube.com/embed/B9qCLs8txBo" frameborder="0" allowfullscreen></iframe></p>
<p>Interesting thermostat from <a href=http://www.nest.com/ target=_blank>Nest</a>. The website also has an installation tutorial video. </p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/05/01/nest-learning-thermostat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bach, Toccata and Fugue in D minor, organ</title>
		<link>http://birdchan.com/home/2012/04/27/bach-toccata-and-fugue-in-d-minor-organ/</link>
		<comments>http://birdchan.com/home/2012/04/27/bach-toccata-and-fugue-in-d-minor-organ/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 21:14:26 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2810</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><iframe width="640" height="480" src="http://www.youtube.com/embed/ipzR9bhei_o" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/04/27/bach-toccata-and-fugue-in-d-minor-organ/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>廣州用水泥料做鹼水麵！</title>
		<link>http://birdchan.com/home/2012/04/26/%e5%bb%a3%e5%b7%9e%e7%94%a8%e6%b0%b4%e6%b3%a5%e6%96%99%e5%81%9a%e9%b9%bc%e6%b0%b4%e9%ba%b5%ef%bc%81/</link>
		<comments>http://birdchan.com/home/2012/04/26/%e5%bb%a3%e5%b7%9e%e7%94%a8%e6%b0%b4%e6%b3%a5%e6%96%99%e5%81%9a%e9%b9%bc%e6%b0%b4%e9%ba%b5%ef%bc%81/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 06:46:02 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2806</guid>
		<description><![CDATA[【食在廣州】廣州用水泥料做鹼水麵！]]></description>
			<content:encoded><![CDATA[<p><iframe width="640" height="480" src="http://www.youtube.com/embed/wNYNOAmsFW4" frameborder="0" allowfullscreen></iframe><br />
【食在廣州】廣州用水泥料做鹼水麵！</p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/04/26/%e5%bb%a3%e5%b7%9e%e7%94%a8%e6%b0%b4%e6%b3%a5%e6%96%99%e5%81%9a%e9%b9%bc%e6%b0%b4%e9%ba%b5%ef%bc%81/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DonorsChoose.org</title>
		<link>http://birdchan.com/home/2012/04/25/donorschoose-org/</link>
		<comments>http://birdchan.com/home/2012/04/25/donorschoose-org/#comments</comments>
		<pubDate>Wed, 25 Apr 2012 23:38:29 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2801</guid>
		<description><![CDATA[If you ever want to donate to school kids, check out this DonorsChoose.org website! Here&#8217;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. Then, [...]]]></description>
			<content:encoded><![CDATA[<p><iframe width="640" height="480" src="http://www.youtube.com/embed/PUSdjfh2YjM" frameborder="0" allowfullscreen></iframe></p>
<p>If you ever want to donate to school kids, check out this <a href=http://www.donorschoose.org/ target=_blank>DonorsChoose.org</a> website! </p>
<p>Here&#8217;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.</p>
<p>Then, you can browse project requests and give any amount to the one that inspires you. Once a project reaches its funding goal, we deliver the materials to the school.</p>
<p>You&#8217;ll get photos of your project taking place, a thank-you letter from the teacher, and a cost report showing how each dollar was spent. If you give over $50, you&#8217;ll also receive hand-written thank-you letters from the students.</p>
<p>At DonorsChoose.org, you can give as little as $1 and get the same level of choice, transparency, and feedback that is traditionally reserved for someone who gives millions. </p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/04/25/donorschoose-org/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL converting Text to Varchar</title>
		<link>http://birdchan.com/home/2012/04/13/mysql-converting-text-to-varchar/</link>
		<comments>http://birdchan.com/home/2012/04/13/mysql-converting-text-to-varchar/#comments</comments>
		<pubDate>Sat, 14 Apr 2012 00:04:42 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2797</guid>
		<description><![CDATA[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&#8217;t be truncating anything. Run the following to make sure ?View Code SQL1 2 SELECT MAX&#40; LENGTH&#40; target_column &#41; &#41; FROM target_table As long as the [...]]]></description>
			<content:encoded><![CDATA[<p>One incentive of converting a text column to a varchar column is that, you can index that column for quicker query. </p>
<p>Before converting, you want to make sure you won&#8217;t be truncating anything. Run the following to make sure</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2797code46'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p279746"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p2797code46"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> MAX<span style="color: #66cc66;">&#40;</span> LENGTH<span style="color: #66cc66;">&#40;</span>  target_column <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> 
<span style="color: #993333; font-weight: bold;">FROM</span>  target_table</pre></td></tr></table></div>

<p>As long as the returned length is less than your varchar length, you are good to go. </p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/04/13/mysql-converting-text-to-varchar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Marathon Fundraising &#8211; American Brain Tumor Association</title>
		<link>http://birdchan.com/home/2012/04/09/marathon-fundraising-american-brain-tumor-association/</link>
		<comments>http://birdchan.com/home/2012/04/09/marathon-fundraising-american-brain-tumor-association/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 19:51:57 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[personal]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2792</guid>
		<description><![CDATA[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!]]></description>
			<content:encoded><![CDATA[<p>My friend Johnny is running for the SF Full-Marathon this summer for a good cause. Please visit his <a href=http://hope.abta.org/site/TR?px=2166482&#038;fr_id=2290&#038;pg=personal target=_blank>fundraising page</a> for more details! Go Johnny! </p>
<p><a href=http://hope.abta.org/site/TR?px=2166482&#038;fr_id=2290&#038;pg=personal target=_blank><img src=/images/TB-2012-Logo.jpg></a></p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/04/09/marathon-fundraising-american-brain-tumor-association/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Glass</title>
		<link>http://birdchan.com/home/2012/04/04/project-glass/</link>
		<comments>http://birdchan.com/home/2012/04/04/project-glass/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 02:13:44 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2789</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><iframe width="640" height="360" src="http://www.youtube.com/embed/9c6W4CCU9M4" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/04/04/project-glass/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DuckDuckGo</title>
		<link>http://birdchan.com/home/2012/03/29/duckduckgo/</link>
		<comments>http://birdchan.com/home/2012/03/29/duckduckgo/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 02:07:40 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2782</guid>
		<description><![CDATA[DuckDuckGo is a search engine much like google. I tried it with a few searches and it&#8217;s just as fast as google if not faster. For now it&#8217;s not a threat yet but who knows. I like how it gives you its traffic stats as well.]]></description>
			<content:encoded><![CDATA[<p><a href=http://duckduckgo.com/ target=_blank>DuckDuckGo</a> is a search engine much like <a href=http://google.com target=_blank>google</a>. I tried it with a few searches and it&#8217;s just as fast as google if not faster. For now it&#8217;s not a threat yet but who knows. </p>
<div style='margin: 30px auto; text-align: center;'>
<a href=http://duckduckgo.com/ target=_blank><img src=/images/DuckDuckGo.png style='width: 400px;'></a>
</div>
<p>I like how it gives you <a href=http://duckduckgo.com/traffic.html target=_blank>its traffic stats</a> as well. <img src='http://birdchan.com/home/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/03/29/duckduckgo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPExcel: the right way to open files</title>
		<link>http://birdchan.com/home/2012/03/26/phpexcel-the-right-way-to-open-files/</link>
		<comments>http://birdchan.com/home/2012/03/26/phpexcel-the-right-way-to-open-files/#comments</comments>
		<pubDate>Tue, 27 Mar 2012 05:29:44 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2778</guid>
		<description><![CDATA[Just let PHPExcel figure out the file type by using PHPExcel_IOFactory::identify() ?View Code PHP1 2 3 4 5 6 7 8 9 10 11 12 13 14 $filename = 'your_file.xls'; &#160; require_once 'PHPExcel/Classes/PHPExcel.php'; &#160; // Create new PHPExcel object $filetype = PHPExcel_IOFactory::identify($filename); $objReader = PHPExcel_IOFactory::createReader($filetype); $objReader-&#62;setReadDataOnly(true); // set this if you don't need to write [...]]]></description>
			<content:encoded><![CDATA[<p>Just let PHPExcel figure out the file type by using <b>PHPExcel_IOFactory::identify()</b></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2778code48'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p277848"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p2778code48"><pre class="php" style="font-family:monospace;">$filename = 'your_file.xls';
&nbsp;
require_once 'PHPExcel/Classes/PHPExcel.php';
&nbsp;
// Create new PHPExcel object
$filetype = PHPExcel_IOFactory::identify($filename);
$objReader = PHPExcel_IOFactory::createReader($filetype);
$objReader-&gt;setReadDataOnly(true);  // set this if you don't need to write
$objPHPExcel = $objReader-&gt;load($filename);
&nbsp;
// go through each sheet
foreach ($objPHPExcel-&gt;getWorksheetIterator() as $worksheet) {
  ...
}</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/03/26/phpexcel-the-right-way-to-open-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Packing form elements using json</title>
		<link>http://birdchan.com/home/2012/03/22/packing-form-elements-using-json/</link>
		<comments>http://birdchan.com/home/2012/03/22/packing-form-elements-using-json/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 02:47:43 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2772</guid>
		<description><![CDATA[Sometimes I don&#8217;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. ?View Code JS1 2 3 4 5 [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes I don&#8217;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.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2772code52'); return false;">View Code</a> JS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p277252"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p2772code52"><pre class="js" style="font-family:monospace;">json_str = JSON.stringify($('#my_form').serializeArray());
&nbsp;
$.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);
  }
});</pre></td></tr></table></div>

<p>Yea, <b><a href=http://api.jquery.com/serializeArray/ target=_blank>serializeArray()</a></b> will convert a form object to a javascript array. Notice this method can only apply to form objects. Then the <b><a href=https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/JSON/stringify target=_blank>stringify</a></b> method will convert the array to a json string. </p>
<p>Once the json string gets sent over, here is what happens on the php side. I like associated arrays.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2772code53'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p277253"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p2772code53"><pre class="php" style="font-family:monospace;">$form_data_encoded = $_POST['form_data'];
$form_data_decoded = json_decode($form_data_encoded);
&nbsp;
// building an associated array
$form_data = array();
foreach ($form_data_decoded as $obj){
  $name = $obj-&gt;{&quot;name&quot;};
  $value = $obj-&gt;{&quot;value&quot;};
  $form_data[$name] = $value;
}</pre></td></tr></table></div>

<p>In case you are a pure javascript dude, here is some code to build an associated array in javascript out of that json_str from above.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2772code54'); return false;">View Code</a> JS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p277254"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p2772code54"><pre class="js" style="font-family:monospace;">var arr = jQuery.parseJSON(json_str);
var dict = new Array();
for (k in arr){
  arr2 = arr[k];
  dict[arr2.name] = arr2.value;
}</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/03/22/packing-form-elements-using-json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPExcel</title>
		<link>http://birdchan.com/home/2012/03/22/phpexcel/</link>
		<comments>http://birdchan.com/home/2012/03/22/phpexcel/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 02:24:12 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2761</guid>
		<description><![CDATA[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. ?View Code PHP1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [...]]]></description>
			<content:encoded><![CDATA[<p><a href=http://phpexcel.codeplex.com/ target=_blank>PHPExcel</a> 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.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2761code57'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p276157"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code" id="p2761code57"><pre class="php" style="font-family:monospace;">$filename = 'your_file.xls';
&nbsp;
require_once 'PHPExcel/Classes/PHPExcel.php';
&nbsp;
// Create new PHPExcel object
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader-&gt;load($filename);
&nbsp;
foreach ($objPHPExcel-&gt;getWorksheetIterator() as $worksheet) {
&nbsp;
  $sheet_name = $worksheet-&gt;getTitle();
&nbsp;
  foreach ($worksheet-&gt;getRowIterator() as $row) {
    $cellIterator = $row-&gt;getCellIterator();
    $cellIterator-&gt;setIterateOnlyExistingCells(false); // Loop all cells, even if empty
    foreach ($cellIterator as $cell) {
      if (!is_null($cell)) {
        $cell_coord = $cell-&gt;getCoordinate();
        $cell_val = $cell-&gt;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);
        }
      }
    }
  }
&nbsp;
}</pre></td></tr></table></div>

<p>For <b>do_something_with_this_cell($sheet_name, $col, $row, $cell_val)</b>, you can either store the value into DB for later analysis, or look up a mapping array and determine what that cell carries. </p>
<p>Sometimes you may need to deal with cells that carry dates. If you simply make the getCalculatedValue() call you will get some strange integer back but not the actual date string. The reason for that is, the date object in excel is actually masked by a date formatter. In order to get the desired date string, do the following:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2761code58'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p276158"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p2761code58"><pre class="php" style="font-family:monospace;">foreach ($cellIterator as $cell) {
  if (!is_null($cell)) {
    $cell_coord = $cell-&gt;getCoordinate();
    $cell_val = $cell-&gt;getCalculatedValue();
    if (preg_match('/^([a-zA-Z]+)([0-9]+)$/', $cell_coord, $matches)){
      $col = $matches[1];
      $row = (int) $matches[2];
&nbsp;
      // check for date object
      if(PHPExcel_Shared_Date::isDateTime($cell)){
        $cell_val = PHPExcel_Style_NumberFormat::toFormattedString($cell_val, &quot;YYYY-MM-DD&quot;);
      }
&nbsp;
      do_something_with_this_cell($sheet_name, $col, $row, $cell_val);
    }
  }
}</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/03/22/phpexcel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to disconnect comcast TV</title>
		<link>http://birdchan.com/home/2012/03/17/how-to-disconnect-comcast-tv/</link>
		<comments>http://birdchan.com/home/2012/03/17/how-to-disconnect-comcast-tv/#comments</comments>
		<pubDate>Sat, 17 Mar 2012 22:19:47 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[personal]]></category>

		<guid isPermaLink="false">http://birdchan.com/home/?p=2757</guid>
		<description><![CDATA[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&#8217;t have time to watch TV, I decided to cancel just the TV service. It took me a while to find out how to [...]]]></description>
			<content:encoded><![CDATA[<p>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&#8217;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. </p>
<ol>
<li>Call 1-800-266-2278.
<li>If you don&#8217;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.
<li>Then just a lot more options with the voice machine to get to an actual person who can assist you to downgrade your service.
</ol>
<p>For all other issues, you can try out the online chat service at: <a href=https://www.comcastsupport.com/chatentry/ target=_blank>https://www.comcastsupport.com/chatentry/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://birdchan.com/home/2012/03/17/how-to-disconnect-comcast-tv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

