<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>FrankMao.com</title>
	<atom:link href="http://frankmao.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://frankmao.com</link>
	<description>IOC(SM):MOC(RM):TDD(NU):SCC(TFS):ORM(L2S):JSL(Jq):CIS(CC)</description>
	<lastBuildDate>Wed, 30 May 2012 18:33:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='frankmao.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>FrankMao.com</title>
		<link>http://frankmao.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://frankmao.com/osd.xml" title="FrankMao.com" />
	<atom:link rel='hub' href='http://frankmao.com/?pushpress=hub'/>
		<item>
		<title>AWS Spot instance</title>
		<link>http://frankmao.com/2012/05/25/aws-spot-instance/</link>
		<comments>http://frankmao.com/2012/05/25/aws-spot-instance/#comments</comments>
		<pubDate>Fri, 25 May 2012 20:27:27 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AWS]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1662</guid>
		<description><![CDATA[Concept Compare to on-demand instance which costs about $0.02/h, spot instance price starts from $0.006, almost a third of the other one. Running a micro instance for a month will be only $4.5. Why so cheap? One possible reason would be, on-demand instances are charged by hour, which means even if you only used it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1662&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Concept</h2>
<p>Compare to on-demand instance which costs about $0.02/h, spot instance price starts from $0.006, almost a third of the other one. Running a micro instance for a month will be only $4.5.</p>
<p>Why so cheap? One possible reason would be, on-demand instances are charged by hour, which means even if you only used it for one minute then stop your instance immediately, you will still be charged for the full hour.</p>
<p>The only drawback for spot instance is that there is no guarantee for server instance to continue running. When market price goes up, spot instance will be terminated. Try to pick a quiet region if you can, e.g., us-east-1b price history seems very stable  0.006/h for a month, even for past 3 months ( only 2 spikes on Apr. 23)</p>
<p>When instance terminated, all data will be lost. Root ebs will be deleted automatically. If state data is needed, an extra ebs can be attached as user-data storage.There are many different posts showing how to attach another ebs during start-up, like coding in rc.d</p>
<p dir="ltr"><a href="http://ec2dream.blogspot.ca/search/label/EBS">http://ec2dream.blogspot.ca/search/label/EBS</a></p>
<p dir="ltr"><a href="http://www.ioncannon.net/system-administration/199/automounting-amazon-ebs-volumes-on-ec2-instances/">http://www.ioncannon.net/system-administration/199/automounting-amazon-ebs-volumes-on-ec2-instances/</a></p>
<p>but the easiest way is to set it in request, ec2 tool kit only.</p>
<ul>
<li><a href="https://forums.aws.amazon.com/thread.jspa?messageID=200921%F0%B1%83%99">https://forums.aws.amazon.com/thread.jspa?messageID=200921&amp;#200921</a></li>
<li><a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/concepts-spot-instances-applications-ebs.html">http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/concepts-spot-instances-applications-ebs.html</a></li>
<li><a href="http://docs.amazonwebservices.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-RequestSpotInstances.html">http://docs.amazonwebservices.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-RequestSpotInstances.html</a></li>
</ul>
<p>ec2-request-spot-instances -p 0.006 -t t1.micro -n 1 -b &#8216;/dev/sdf=snap-a023dfdf::false&#8217; ami-746fc91d -z us-east-1b -k mykeypaire -g my-group -r persistent</p>
<ol>
<li>Can not use sda1 （root), otherwise error: snapshotId cannot be modified on root device</li>
<li>/dev/sdx start from a letter &gt;f, in the example it uses b, I encountered an error saying snap id can only be changed on ebs device.</li>
<li>Don’t forget the key-value pair and security group. They are key to access.</li>
<li>-r persistent means repeat request.</li>
</ol>
<h2>Setup OS (environment, tools, your app, etc)</h2>
<p>Spot instance should start working for your order immediately after request fulfilled, the perfect solution would be start from your private AMI.</p>
<h2>Create AMI</h2>
<p>To create an AMI is to request a on-demand instance, setup everything you need, then</p>
<ul>
<li>Option A: created from an existing instance, better to stop the instance before</li>
<li>Option B: create an ebs snapshot, from which create a new image.</li>
</ul>
<p>Write down your image id. then request spot instance. Request can be done through AWS console or ec2 tool kit.</p>
<h2>Setup ec2 tool kit</h2>
<p dir="ltr">Download zip file from http://developer.amazonwebservices.com/connect/entry.jspa?externalID=368&amp;categoryID=88</p>
<p dir="ltr">Simply following <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/setting-up-your-tools.html">http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/setting-up-your-tools.html</a></p>
<p>export EC2_HOME=~/tools/ec2&#8230;<br />
export JAVA_HOME=/usr</p>
<p>Generate X509 cert following  <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/using-credentials.html#using-credentials-certificate">http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/using-credentials.html#using-credentials-certificate</a><br />
upload those 2 files to your work machine under  ~/.ec2 folder</p>
<p>$ export EC2_PRIVATE_KEY=~/.ec2/pk-blahblah.pem<br />
$ export EC2_CERT=~/.ec2/cert-blahblah.pem</p>
<p>Test setup using a command like ec2-describe-regions</p>
<p>It should work.</p>
<p>Those export and path setup can be put into ~/.bash_profile or ~/.bashrc</p>
<h2>Manually attach ebs</h2>
<h3>Created a new ebs 1G</h3>
<p>Attach to new instance manually in AWS console<img src="https://lh4.googleusercontent.com/hpGwg16ygHcCnE8BD7yTuh4rTQQpc6KJHF_RBy4r5P1pSkFQrR3ffAMg9k7Ogwwv0HvSa4y9-4BxLJP20EcKyIwbN0hCrc5f9uvqAAvbXjtClApb5IA" alt="" width="800px;" height="287px;" /><br />
device name will change to /dev/xvdf from /dev/sdf in ubuntu</p>
<p>ebs needs format before mount</p>
<p>sudo mkfs -t ext3 /dev/xvdf<br />
sudo mount -t ext4 /dev/xvdf /home/ubuntu/folder_to_mount</p>
<p dir="ltr">ref: <a href="http://yoodey.com/how-attach-and-mount-ebs-volume-ec2-instance-ubuntu-1010">http://yoodey.com/how-attach-and-mount-ebs-volume-ec2-instance-ubuntu-1010</a></p>
<h2>Set trust scp/ssh for rc2 instance on your own VPS</h2>
<p>local: ssh-keygen -t dsa -f $HOME/.ssh/id_dsa -P &#8221;<br />
remote:(~/.ssh) cat id_dsa &gt;&gt; authorized_keys</p>
<p dir="ltr">ref: <a href="http://www.csua.berkeley.edu/%7Eranga/notes/ssh_nopass.html">http://www.csua.berkeley.edu/~ranga/notes/ssh_nopass.html</a></p>
<h2>Bad news, spot instance is not included in free tier.</h2>
<p>All the saving cost export I spent so far seems useless, and I will revisit this post when my 12 month free tier expired.<br />
<img src="https://lh3.googleusercontent.com/R64xCglEbOq_-NJhBFC6bDZ7PYvDWBpliz-9h81XFwlgVFEuJtcsx08hqrnSf2EoQ8jJtM2J8OHs-oZLaVyUl_ridRgQKFsg2_oIeOCSujh2mBluywE" alt="" width="669px;" height="419px;" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/1662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/1662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/maonet.wordpress.com/1662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/maonet.wordpress.com/1662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/maonet.wordpress.com/1662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/maonet.wordpress.com/1662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/1662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/1662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/1662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/1662/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/1662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/1662/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1662&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/05/25/aws-spot-instance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>

		<media:content url="https://lh4.googleusercontent.com/hpGwg16ygHcCnE8BD7yTuh4rTQQpc6KJHF_RBy4r5P1pSkFQrR3ffAMg9k7Ogwwv0HvSa4y9-4BxLJP20EcKyIwbN0hCrc5f9uvqAAvbXjtClApb5IA" medium="image" />

		<media:content url="https://lh3.googleusercontent.com/R64xCglEbOq_-NJhBFC6bDZ7PYvDWBpliz-9h81XFwlgVFEuJtcsx08hqrnSf2EoQ8jJtM2J8OHs-oZLaVyUl_ridRgQKFsg2_oIeOCSujh2mBluywE" medium="image" />
	</item>
		<item>
		<title>Push notification coding memo</title>
		<link>http://frankmao.com/2012/04/30/push-notification-coding-memo/</link>
		<comments>http://frankmao.com/2012/04/30/push-notification-coding-memo/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 15:33:48 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1655</guid>
		<description><![CDATA[Push messages are all from apple push server, one for each environment: sandbox and production. You need to build a push client to send message to Apple push server in PHP or ruby. Push client needs ssl certificate from apple. To get it, enable push feature in your AppId, import cert, then create new provision [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1655&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="padding-left:30px;">Push messages are all from apple push server, one for each environment: sandbox and production.</p>
<p style="padding-left:30px;">You need to build a push client to send message to Apple push server in PHP or ruby. Push client needs ssl certificate from apple. To get it, enable push feature in your AppId, import cert, then create new provision file.</p>
<p style="padding-left:30px;">Considering Xtify or UrbanAirship if you or your clients don&#8217;t have your/their own VPS. Both Xtify and UrbanAirship offer free tier membership, 1 million push messages per month.</p>
<p style="padding-left:30px;">Documentation from Xtify and UrbanAirship are a little bit different, Xtify needs you export private key under APN certificate item as push certificate, while <a href="https://docs.urbanairship.com/display/DOCS/Getting+Started%3A+iOS%3A+Push">UrbanAirship document</a> stated that you need to export the APN certificate itself (not the private key under), otherwise when exporting certificate, it will report error saying you are importing a development certificate.</p>
<p style="padding-left:30px;">Xtify doesn&#8217;t need credit card to register, UrbanAirship won&#8217;t allow you create App for production until you give away your credit card number.</p>
<p style="padding-left:30px;">Xtify has a magic schedule settings, forgetting set this will cause not sending message, ensure to activate it and check measurement report before you revoke your certificate and start over.</p>
<p style="padding-left:30px;">Support response from UrbanAirship is mush faster, my first question was answered in 3 hours, amazing.</p>
<p style="padding-left:30px;">Call Apple feedback service frequently to eliminate inactive device from your send out list.</p>
<p style="padding-left:30px;">
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/1655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/1655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/maonet.wordpress.com/1655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/maonet.wordpress.com/1655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/maonet.wordpress.com/1655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/maonet.wordpress.com/1655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/1655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/1655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/1655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/1655/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/1655/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/1655/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1655&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/04/30/push-notification-coding-memo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>
	</item>
		<item>
		<title>Revisit Date.parse, time zone, dst, and sqlite issues</title>
		<link>http://frankmao.com/2012/04/19/revisit-date-parse-time-zone-dst-and-sqlite-issues/</link>
		<comments>http://frankmao.com/2012/04/19/revisit-date-parse-time-zone-dst-and-sqlite-issues/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 20:45:03 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Sqlite]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1651</guid>
		<description><![CDATA[I thought Date.parse() was very easy, until some time zone and DST (daylight saving time) issues came to me today. First problem, missing time zone means UTC DateTime.parse(&#8220;2012-04-19 12:12:12&#8243;) is default to UTC, I need find out the correct time zone. OK, MDT for now. But, what if DST finished? That means I can&#8217;t hard [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1651&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I thought Date.parse() was very easy, until some time zone and DST (daylight saving time) issues came to me today.</p>
<h2>First problem, missing time zone means UTC</h2>
<p>DateTime.parse(&#8220;2012-04-19 12:12:12&#8243;) is default to UTC, I need find out the correct time zone. OK, MDT for now. But, what if DST finished?</p>
<p>That means I can&#8217;t hard code MDT in date string.</p>
<p>Need to find out a way to check if date_to_parse is in DST period or not.</p>
<p>Assuming the machine in which the code is running on is at the same time zone as the date_to_parse.</p>
<p><pre class="brush: ruby;">
        date_s = &quot;2012-04-19 12:12:12&quot;
        date = DateTime.parse(&quot;#{date_s}&quot;)
        time_zone = Time.local(date.year, date.month, date.day).isdst ? &quot;MDT&quot; : &quot;MST&quot;
        puts DateTime.parse(&quot;#{date_s} #{time_zone}&quot;)

</pre></p>
<p>OK, it works very well. I don&#8217;t have to worry about to change the time zone back when Winter is coming.</p>
<h2>Second issue, date in sqlite3.</h2>
<p>Sqlite3 doesn&#8217; t have a datetime internal date type. It convert it to string or integer.</p>
<p>So when saving date into sqlite3, right way should be either convert date to integer (unix epoch),<br />
<pre class="brush: ruby;">Time.parse(date_s).to_i</pre><br />
or convert it to string WITH TIME ZONE.<br />
<pre class="brush: ruby;">date.strftime(&quot;%Y-%m-%d %H:%M:%S %Z&quot;)</pre></p>
<h2>Third one, comparing date in sqlite3</h2>
<p>Remember no date_diff in sqlite3, date is either string (not compare friendly) or integer.</p>
<p><pre class="brush: sql;">

select date, strftime('%s',date) as orig_date,strftime('%s','#{occurrence.date.strftime(&quot;%Y-%m-%d %H:%M:%S %Z&quot;)}') as new_date from occurrence
where abs(orig_date - new_date) &lt; 3600 * 10

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1651/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/1651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/1651/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/maonet.wordpress.com/1651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/maonet.wordpress.com/1651/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/maonet.wordpress.com/1651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/maonet.wordpress.com/1651/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/1651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/1651/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/1651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/1651/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/1651/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/1651/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1651&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/04/19/revisit-date-parse-time-zone-dst-and-sqlite-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>
	</item>
		<item>
		<title>SSL3_GET_SERVER_CERTIFICATE  error in JJ&#8217;s VPS manager</title>
		<link>http://frankmao.com/2012/04/13/ssl3_get_server_certificate-error-in-jjs-vps-manager/</link>
		<comments>http://frankmao.com/2012/04/13/ssl3_get_server_certificate-error-in-jjs-vps-manager/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 14:58:39 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[VPS]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1647</guid>
		<description><![CDATA[If you like me own a busy VPS at dreamhost, you probably already falling in love with JJ&#8217;s VPS manager, a tool to dynamically adjust server memory according server load. Everything works OK until today I got SSL3_GET_SERVER_CERTIFICATE error. CURL encountered an error. &#8216;SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1647&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you like me own a busy VPS at dreamhost, you probably already falling in love with JJ&#8217;s VPS manager, a tool to dynamically adjust server memory according server load.</p>
<p>Everything works OK until today I got SSL3_GET_SERVER_CERTIFICATE error.</p>
<blockquote><p>CURL encountered an error. &#8216;SSL certificate problem, verify that the CA cert is OK. Details:<br />
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed&#8217;</p></blockquote>
<p>Because it happens on my two different VPSs,  I doubt it&#8217;s Dreamhost API server problem. Google results turn out there is a way to ignore server certificate.</p>
<p>Quick workaround:</p>
<ol>
<li> vi ~jj/libs/DH_API/dreamhost.api.php</li>
<li>find curl_setopt</li>
<li>add the following 2 lines<br />
<span style="font-family:Courier, Monospaced;">curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);<br />
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); </span></li>
</ol>
<p>Restart daemon, JJ seems happy now.</p>
<p>I know it&#8217;s not safe, if you know what&#8217;s happening on Dreamhost API server, please notify me to add those check back.</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1647/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1647/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/1647/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/1647/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/maonet.wordpress.com/1647/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/maonet.wordpress.com/1647/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/maonet.wordpress.com/1647/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/maonet.wordpress.com/1647/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/1647/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/1647/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/1647/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/1647/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/1647/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/1647/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1647&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/04/13/ssl3_get_server_certificate-error-in-jjs-vps-manager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>
	</item>
		<item>
		<title>Convert Validator from EVil to DataAnnotation</title>
		<link>http://frankmao.com/2012/04/10/convert-validator-from-evil-to-dataannotation/</link>
		<comments>http://frankmao.com/2012/04/10/convert-validator-from-evil-to-dataannotation/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 15:20:25 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[dotNet]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1644</guid>
		<description><![CDATA[We were using Evil Validation library for a while, works OK, but doesn&#8217;t support WPF/Silverlight and MVC very well. Fortunately, it&#8217;s not too hard to convert it to DataAnnotations. Evil code example: To DataAnnotation:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1644&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We were using <a href="http://evil.codeplex.com/">Evil Validation library</a> for a while, works OK, but doesn&#8217;t support WPF/Silverlight and MVC very well. Fortunately, it&#8217;s not too hard to convert it to DataAnnotations.</p>
<p>Evil code example:</p>
<p><pre class="brush: csharp;">

    class EmailAddress
    {
        public EmailAddress(string value)
        {
            Value = value;
        }

        [ValidateRegex(@&quot;\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}&quot;, &quot;Invalid recipient email address&quot;)]
        public string Value { get; set; }

    }

        public static bool ValidateEmailAddress(string emailAddress)
        {
              return ((new EmailAddress(emailAddress)).IsValid());
        }

</pre></pre>
<p>To DataAnnotation:<br />
<pre class="brush: csharp;">

    class EmailAddress
    {
        public EmailAddress(string value)
        {
            Value = value;
        }

        [RegularExpression(@&quot;\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}&quot;, ErrorMessage = &quot;Invalid recipient email address&quot;)]
        public string Value { get; set; }

    }

       public static bool ValidateEmailAddress(string emailAddress)
        {

            EmailAddress emailToValidate = new EmailAddress(emailAddress);

            // Watchout the last bool flag, indicate whether validate all properties. (What else? just modified one?)
            return Validator.TryValidateObject(emailToValidate, new ValidationContext(emailToValidate, null, null), null, true);

            // For one property model, we can also use this syntax.
            ValidationContext validationContext = new ValidationContext(emailToValidate, null, null);
            validationContext.MemberName = &quot;Value&quot;;
            return Validator.TryValidateProperty(emailAddress,
                validationContext
                , null);

        }
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1644/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1644/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/1644/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/1644/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/maonet.wordpress.com/1644/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/maonet.wordpress.com/1644/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/maonet.wordpress.com/1644/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/maonet.wordpress.com/1644/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/1644/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/1644/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/1644/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/1644/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/1644/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/1644/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1644&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/04/10/convert-validator-from-evil-to-dataannotation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>
	</item>
		<item>
		<title>Invalid Product Id?</title>
		<link>http://frankmao.com/2012/03/30/invalid-product-id/</link>
		<comments>http://frankmao.com/2012/03/30/invalid-product-id/#comments</comments>
		<pubDate>Sat, 31 Mar 2012 04:40:16 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1639</guid>
		<description><![CDATA[I&#8217;ve re-visited this same blog post again and again at least 10 times since I started iOS developing, every time with different answer, to save me search time in the future, I quoted the list here and added my 2 cents for how to solve invalid-product-id problem. List from Troy: Have you enabled In-App Purchases [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1639&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve re-visited <a href="http://troybrant.net/blog/2010/01/invalid-product-ids/">this same blog post</a> again and again at least 10 times since I started iOS developing, every time with different answer, to save me search time in the future, I quoted the list here and added my 2 cents for how to solve invalid-product-id problem.</p>
<p>List from Troy:</p>
<ul>
<li>Have you enabled In-App Purchases for your App ID?</li>
<li>Have you checked Cleared for Sale for your product?</li>
<li>Have you submitted (and optionally rejected) your application binary? <span style="color:#ff6600;">(I don&#8217;t think this is necessary, in fact, after you submit, you can add new product into the app anymore)</span></li>
<li>Does your project’s .plist Bundle ID match your App ID?  <span style="color:#ff6600;">(This is what I got today, App ID and bundle ID were created by another guy)</span></li>
<li>Have you generated and installed a new provisioning profile for the new App ID? <span style="color:#ff6600;">(got me 2 times)</span></li>
<li>Have you configured your project to code sign using this new provisioning profile? <span style="color:#ff6600;">(got me 1 time)</span></li>
<li>Are you building for iPhone OS 3.0 or above?</li>
<li>Are you using the full product ID when when making an <code>SKProductRequest</code>? <span style="color:#ff6600;">(got me 1 time)</span></li>
<li>Have you waited several hours since adding your product to iTunes Connect? <span style="color:#ff6600;"> (got me 1 time)</span></li>
<li>Are your bank details active on iTunes Connect? (via <a href="http://troybrant.net/blog/2010/01/invalid-product-ids/#comment-22">Mark</a>)</li>
<li>Have you tried deleting the app from your device and reinstalling? (via <a href="http://troybrant.net/blog/2010/01/invalid-product-ids/#comment-356">Hector</a>, <a href="http://troybrant.net/blog/2010/01/invalid-product-ids/#comment-883">S3B</a>, <a href="http://troybrant.net/blog/2010/01/invalid-product-ids/#comment-1001">Alex O</a>, <a href="http://troybrant.net/blog/2010/01/invalid-product-ids/#comment-1070">Joe</a>, and <a href="http://troybrant.net/blog/2010/01/invalid-product-ids/#comment-1243">Alberto</a>) <span style="color:#ff6600;">(This solved my problem 3 times)</span></li>
<li>Is your device jailbroken? If so, you need to revert the jailbreak for IAP to work. (via <a href="http://troybrant.net/blog/2010/01/invalid-product-ids/#comment-5763">oh my god</a>, <a href="http://troybrant.net/blog/2010/01/invalid-product-ids/#comment-5921">Roman</a>, and <a href="http://troybrant.net/blog/2010/01/invalid-product-ids/#comment-6210">xfze</a>)</li>
</ul>
<p>&nbsp;</p>
<p>My suggestions:</p>
<ol>
<li>Test listing product from simulator first, then move on to device. Ensure product id is OK.</li>
<li>Uninstall can fix the problem happened on device most of time.</li>
<li>Delay on new created product happens, at least to me 2 times, but not always, check your local settings carefully following the list above.</li>
<li>Once old product id being removed, the new product id still can not conflict with the old id, it&#8217;s a soft delete in Apple&#8217;s system.</li>
<li>Don&#8217;t bother auto-renewable subscription product, unless your are building a newsstand/magazine app.</li>
<li>Don&#8217;t be too greedy on consumable in-app purchase product, start small, you can add big one in later version. Apple is very strict on those coin-like products.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/1639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/1639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/maonet.wordpress.com/1639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/maonet.wordpress.com/1639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/maonet.wordpress.com/1639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/maonet.wordpress.com/1639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/1639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/1639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/1639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/1639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/1639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/1639/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1639&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/03/30/invalid-product-id/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>
	</item>
		<item>
		<title>Build an iOS app access only Drupal CMS site</title>
		<link>http://frankmao.com/2012/03/28/build-an-ios-app-access-only-drupal-cms-site/</link>
		<comments>http://frankmao.com/2012/03/28/build-an-ios-app-access-only-drupal-cms-site/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 17:59:37 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1624</guid>
		<description><![CDATA[Drupal is based on mysql, in the new version 7 it gives option to choose sqlite. Either way, connecting from iOS app directly to Drupal db is a problem. Somebody posted mysql library for mac OS, even for iSO, but it&#8217;s not public API. Apple won&#8217;t like it. Solution: RESTful service on Drupal Installation process [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1624&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Drupal is based on mysql, in the new version 7 it gives option to choose sqlite. Either way, connecting from iOS app directly to Drupal db is a problem.</p>
<p>Somebody posted mysql library for mac OS, even for iSO, but it&#8217;s not public API. Apple won&#8217;t like it.</p>
<h2>Solution: RESTful service on Drupal</h2>
<p>Installation process is painful, because the missing sypc.php can&#8217;t be done through Update management web interface module.</p>
<p>Turn on RESTful service, getting node/1 is not a problem, but I couldn&#8217;t make user/1 to work, later I realized it&#8217;s permission problem, had to grant &#8216;pull user profile&#8217; right to anonymous user.</p>
<p><a href="http://wolfgangziegler.net/restful-web-services-for-Drupal">The official doc </a>stated that RESTful comes with basic authentication sub module, but I couldn&#8217;t find it, the only one available in RESTful config panel is Session Authentication, which means admin must log in to be able to call user/1</p>
<p>Tried http://username:passwrod@mysite/test/user/1, and using code to pass credential, like this code in ruby,  no good.</p>
<p><pre class="brush: ruby;">

uri = URI('http://test.site.com/drupal/rest/user/1.json')

req = Net::HTTP::Get.new(uri.request_uri)

req.basic_auth 'user', 'psw'

res = Net::HTTP.start(uri.host, uri.port) {|http|
http.request(req)
}
p res
puts res.body

</pre></p>
<p>It seems Drupal RESTful service is having problem in basic authentication. Or I just too dumb to figure it out.</p>
<p><a href="http://maonet.files.wordpress.com/2012/03/drupal_rest_basi_auth.png"><img class="aligncenter size-full wp-image-1625" title="drupal_rest_basi_auth" src="http://maonet.files.wordpress.com/2012/03/drupal_rest_basi_auth.png?w=600&h=635" alt="" width="600" height="635" /></a></p>
<p>My project doesn&#8217;t have a requirement to protect web content, which means those nodes should be only available to iOS client.</p>
<h2>Work Around: <a href="http://drupal.org/project/securesite">Secure site </a>module</h2>
<p>One problem to fix is to apply patch for non-Apache-module mode php site, mine is CGI, adding</p>
<blockquote><p>RewriteRule .* &#8211; [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]</p></blockquote>
<p>to .htaccess, tah-dah, it works!</p>
<p>While the database setup in secure site module is still too messy to me, I just end up with setup a highly secured anonymous user for now. Anyway, content has been protected.</p>
<h2>About testing Drual REST servcie</h2>
<p>GET is fine, but http://test.site.com/drupal/rest/taxonomy_term/selectNodes is a POST only URI.</p>
<p>Test method 1: download Poster Firfox add-on, set Content Type to application/x-www-form-urlencoded, parameter to tid=1</p>
<p><a href="http://maonet.files.wordpress.com/2012/03/poster_rest_test.png"><img class="aligncenter size-full wp-image-1626" title="poster_rest_test" src="http://maonet.files.wordpress.com/2012/03/poster_rest_test.png?w=600" alt=""   /></a></p>
<p>To get json result, set headers to application/json.</p>
<p>Test method 2:</p>
<p>curl http://test.site.com/drupal/rest/taxonomy_term/selectNodes &#8211;form &#8216;tid=1&#8242; -u user:pwd &#8211;header &#8216;Accept:application/xml&#8217;</p>
<p>Watch out, by default form-urlencoded is not checked after installation.</p>
<p><a href="http://maonet.files.wordpress.com/2012/03/rest_form_urlencoded.png"><img class="aligncenter size-full wp-image-1627" title="rest_form_urlencoded" src="http://maonet.files.wordpress.com/2012/03/rest_form_urlencoded.png?w=600&h=731" alt="" width="600" height="731" /></a></p>
<p>Passing json as request data is much easier.</p>
<p><a href="http://maonet.files.wordpress.com/2012/03/poster_json.png"><img class="aligncenter size-full wp-image-1629" title="poster_json" src="http://maonet.files.wordpress.com/2012/03/poster_json.png?w=600" alt=""   /></a></p>
<p>curl http://test.site.com/drupal/rest/taxonomy_term/selectNodes &#8211;d {&#8216;tid&#8217;:1} -u user:pwd &#8211;header &#8216;Accept:application/json&#8217;</p>
<p>doesn&#8217;t work for me, don&#8217;t know what missing.</p>
<h2>Back to Session Authentication</h2>
<p>According to <a href="http://drupal.org/node/790416#comment-3809568">this comment</a>, to properly setup a session in RESTfule service is this:</p>
<ol>
<li>Get session id through an empty body POST to rest/system/connect, parse response to get session id. (Must set req['Accept'] = &#8216;application/json&#8217; or xml if using ruby)</li>
<li>POST to rest/user/login with parms like sessid=2c038ba6326f12f132502e98434857cc&amp;username=&lt;username&gt;&amp;password=&lt;password&gt;</li>
<li>Parse body.</li>
</ol>
<p>This works, but how to keeping session in the following rest request is not clear, more specific, how to pass sess id in request?</p>
<p>Here is another way based on Michael Cole&#8217;s comment, calling login directly, his example is saving session name/id in a cookie file, then passing it as session cookie in the following request. If actually can be passed as Cookie attribute in header.</p>
<p>Here is my explanation in ruby code,</p>
<p><pre class="brush: ruby;">

  def login(username, psw)
    uri = URI(&quot;http://test.mysite.com/drupal/rest/u/login.json&quot;)

    req = Net::HTTP::Post.new(uri.request_uri)

    req.content_type = 'application/x-www-form-urlencoded'
    req.set_form_data(&quot;username&quot; =&gt; username, 'password' =&gt; psw)
    #req['Accept'] = 'application/json'  #another style if url not end with .json

    res = Net::HTTP.start(uri.host, uri.port) {|http|
      http.request(req)
    }

    if Net::HTTPOK
       json = JSON(res.body)

      @session_id = json[&quot;sessid&quot;]
      @session_name = json[&quot;session_name&quot;]
    end
  end

  def get_post(id)
    uri = URI(&quot;http://test.mysite.com/drupal/rest/node/#{id}.json&quot;)

    req = Net::HTTP::Get.new(uri.request_uri)
    req[&quot;Cookie&quot;] =  &quot;#{@session_name}=#{@session_id}&quot;
    res = Net::HTTP.start(uri.host, uri.port) {|http|

      http.request(req)
    }

    if Net::HTTPOK

       json = JSON(res.body)

      return json[&quot;body&quot;][&quot;und&quot;][0][&quot;safe_value&quot;]
    end

  end

</pre></p>
<p><a href="http://drupal.stackexchange.com/questions/4718/how-to-create-test-endpoint">Best doc</a> I found on drupal REST service.</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/1624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/1624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/maonet.wordpress.com/1624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/maonet.wordpress.com/1624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/maonet.wordpress.com/1624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/maonet.wordpress.com/1624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/1624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/1624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/1624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/1624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/1624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/1624/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1624&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/03/28/build-an-ios-app-access-only-drupal-cms-site/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>

		<media:content url="http://maonet.files.wordpress.com/2012/03/drupal_rest_basi_auth.png" medium="image">
			<media:title type="html">drupal_rest_basi_auth</media:title>
		</media:content>

		<media:content url="http://maonet.files.wordpress.com/2012/03/poster_rest_test.png" medium="image">
			<media:title type="html">poster_rest_test</media:title>
		</media:content>

		<media:content url="http://maonet.files.wordpress.com/2012/03/rest_form_urlencoded.png" medium="image">
			<media:title type="html">rest_form_urlencoded</media:title>
		</media:content>

		<media:content url="http://maonet.files.wordpress.com/2012/03/poster_json.png" medium="image">
			<media:title type="html">poster_json</media:title>
		</media:content>
	</item>
		<item>
		<title>Apple TV, AirPlay</title>
		<link>http://frankmao.com/2012/03/19/my-reviews-on-new-apple-tv/</link>
		<comments>http://frankmao.com/2012/03/19/my-reviews-on-new-apple-tv/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 17:14:22 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AppleTV]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1619</guid>
		<description><![CDATA[I need to do an iOS dev presentation this weekend at a local user group, one problem to solve is to connect my iPad to their projector. I know there is iPad to VGA or HDMI cable, cost about $40-50, Apple TV seems a much better solution, AirPlay should solve the problem easily. Hook up [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1619&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I need to do an iOS dev presentation this weekend at a local user group, one problem to solve is to connect my iPad to their projector. I know there is iPad to VGA or HDMI cable, cost about $40-50, Apple TV seems a much better solution, AirPlay should solve the problem easily.</p>
<p>Hook up AppleTV to my receiver is easy, only wifi password basically. I need to turn on the iTunes Home sharing feature on my MacMini, then on AppleTV I can see that shared iTunes library. Surprised Apple requests AppleID to turn home sharing on, all info save on their server?</p>
<p>Watched a few trailers, Hunger Games, AV quality is awesome. My daughter quickly took it over and starting watch youtube on AppleTV.</p>
<p>One annoying limitation for Youtube on AppleTV is no Chinese input, so can&#8217;t search Youtube with Chinese titles. Solution is login with youtube id, then can play youtube playlist created on somewhere else.</p>
<p>Remote control for AppleTV is cute, but too small for my hand, download the app called remote for my iPad, I can then control AppleTV on iPad. It&#8217;s good for playing music without turn on real TV.</p>
<p>About AirPlay, not many apps support this feature yet. Photos is one of them, but not Videos! Some people end up with converting their powerpoint file to separated images to be able to play on project through AirPlay.</p>
<p>Luckily, I have a iPad2. Turn on AirPlay mirroring feature on it and everything shows on iPad can be outputted to TV. Cool!</p>
<p>The app I developed, including iClip and maodou, are using iOS native media player, AirPlay doesn&#8217;t have any problem. But one of the app I purchased called OPlayer, AirPlay only works for the sound. no video. I had to back to another app called streamtome to play those non-h264 videos on my computer.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1619/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/1619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/1619/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/maonet.wordpress.com/1619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/maonet.wordpress.com/1619/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/maonet.wordpress.com/1619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/maonet.wordpress.com/1619/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/1619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/1619/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/1619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/1619/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/1619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/1619/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1619&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/03/19/my-reviews-on-new-apple-tv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>
	</item>
		<item>
		<title>Sqlite and CoreData in iOS, repository pattern</title>
		<link>http://frankmao.com/2012/03/16/sqlite-and-coredata-in-ios-repository-pattern/</link>
		<comments>http://frankmao.com/2012/03/16/sqlite-and-coredata-in-ios-repository-pattern/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 19:49:48 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[CoreData]]></category>
		<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1610</guid>
		<description><![CDATA[I haven&#8217;t see too many articles talking about iOS Core-Data development yet, so I documented something important here for future reference.  No need to create ID property as identity column for your model, in fact, id is a reserved keyword for cocoa, IDE will looks weird for id property in model. core-data will generate a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1610&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t see too many articles talking about iOS Core-Data development yet, so I documented something important here for future reference.</p>
<ol>
<li> No need to create ID property as identity column for your model, in fact, id is a reserved keyword for cocoa, IDE will looks weird for id property in model. core-data will generate a few extra columns in your model table, including ZID, Z&#8230;, all  have a Z prefix.</li>
<li>All number like fields will be mapped to NSNumber.</li>
<li>Create app with core-data support, in XCode4, single view app template doesn&#8217;t have this core-data support option, try create another project in different project template, then copy the generated core-data code from appDelegate into your project.</li>
<li>If you have your own existing database which will be installed with app bundle, you need to manually copy it from bundle to document folder to make it writable.</li>
<li>New object needs to save into database later should created by insertNewObjectForEntityForName.</li>
<li>Hold the managedObjectContext till the app terminate, that&#8217;s why core-data code were in appDeledate, if move into you own class, create retain property.</li>
</ol>
<pre></pre>
<p>Personnly, I like to implement repository pattern for all coredata operations, including initialize. My sample repository looks like this:</p>
<p><pre class="brush: cpp;">
@interface iCWOccurrenceRepository()
- (NSMutableArray *)retrieveAllOccurrencesForCity:(NSString*)city sinceDate:(NSDate*)startDate;
@end

@implementation iCWOccurrenceRepository

@synthesize managedObjectContext = __managedObjectContext;
@synthesize managedObjectModel = __managedObjectModel;
@synthesize persistentStoreCoordinator = __persistentStoreCoordinator;

NSString * DBNAME = @&quot;mydb.sqlite&quot;;

- (void)saveANew:(NSArray*) line{
    NSManagedObjectContext * context = self.managedObjectContext;
    NSManagedObject *newOccurrence = [NSEntityDescription
                                      insertNewObjectForEntityForName:@&quot;Occurrence&quot;
                                      inManagedObjectContext:context];

    Occurrence* oToSave = ((Occurrence*)newOccurrence);
    oToSave.id = [NSNumber numberWithInt:[[line objectAtIndex:0] intValue]];
    oToSave.city = [line objectAtIndex:1];
//...
    [self saveContext];

}
- (void)saveContext
{
    NSError *error = nil;
    NSManagedObjectContext *managedObjectContext = __managedObjectContext;
    if (managedObjectContext != nil)
    {
        if ([managedObjectContext hasChanges] &amp;&amp; ![managedObjectContext save:&amp;error])
        {
            /*
             Replace this implementation with code to handle the error appropriately.

             abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
             */
            NSLog(@&quot;Unresolved error %@, %@&quot;, error, [error userInfo]);
            abort();
        }
    }
}

#pragma mark - Core Data stack

/**
 Returns the managed object context for the application.
 If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application.
 */
- (NSManagedObjectContext *)managedObjectContext
{
    if (__managedObjectContext != nil)
    {
        return __managedObjectContext;
    }

    NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
    if (coordinator != nil)
    {
        __managedObjectContext = [[NSManagedObjectContext alloc] init];
        [__managedObjectContext setPersistentStoreCoordinator:coordinator];
    }
    return __managedObjectContext;
}

/**
 Returns the managed object model for the application.
 If the model doesn't already exist, it is created from the application's model.
 */
- (NSManagedObjectModel *)managedObjectModel
{
    if (__managedObjectModel != nil)
    {
        return __managedObjectModel;
    }
    NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@&quot;iCW&quot; withExtension:@&quot;momd&quot;];
    __managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
    return __managedObjectModel;
}

/**
 Returns the persistent store coordinator for the application.
 If the coordinator doesn't already exist, it is created and the application's store added to it.
 */
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
    if (__persistentStoreCoordinator != nil)
    {
        return __persistentStoreCoordinator;
    }

    NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:DBNAME];

    NSError *error = nil;
    __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
    if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&amp;error])
    {
         [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

        NSLog(@&quot;Unresolved error %@, %@&quot;, error, [error userInfo]);
        abort();
    }

    return __persistentStoreCoordinator;
}

#pragma mark - Application's Documents directory

/**
 Returns the URL to the application's Documents directory.
 */
- (NSURL *)applicationDocumentsDirectory
{
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}

-(void)createEditableCopyOfDatabaseIfNeeded {
	//
	NSFileManager *fileManager = [NSFileManager defaultManager];
	NSURL *documentDirectory = [self applicationDocumentsDirectory];
	NSString *writeableDBPath = [[documentDirectory
								  URLByAppendingPathComponent:DBNAME]
								 path];
	NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath]
							   stringByAppendingPathComponent:DBNAME];

	BOOL defaultDbExists = [fileManager fileExistsAtPath:defaultDBPath];
	BOOL dbExistsInDocFolder = [fileManager fileExistsAtPath:writeableDBPath];

	if (!dbExistsInDocFolder &amp;&amp; defaultDbExists) {

		NSError *error;
		BOOL success = [fileManager copyItemAtPath:defaultDBPath toPath:writeableDBPath error:&amp;error];

		if (!success) {
            NSAssert1(0, @&quot;Failed to create writable database file with message '%@'.&quot;,
                      [error localizedDescription]);
		}
	}

}

- (NSMutableArray *)retrieveAllOccurrencesForCity:(NSString*)city sinceDate:(NSDate*)startDate{

	NSManagedObjectContext *managedObjectContext = self.managedObjectContext;
	NSFetchRequest *request = [[NSFetchRequest alloc] init];
	NSEntityDescription *entity = [NSEntityDescription entityForName:@&quot;Occurrence&quot;
											  inManagedObjectContext:managedObjectContext];
	[request setEntity:entity];

	NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc]
										initWithKey:@&quot;id&quot; ascending:NO];

	NSArray *sortDescriptors = [[NSArray alloc]
								initWithObjects:sortDescriptor, nil];

	[request setSortDescriptors:sortDescriptors];

	NSPredicate *bPredicate =
    [NSPredicate predicateWithFormat:@&quot;city == %@ and date &gt; %@&quot;, city, startDate];

    [request setPredicate:bPredicate];

	NSError *error;
	NSMutableArray *fetchResults = [[managedObjectContext executeFetchRequest:request
                                                                        error:&amp;error] mutableCopy] ;

	if (fetchResults == nil) {
		// handle the error
	}
	return fetchResults;

}
@end
</pre></p>
<p>Again, this repository class needs to be a strong retain property in caller.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1610/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/1610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/1610/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/maonet.wordpress.com/1610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/maonet.wordpress.com/1610/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/maonet.wordpress.com/1610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/maonet.wordpress.com/1610/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/1610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/1610/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/1610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/1610/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/1610/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/1610/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1610&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/03/16/sqlite-and-coredata-in-ios-repository-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>
	</item>
		<item>
		<title>Lookup in db or in code (enum)?</title>
		<link>http://frankmao.com/2012/02/23/lookup-in-db-or-in-code-enum/</link>
		<comments>http://frankmao.com/2012/02/23/lookup-in-db-or-in-code-enum/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 16:48:18 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1605</guid>
		<description><![CDATA[Maybe this is a solved problem already, but I couldn&#8217;t figure it out until today. With massive usage of NHibernate, lookup in db or in code always appear as a puzzle to me. For example, given a lookup dictionary like mime type: text/plain, text/html, image/gif and other stuff. It make sense to save all those [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1605&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Maybe this is a solved problem already, but I couldn&#8217;t figure it out until today. With massive usage of NHibernate, lookup in db or in code always appear as a puzzle to me. For example, given a lookup dictionary like mime type: text/plain, text/html, image/gif and other stuff. It make sense to save all those data into a table then enable foreign key on all referenced tables. But, in code, those mime type id itself will appear like magic number, I don&#8217;t likes this.</p>
<p>So, creating an enum contains all items solve the magic number issue, partly, and introduce another sync concern, what if data in db and enum in code out of sync?</p>
<p><a href="http://openlandscape.net/2011/04/16/hey-nhibernate-dont-mess-with-my-enums/">This post</a> demos a brilliant idea of creating enum on the fly, but mime value has slash in it, this solution doesn&#8217;t work. Also, wrapper class around enum seems unnecessary.</p>
<p>Based on the suggestion from <a href="http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/290534b6-11e5-4a26-8334-9cbb422337a2/">this post</a>. here comes my solution,</p>
<p><pre class="brush: csharp;">

   public enum MimeType
    {
        [Description(&quot;application/octet-stream&quot;)] ApplicationOctetStream,
        [Description(&quot;text/plain&quot;)] TextPlain = 1,
        [Description(&quot;text/html&quot;)] TextHtml,
        [Description(&quot;application/pdf&quot;)] ApplicationPdf,
        [Description(&quot;application/vnd.ms-excel&quot;)] ApplicationVndMsExcel,
        [Description(&quot;image/gif&quot;)] ImageGif,
        [Description(&quot;image/jpeg&quot;)] ImageJpeg,
        [Description(&quot;application/rtf&quot;)] ApplicationRtf,
        [Description(&quot;application/zip&quot;)] ApplicationZip,
        [Description(&quot;application/msword&quot;)] ApplicationMsword,
        [Description(&quot;application/mspowerpoint&quot;)] ApplicationMspowerpoint
    }

    /// &lt;summary&gt;
    /// Extension methods container for enum used to check synchronization between enum in code and data in db.
    /// see usage in should_fetch_all_mime_types() of EmailQueueRepositoryTest class
    /// &lt;/summary&gt;
    public static class MimeTypeEx
    {
        public static MimeType ToMimeTypeValue(this string value)
        {
            foreach (FieldInfo fi in typeof (MimeType).GetFields())
            {
                if (!fi.IsStatic)
                {
                    continue;
                }

                object[] attrs = fi.GetCustomAttributes(typeof (DescriptionAttribute), false);
                if (attrs == null || attrs.Length &lt;= 0)
                {
                    continue;
                }

                var descr = (DescriptionAttribute) attrs[0];
                if (0 == string.Compare(value.Trim(), descr.Description))
                    // in case varchar type. trim it before compare.
                {
                    return (MimeType) fi.GetValue(null);
                }
            }

            throw new InvalidDataException(value);
            //return MimeType.Unknown;
        }

        public static string ToMimeTypeString(this MimeType value)
        {
            foreach (FieldInfo fi in typeof (MimeType).GetFields())
            {
                if (!fi.IsStatic || (MimeType) fi.GetValue(null) != value)
                {
                    continue;
                }

                object[] attrs = fi.GetCustomAttributes(typeof (DescriptionAttribute), false);
                if (attrs == null || attrs.Length &lt;= 0)
                {
                    continue;
                }

                var descr = (DescriptionAttribute) attrs[0];
                return descr.Description;
            }

            return string.Empty;
        }
    }

    /// &lt;summary&gt;
    /// Used to read mime type from db, then we can check synchronization with defined enum mime type.
    /// &lt;/summary&gt;
    public class MimeTypeInDb
    {
        public virtual int Id { get; set; }
        public virtual string Name { get; set; }
        public virtual bool BinaryInd { get; set; }
    }

</pre></p>
<p>Test code, similar functionality should be done in app start or somewhere static ctor to ensure the synchronization.</p>
<p><pre class="brush: csharp;">
       [Test]
        public void should_fetch_all_mime_types()
        {
            var results = _repository.FetchAll&lt;MimeTypeInDb&gt;();

            Assert.That(results.Count(), Is.GreaterThan(0));

            foreach (MimeTypeInDb mimeTypeInDb in results)
            {
                Console.WriteLine(mimeTypeInDb.Name.ToMimeTypeValue()); // will throw invalid data exception if enum not found.
            }

            foreach (MimeType mimeType in Enum.GetValues(typeof(MimeType)))
            {
                Console.WriteLine(mimeType.ToMimeTypeString());
                if (! results.Any(x =&gt; x.Name.Trim() == mimeType.ToMimeTypeString()))
                {
                    Assert.Fail(mimeType.ToMimeTypeString() +&quot; not found in db.&quot;);
                }
            }
        }
</pre></p>
<p>About mapping the enum to int in FluentNHibernate:</p>
<p><pre class="brush: csharp;">
  Map(x =&gt; x.MimeType).Column(&quot;mime_type_id&quot;).CustomType&lt;MimeType&gt;();
</pre></p>
<p>Note: using CustomType&lt;int&gt;() also works, but it will cause extra update problem for reading query. NH is trying to set column to enum string value.</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1605/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1605/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/maonet.wordpress.com/1605/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/maonet.wordpress.com/1605/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/maonet.wordpress.com/1605/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/maonet.wordpress.com/1605/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/maonet.wordpress.com/1605/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/maonet.wordpress.com/1605/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/maonet.wordpress.com/1605/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/maonet.wordpress.com/1605/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/maonet.wordpress.com/1605/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/maonet.wordpress.com/1605/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/maonet.wordpress.com/1605/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/maonet.wordpress.com/1605/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1605&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/02/23/lookup-in-db-or-in-code-enum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d41c3a25ca01f1e979e2bc86b8c4ed38?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">FMao</media:title>
		</media:content>
	</item>
	</channel>
</rss>
