<?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>Fri, 10 May 2013 21:03:35 +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>JDeveloper doesn&#8217;t like remote deploying to weblogic</title>
		<link>http://frankmao.com/2013/04/24/jdeveloper-doesnt-like-remote-deploying-to-weblogic/</link>
		<comments>http://frankmao.com/2013/04/24/jdeveloper-doesnt-like-remote-deploying-to-weblogic/#comments</comments>
		<pubDate>Wed, 24 Apr 2013 15:54:00 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[IAM]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1720</guid>
		<description><![CDATA[Error, error, trying to deploy directly to Application server in JDeveloper. It kept failing, had to  deploy a war then install/deploy in weblogic console. [09:39:49 AM] ----  Deployment started.  ---- [09:39:49 AM] Target platform is  (Weblogic 10.3). [09:39:49 AM] Retrieving existing application information [09:39:49 AM] Running dependency analysis... [09:39:49 AM] Building... [09:39:49 AM] Deploying profile... [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1720&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Error, error, trying to deploy directly to Application server in JDeveloper. It kept failing, had to  deploy a war then install/deploy in weblogic console.</p>
<p><code></p>
<p>[09:39:49 AM] ----  Deployment started.  ----<br />
[09:39:49 AM] Target platform is  (Weblogic 10.3).<br />
[09:39:49 AM] Retrieving existing application information<br />
[09:39:49 AM] Running dependency analysis...<br />
[09:39:49 AM] Building...<br />
[09:39:49 AM] Deploying profile...<br />
[09:39:49 AM] Wrote Web Application Module to C:\work\Oracle_IAM\iam\JDeveloper_Projects\Captcha\deploy\captcha.war<br />
[09:39:49 AM] Deploying Application...<br />
[09:39:50 AM] Weblogic Server Exception: weblogic.management.ManagementException: [Deployer:149007]New source location, 'C:\app\oracle\Middleware_IAM\user_projects\domains\IAMDomain\servers\AdminServer\upload\aglc.iam.captcha\1@1\app\captcha.war', cannot be deployed to configured application, 'aglc.iam.captcha [LibSpecVersion=1,LibImplVersion=1]'. The application source is at 'C:\app\oracle\Middleware_IAM\Oracle_IAM1\server\apps\aglc.iam.captcha.war'. Changing the source location is not allowed for a previously attempted deployment. Try deploying without specifying the source.<br />
[09:39:50 AM]   See server logs or server console for more details.<br />
[09:39:50 AM] weblogic.management.ManagementException: [Deployer:149007]New source location, 'C:\app\oracle\Middleware_IAM\user_projects\domains\IAMDomain\servers\AdminServer\upload\aglc.iam.captcha\1@1\app\captcha.war', cannot be deployed to configured application, 'aglc.iam.captcha [LibSpecVersion=1,LibImplVersion=1]'. The application source is at 'C:\app\oracle\Middleware_IAM\Oracle_IAM1\server\apps\aglc.iam.captcha.war'. Changing the source location is not allowed for a previously attempted deployment. Try deploying without specifying the source.<br />
[09:39:50 AM] Deployment cancelled.<br />
[09:39:50 AM] ----  Deployment incomplete  ----.<br />
[09:39:50 AM] Remote deployment failed (oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer)<br />
[09:43:30 AM] ----  Deployment started.  ----<br />
[09:43:30 AM] Target platform is  (Weblogic 10.3).<br />
[09:43:30 AM] Retrieving existing application information<br />
[09:43:30 AM] Running dependency analysis...<br />
[09:43:30 AM] Building...<br />
[09:43:42 AM] Deploying profile...<br />
[09:43:42 AM] Wrote Web Application Module to C:\work\Oracle_IAM\iam\JDeveloper_Projects\Login\deploy\login.war<br />
[09:43:42 AM] Deploying Application...<br />
[09:43:43 AM] Weblogic Server Exception: weblogic.management.ManagementException: [Deployer:149007]New source location, 'C:\app\oracle\Middleware_IAM\user_projects\domains\IAMDomain\servers\AdminServer\app\login.war', cannot be deployed to configured application, 'login'. The application source is at 'C:\app\oracle\Middleware_IAM\user_projects\domains\IAMDomain\servers\AdminServer\upload\login.war'. Changing the source location is not allowed for a previously attempted deployment. Try deploying without specifying the source.<br />
[09:43:43 AM]   See server logs or server console for more details.<br />
[09:43:43 AM] weblogic.management.ManagementException: [Deployer:149007]New source location, 'C:\app\oracle\Middleware_IAM\user_projects\domains\IAMDomain\servers\AdminServer\app\login.war', cannot be deployed to configured application, 'login'. The application source is at 'C:\app\oracle\Middleware_IAM\user_projects\domains\IAMDomain\servers\AdminServer\upload\login.war'. Changing the source location is not allowed for a previously attempted deployment. Try deploying without specifying the source.<br />
[09:43:43 AM] Deployment cancelled.<br />
[09:43:43 AM] ----  Deployment incomplete  ----.<br />
[09:43:43 AM] Remote deployment failed (oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer)</p>
<p> </code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1720/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1720/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1720&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2013/04/24/jdeveloper-doesnt-like-remote-deploying-to-weblogic/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>Install WLS as Windows Service got &#8216;input line too long&#8217; error</title>
		<link>http://frankmao.com/2013/04/18/install-wls-as-windows-service/</link>
		<comments>http://frankmao.com/2013/04/18/install-wls-as-windows-service/#comments</comments>
		<pubDate>Thu, 18 Apr 2013 17:17:04 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[IAM]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1716</guid>
		<description><![CDATA[Following doc: https://support.oracle.com/epmos/faces/ui/km/SearchDocDisplay.jspx?_afrLoop=85729941264881&#038;_afrWindowMode=0&#038;_adf.ctrl-state=u0k53lbwd_130#aref_section23 Setup Node manager as NT Service is easy, just run that cmd under WL_HOME\server\bin\installNodeMgrSvc.cmd. Service created successfully, no errors, start/stop smoothly. The problem popped up when doing Admin server and Managed server. Error: the input line is too long. This is typical JAVA CLASSPATH exceed DOS/WIN environment size limit issue. The number [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1716&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Following doc: <a href="https://support.oracle.com/epmos/faces/ui/km/SearchDocDisplay.jspx?_afrLoop=85729941264881&#038;_afrWindowMode=0&#038;_adf.ctrl-state=u0k53lbwd_130#aref_section23" rel="nofollow">https://support.oracle.com/epmos/faces/ui/km/SearchDocDisplay.jspx?_afrLoop=85729941264881&#038;_afrWindowMode=0&#038;_adf.ctrl-state=u0k53lbwd_130#aref_section23</a></p>
<p>Setup Node manager as NT Service is easy, just run that cmd under WL_HOME\server\bin\installNodeMgrSvc.cmd.</p>
<p>Service created successfully, no errors, start/stop smoothly.</p>
<p>The problem popped up when doing Admin server and Managed server.</p>
<p>Error: the input line is too long.</p>
<p>This is typical JAVA CLASSPATH exceed DOS/WIN environment size limit issue.</p>
<p>The number of characters that can be entered into a single command is limited to 8191. (this is including spaces).</p>
<p>In detail, The error occurs when setting EXTRA_JAVA_PROPERTIES in call %USERDOMAIN_HOME%\bin\setDomainEnv.cmd</p>
<p>Try to ignore those lines:<br /> <code>set EXTRA_JAVA_PROPERTIES=-Doracle.apm.home=%APM_ORACLE_HOME% -DAPM_HELP_FILENAME=oesohwconfig.xml %EXTRA_JAVA_PROPERTIES%<br /> set EXTRA_JAVA_PROPERTIES= -DXL.HomeDir=%OIM_ORACLE_HOME%\server -Dscheduler.disabled=false -Djava.security.auth.login.config=%OIM_ORACLE_HOME%\server\config\authwl.conf -Dorg.owasp.esapi.resources=%OIM_ORACLE_HOME%\server\apps\oim.ear\APP-INF\classes -DeditionOverride=ee %EXTRA_JAVA_PROPERTIES%<br /> set EXTRA_JAVA_PROPERTIES= -Doracle.oaam.home=%OAAM_ORACLE_HOME% -Djava.awt.headless=true %EXTRA_JAVA_PROPERTIES%<br /> set EXTRA_JAVA_PROPERTIES= -Doracle.oaam.home=%OAAM_ORACLE_HOME% %EXTRA_JAVA_PROPERTIES%<br /> set EXTRA_JAVA_PROPERTIES= -Doracle.oaam.home=%OAAM_ORACLE_HOME% %EXTRA_JAVA_PROPERTIES%<br /> set EXTRA_JAVA_PROPERTIES= -Doam.oes.new=true -DOAM_POLICY_FILE=%DOMAIN_HOME%\config\fmwconfig\oam-policy.xml -DOAM_CONFIG_FILE=%DOMAIN_HOME%\config\fmwconfig\oam-config.xml -DOAM_ORACLE_HOME=%OAM_ORACLE_HOME% -Doracle.security.am.SERVER_INSTNCE_NAME=%SERVER_NAME% -Does.jars.home=%OAM_ORACLE_HOME%\server\lib\oes-d8 -Does.integration.path=%OAM_ORACLE_HOME%\server\lib\oeslib\oes-integration.jar -Does.enabled=true -Djavax.xml.soap.SOAPConnectionFactory=weblogic.wsee.saaj.SOAPConnectionFactoryImpl -Djavax.xml.soap.MessageFactory=oracle.j2ee.ws.saaj.soap.MessageFactoryImpl -Djavax.xml.soap.SOAPFactory=oracle.j2ee.ws.saaj.soap.SOAPFactoryImpl %EXTRA_JAVA_PROPERTIES%<br /> set EXTRA_JAVA_PROPERTIES=%EXTRA_JAVA_PROPERTIES% -Dem.oracle.home=C:\app\oracle\Middleware_IAM\oracle_common -Djava.awt.headless=true<br /> set EXTRA_JAVA_PROPERTIES=%EXTRA_JAVA_PROPERTIES% -Dbpm.enabled=true<br /> set EXTRA_JAVA_PROPERTIES=%EXTRA_JAVA_PROPERTIES% -Dsoa.archives.dir=%SOA_ORACLE_HOME%\soa -Dsoa.oracle.home=%SOA_ORACLE_HOME% -Dsoa.instance.home=%DOMAIN_HOME% -Dtangosol.coherence.clusteraddress=227.7.7.9 -Dtangosol.coherence.clusterport=9778 -Dtangosol.coherence.log=jdk -Djavax.xml.soap.MessageFactory=oracle.j2ee.ws.saaj.soap.MessageFactoryImpl -Dweblogic.transaction.blocking.commit=true -Dweblogic.transaction.blocking.rollback=true -Djavax.net.ssl.trustStore=%WL_HOME%\server\lib\DemoTrust.jks<br /> set EXTRA_JAVA_PROPERTIES=%EXTRA_JAVA_PROPERTIES% -Dums.oracle.home=%UMS_ORACLE_HOME%<br /> set EXTRA_JAVA_PROPERTIES=-Dcommon.components.home=%COMMON_COMPONENTS_HOME% -Djrf.version=11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Ddomain.home=%DOMAIN_HOME% -Djrockit.optfile=%COMMON_COMPONENTS_HOME%\modules\oracle.jrf_11.1.1\jrocket_optfile.txt -Doracle.server.config.dir=%ORACLE_DOMAIN_CONFIG_DIR%\servers\%SERVER_NAME% -Doracle.domain.config.dir=%ORACLE_DOMAIN_CONFIG_DIR% -Digf.arisidbeans.carmlloc=%ORACLE_DOMAIN_CONFIG_DIR%\carml -Digf.arisidstack.home=%ORACLE_DOMAIN_CONFIG_DIR%\arisidprovider -Doracle.security.jps.config=%DOMAIN_HOME%\config\fmwconfig\jps-config.xml -Doracle.deployed.app.dir=%DOMAIN_HOME%\servers\%SERVER_NAME%\tmp\_WL_user -Doracle.deployed.app.ext=\- -Dweblogic.alternateTypesDirectory=%ALT_TYPES_DIR% -Djava.protocol.handler.pkgs=%PROTOCOL_HANDLERS% %WLS_JDBC_REMOTE_ENABLED% %EXTRA_JAVA_PROPERTIES%<br /> set JAVA_PROPERTIES=%JAVA_PROPERTIES% %EXTRA_JAVA_PROPERTIES%<br /> </code><br /> When service created and start, got an error &#8216; Unable to initialize the Java virtual machine!&#8217;</p>
<p>This EXTRA_JAVA_PROPERTIES seems is critical for JAVA process. Giving up.</p>
<p>I think for now I have to keep IAM desktop never always in login status.</p>
<p>A helpful trick, beasvc -remove command doesn&#8217;t work. Had to run <a href="http://geekswithblogs.net/shahedul/archive/2006/10/13/93984.aspx">sc delete</a> instead.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1716/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1716/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1716&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2013/04/18/install-wls-as-windows-service/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>magic fields in wordpress</title>
		<link>http://frankmao.com/2012/10/11/magic-fields-in-wordpress/</link>
		<comments>http://frankmao.com/2012/10/11/magic-fields-in-wordpress/#comments</comments>
		<pubDate>Thu, 11 Oct 2012 15:01:07 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1708</guid>
		<description><![CDATA[Custom fields in wordpress is a surprise, with custom post type wordpress suddenly become the first choice for out-of-box CMS system. There are many plugin around, the most of them require some medium level PHP skill to change template or theme. Some cool plugins like Custom Post type UI, just custom post type and advanced [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1708&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Custom fields in wordpress is a surprise, with custom post type wordpress suddenly become the first choice for out-of-box CMS system.</p>
<p>There are many plugin around, the most of them require some medium level PHP skill to change template or theme.</p>
<p>Some cool plugins like Custom Post type UI, just custom post type and advanced custom type. But those plugin still have one problem to solve, how to make the input UI easier to use. One common problem is in the input screen, custom field displayed twice, and still give user flexibility to add other custom fields.</p>
<p>Custom field template suppose fix it, but it seems still need PHP code change somewhere.</p>
<p>Magic fields 2 solved this problem eventual, by introducing some style middle tables at backend, the admin UI looks much cleaner. And data storage is still in post_metadata.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1708/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1708/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1708&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/10/11/magic-fields-in-wordpress/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>
	</item>
		<item>
		<title>Change git external submodule to local repo</title>
		<link>http://frankmao.com/2012/10/04/change-git-external-submodule-to-local-repo/</link>
		<comments>http://frankmao.com/2012/10/04/change-git-external-submodule-to-local-repo/#comments</comments>
		<pubDate>Fri, 05 Oct 2012 05:10:00 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1703</guid>
		<description><![CDATA[Why doing this? an external submodule is not public anymore. rm .gitmodules, or edit it to remove the selected submodule. Remove the submodule’s entry in the .git/config git rm –cached external/selected-submodule git add external/selected-submodule git commit -m git push Credit: http://chrisjean.com/2009/04/20/git-submodules-adding-using-removing-and-updating/<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1703&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Why doing this? an external submodule is not public anymore.</p>
<p>rm .gitmodules, or edit it to remove the selected submodule.</p>
<p>Remove the submodule’s entry in the .git/config</p>
<p><strong>git rm –cached external/selected-submodule</strong></p>
<p>git add <strong>external/selected-submodule</strong></p>
<p>git commit -m</p>
<p>git push</p>
<p>Credit: <a href="http://chrisjean.com/2009/04/20/git-submodules-adding-using-removing-and-updating/" rel="nofollow">http://chrisjean.com/2009/04/20/git-submodules-adding-using-removing-and-updating/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1703/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1703/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1703&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/10/04/change-git-external-submodule-to-local-repo/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>
	</item>
		<item>
		<title>How to calculate &#8216;Tomorrow at 4 pm&#8217; in iOS</title>
		<link>http://frankmao.com/2012/10/04/how-to-calculate-tomorrow-at-4-pm-in-ios/</link>
		<comments>http://frankmao.com/2012/10/04/how-to-calculate-tomorrow-at-4-pm-in-ios/#comments</comments>
		<pubDate>Thu, 04 Oct 2012 18:34:55 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1696</guid>
		<description><![CDATA[NSCalendar *calendar = [NSCalendar gregorianCalendar]; NSDateComponents *oneDayComponents = [[NSDateComponents alloc] init]; oneDayComponents.day = 1; NSDate *tomorrow = [calendar dateByAddingComponents:oneDayComponents toDate:[NSDate date] options:nil]; NSUInteger unitFlags = NSEraCalendarUnit &#124; NSYearCalendarUnit &#124; NSMonthCalendarUnit &#124; NSDayCalendarUnit; NSDateComponents *tomorrowAt4PM = [calendar components:unitFlags fromDate:tomorrow]; tomorrowAt4PM.hour = 16; tomorrowAt4PM.minute = 0; tomorrowAt4PM.second = 0; NSDate *alarmDate = [calendar dateFromComponents:tomorrowAt4PM]; http://adcdownload.apple.com//wwdc_2012/wwdc_2012_session_pdfs/session_304__events_and_reminders_in_event_kit.pdf<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1696&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<pre>NSCalendar *calendar = [NSCalendar gregorianCalendar];
NSDateComponents *oneDayComponents = [[NSDateComponents alloc] init];
oneDayComponents.day = 1;
NSDate *tomorrow = [calendar dateByAddingComponents:oneDayComponents toDate:[NSDate date] options:nil];
NSUInteger unitFlags = NSEraCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSDateComponents *tomorrowAt4PM = [calendar components:unitFlags fromDate:tomorrow];
tomorrowAt4PM.hour = 16;
tomorrowAt4PM.minute = 0;
tomorrowAt4PM.second = 0;
NSDate *alarmDate = [calendar dateFromComponents:tomorrowAt4PM];</pre>
<p><a href="http://adcdownload.apple.com//wwdc_2012/wwdc_2012_session_pdfs/session_304__events_and_reminders_in_event_kit.pdf" rel="nofollow">http://adcdownload.apple.com//wwdc_2012/wwdc_2012_session_pdfs/session_304__events_and_reminders_in_event_kit.pdf</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1696/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1696/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1696&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/10/04/how-to-calculate-tomorrow-at-4-pm-in-ios/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>Facebook sharing feature in iOS app</title>
		<link>http://frankmao.com/2012/10/04/facebook-sharing-feature-in-ios-app/</link>
		<comments>http://frankmao.com/2012/10/04/facebook-sharing-feature-in-ios-app/#comments</comments>
		<pubDate>Thu, 04 Oct 2012 17:45:44 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1689</guid>
		<description><![CDATA[Classic/Obsolete(?) way Install SDK Drag framework folder into XCode project. Drag bundle into XCode project. Drag deprecated header folder into XCode project. check copy in needed. When picking dependency libraries, set them to optional, to allow app running on iOS5. Set other link flag to -lsqlite3.0 Those steps are fully documented on facebook developer site: [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1689&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Classic/Obsolete(?) way</p>
<p>Install SDK</p>
<p>Drag framework folder into XCode project.</p>
<p>Drag bundle into XCode project.</p>
<p>Drag deprecated header folder into XCode project. check copy in needed.</p>
<p>When picking dependency libraries, set them to optional, to allow app running on iOS5.</p>
<p>Set other link flag to -lsqlite3.0</p>
<p>Those steps are fully documented on facebook developer site: <a href="https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/3.1/" rel="nofollow">https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/3.1/</a></p>
<p>Note: we are using old fashion Facebook sharing feature in app.  (FBDelegate vs. FBRequest) Because my client doesn&#8217;t like posting story on their wall without a preview. This way app will popup a separated window to display link to share, image, title, description, etc. User needs to type something in the textbox with placeholder &#8216;say something about this&#8230;&#8217;</p>
<p>Note: again, preset message feature has been disabled by Facebook as of 2012.</p>
<p>In app, we are adding #include &#8220;Facebook.h&#8221; to implement this.</p>
<p>Note: you can use sharekit library for this, but I want to figure out what&#8217;s happening behind the scene.</p>
<p>In the place you want to popup Facebook share options to user, do this to open a Facebook session.</p>
<pre>// openSessionWithAllowLoginUI will be called by the actual sharing screen where users can click button to post message on their wall.
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI
{
    NSArray *permission = [[NSArray alloc] initWithObjects:@"user_likes",@"publish_actions", nil];

    return [FBSession openActiveSessionWithPublishPermissions:permission
                                              defaultAudience:FBSessionDefaultAudienceFriends
 allowLoginUI:allowLoginUI
                                            completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
                                                [self sessionStateChanged:session state:status error:error];
                                            }];}

NSString *const FBSessionStateChangedNotification = @"com.bitrixsoft.Login:FBSessionStateChangedNotifiction";

- (void)sessionStateChanged:(FBSession *)session
                    state:(FBSessionState) state
                    error:(NSError *)error
{
    switch (state) {
        case FBSessionStateOpen:
            if (!error) {
                NSLog(@"User session found");
            }
            break;
        case FBSessionStateClosed:
        case FBSessionStateClosedLoginFailed:
            [FBSession.activeSession closeAndClearTokenInformation];
        default:
            break;
    }

    [[NSNotificationCenter defaultCenter]
     postNotificationName:FBSessionStateChangedNotification
     object:session];

    if (error) {
        [[[UIAlertView alloc]
         initWithTitle:@"Error"
         message:error.localizedDescription
         delegate:nil
         cancelButtonTitle:@"OK"
          otherButtonTitles:nil] show];
    }
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    return [FBSession.activeSession handleOpenURL:url];
}</pre>
<p>I put this in appDelegate, so it can be shared. I don&#8217;t want to call this in appDelegate, otherwise the redirect to facebook to ask permission/login will annoy users.</p>
<p>Add those in appDelegate.h file</p>
<pre>extern NSString *const FBSessionStateChangedNotification;

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI;</pre>
<p>Before calling opensession, sharing window should subscribe statechange notification.</p>
<pre>[[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(sessionStateChanged:)
     name:FBSessionStateChangedNotification
     object:nil];

- (void)sessionStateChanged:(NSNotification *)notification
{
    if ((FBSession.activeSession.isOpen)) {

        if (nil == self.facebook) {
            self.facebook = [[Facebook alloc]
                             initWithAppId:FBSession.activeSession.appID
                             andDelegate:nil];

            self.facebook.accessToken = FBSession.activeSession.accessToken;
            self.facebook.expirationDate = FBSession.activeSession.expirationDate;

            // resume sharing routine here, because first time attempt without login will stop after app back from background, 
            // but this method will get statechange notifcation, so perfect to resume/restart here.
            [self shareViaFacebook];
        }
    }else{

        self.facebook = nil;
    }</pre>
<p>Finally, the actual post action:</p>
<pre>- (IBAction)shareOptions:(id)sender
{

    BNAppDelegate * appDelegate = (BNAppDelegate*)[[UIApplication sharedApplication] delegate];
    [appDelegate openSessionWithAllowLoginUI:YES];

    UIActionSheet * options = [[UIActionSheet alloc]
                               initWithTitle:@"Share"
                               delegate:self
                               cancelButtonTitle:@"Cancel"
                               destructiveButtonTitle:nil
                               otherButtonTitles:@"Twitter", @"Facebook", @"email", nil];

    [options showInView:self.view];
}
- (void)shareViaFacebook
{
    NSString * message = @"test msg from my test ios app";

    // no nil allow in any parameter
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"Bitrix News iPhone app", @"name",
                                   _post.title, @"caption",
                                   _post.exerpt, @"description",
                                   @"http://www.frankmao.com", @"link",
                                   @"http://ww1.prweb.com/prfiles/2011/02/01/8151699/gI_60506_bxlogo.jpg", @"picture",
                                   message, @"message", //already obsolete, don't bother, facebook will ignore it anyway
                                   nil];

    [self.facebook dialog:@"feed" andParams:params andDelegate:self];

}</pre>
<p>Someother gotcha, app identifier must match between app and setting in developers.facebook.com/app, otherwise facebook will complain app is misconfigured when starting the session.</p>
<p>REF: <a href="https://developers.facebook.com/docs/reference/dialogs/feed/" rel="nofollow">https://developers.facebook.com/docs/reference/dialogs/feed/</a></p>
<p><a href="https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/" rel="nofollow">https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1689/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1689/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1689&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/10/04/facebook-sharing-feature-in-ios-app/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>
	</item>
		<item>
		<title>Sharing internet connection with VMWare guest</title>
		<link>http://frankmao.com/2012/07/25/sharing-internet-connection-with-vmware-guest/</link>
		<comments>http://frankmao.com/2012/07/25/sharing-internet-connection-with-vmware-guest/#comments</comments>
		<pubDate>Wed, 25 Jul 2012 19:53:02 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[RubyMine]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1684</guid>
		<description><![CDATA[Network adapter must set to host only (NAT/Bridge won&#8217;t work). On host, control panel-&#62;network and sharing center -&#62;change adapter settings, pick the regular &#8216;Local Area Connection&#8217;, rename the other &#8216;Local Area Connection 2&#8242; used by VMWare hosting to &#8216;VMWare Host Network&#8217; for clarification. Right click on Local Area Connection, select sharing tab, allow sharing internet [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1684&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<ol>
<li>Network adapter must set to host only (NAT/Bridge won&#8217;t work).</li>
<li>On host, control panel-&gt;network and sharing center -&gt;change adapter settings, pick the regular &#8216;Local Area Connection&#8217;, rename the other &#8216;Local Area Connection 2&#8242; used by VMWare hosting to &#8216;VMWare Host Network&#8217; for clarification. Right click on Local Area Connection, select sharing tab, allow sharing internet connection with &#8216;VMWare Host Network&#8217;. Note: ip address on VMWare Host Network will change to something like 192.168.137.1</li>
<li>Stop VMware DHCP Service at service panel, set this service to manual startup type.</li>
<li>Reboot guest. After reboot, guest should get a new ip in 192.168.137 subnet.</li>
<li>Set http proxy in guest in necessary. Note: in RubyMine, svn has it&#8217;s own http settings tab.</li>
</ol>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1684/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1684/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1684&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/07/25/sharing-internet-connection-with-vmware-guest/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>
	</item>
		<item>
		<title>Update version number in vbproj file in NAnt build</title>
		<link>http://frankmao.com/2012/07/20/update-version-number-in-vbproj-file-in-nant-build/</link>
		<comments>http://frankmao.com/2012/07/20/update-version-number-in-vbproj-file-in-nant-build/#comments</comments>
		<pubDate>Fri, 20 Jul 2012 18:13:53 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[CI]]></category>
		<category><![CDATA[NAnt]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1677</guid>
		<description><![CDATA[Today, I got an exact same challenge Scot Hanselman faced 8 years ago.  Copied his script into my build file, error said: Regex does not exist. Added system.dll reference in NAnt according to this post, no help. I stopped, why bother using Regex for such a small task. I turn back to native NAnt tasks. [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1677&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Today, I got <a href="http://www.hanselman.com/blog/BuildingMSIFilesFromNAntAndUpdatingTheVDProjsVersionInformationAndOtherSinsOnTuesday.aspx">an exact same challenge Scot Hanselman faced 8 years ago. </a></p>
<p>Copied his script into my build file, error said: Regex does not exist.</p>
<p>Added system.dll reference in NAnt <a href="http://kalebpederson.com/index.php/2012/01/nant-error-the-type-or-namespace-does-not-exist">according to this post</a>, no help.</p>
<p>I stopped, why bother using Regex for such a small task.</p>
<p>I turn back to native NAnt tasks. Strategy is,</p>
<ol>
<li>Find the hardcoded version number in vdproj file, e.g., 1.1.0, notify team member don&#8217;t touch it, this will be my constant, or token to be replaced later.</li>
<li>Replace this 1.1.0 on the fly during the build, build msi. Create backup vdproj file before replacing.</li>
<li>When build finished, restore original vdproj.</li>
</ol>
<p>Simple and clean solution, job accomplished.</p>
<p>Only goofy part is, if I run this build script when Visual Studio opened, VS kept saving memory cached content to disk, causing file conflict.</p>
<p>Not a big deal, this build target only runs on our CI server anyway.</p>
<pre class="brush: xml; title: ; notranslate">

  &lt;property name=&quot;orig.version.number.in.vdproj&quot; value=&quot;1.1.0&quot; /&gt; &lt;!--ensure this matches vdproj--&gt;
  &lt;property name=&quot;path.vdproj.file&quot; value=&quot;src\EmailProcessorNTServiceSetup\EmailProcessorNTServiceSetup.vdproj&quot; /&gt;
  &lt;property name=&quot;path.vdproj.file.orig&quot; value=&quot;${path.vdproj.file}.orig&quot; /&gt;

  &lt;target name=&quot;update.vdproj.version&quot; depends=&quot;&quot;&gt;
    &lt;loadfile file=&quot;${path.vdproj.file}&quot; property=&quot;file.contents&quot; /&gt;
	&lt;!-- build.number in format of xx.xx.xx.xx, need to shorten to xx.xx.xx to satisfy vdproj --&gt;
    &lt;property name=&quot;version.number&quot; value=&quot;${string::substring(build.number, 0, string::last-index-of(build.number, '.'))}&quot;/&gt;
	&lt;echo message=&quot;shorteded version.number: ${version.number}&quot; /&gt;
    &lt;echo file=&quot;${path.vdproj.file}&quot; message=&quot;${string::replace(file.contents, orig.version.number.in.vdproj, version.number)}&quot; /&gt;
  &lt;/target&gt;  
 
  &lt;/target&gt;

  &lt;target name=&quot;restore.vdproj.file&quot; depends=&quot;&quot;&gt;
    &lt;delete file=&quot;${path.vdproj.file}&quot; /&gt;
	&lt;echo message=&quot;${path.vdproj.file} could not be deleted&quot; if=&quot;${file::exists(path.vdproj.file)}&quot; /&gt;

	&lt;if test=&quot;${not file::exists(path.vdproj.file)}&quot;&gt;
		&lt;copy file=&quot;${path.vdproj.file.orig}&quot;
          tofile=&quot;${path.vdproj.file}&quot;

          /&gt;
		&lt;delete file=&quot;${path.vdproj.file.orig}&quot; /&gt;
	&lt;/if&gt;
&lt;!-- can also replace it back, same result, but this potentially still mess up svn flag.    &lt;echo file=&quot;${path.vdproj.file}&quot; message=&quot;${string::replace(file.contents, version.number, orig.version.number.in.vdproj)}&quot; /&gt;--&gt;
  &lt;/target&gt;
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1677/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1677/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1677&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/07/20/update-version-number-in-vbproj-file-in-nant-build/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>Setup git access on TeamCity behind firewall</title>
		<link>http://frankmao.com/2012/06/15/setup-git-access-on-teamcity-behind-firewall/</link>
		<comments>http://frankmao.com/2012/06/15/setup-git-access-on-teamcity-behind-firewall/#comments</comments>
		<pubDate>Fri, 15 Jun 2012 16:49:17 +0000</pubDate>
		<dc:creator>Frank Mao</dc:creator>
				<category><![CDATA[CI]]></category>
		<category><![CDATA[VCS]]></category>

		<guid isPermaLink="false">http://frankmao.com/?p=1673</guid>
		<description><![CDATA[Problem: Our CI server needs to grab the source code from external world to run a build. Use git behind firewall git config &#8211;global -l check http.proxy=? git config -global http.proxy=http://proxy-server:port-number If reset is necessary, git config &#8211;global  unset http.proxy or  git config &#8211;global unset-all http.proxy &#160; Configure TeamCity connect to external git repository So [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1673&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Problem: Our CI server needs to grab the source code from external world to run a build.</p>
<h1>Use git behind firewall</h1>
<p>git config &#8211;global -l<br />
check http.proxy=?</p>
<p>git config -global http.proxy=http://proxy-server:port-number<br />
If reset is necessary,<br />
git config &#8211;global  unset http.proxy<br />
or  git config &#8211;global unset-all http.proxy</p>
<p>&nbsp;</p>
<h1>Configure TeamCity connect to external git repository</h1>
<p>So far there is no place to set http proxy in teamcity yet. (we are on teamcity 7.03）</p>
<p>One easiest solution is:</p>
<ol>
<li>git clone to local repo folder, e.g. c:/git_repo&gt;git clone <a href="https://remote-git" rel="nofollow">https://remote-git</a> myrepo</li>
<li>share this folder on local network</li>
<li>in TeamCity, VCS settings, set remote fetch url to \\repo-host\myrepo</li>
<li>tahdah&#8230;it works!</li>
</ol>
<p>Remaining problem is we still need to manually run git pull on git_repo folder to get latest from remote, maybe a cron job can make this easier.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/maonet.wordpress.com/1673/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/maonet.wordpress.com/1673/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=frankmao.com&#038;blog=431779&#038;post=1673&#038;subd=maonet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://frankmao.com/2012/06/15/setup-git-access-on-teamcity-behind-firewall/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>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 [&#8230;]<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> <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>
	</channel>
</rss>
