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

<channel>
	<title>BitBonsai Labs &#187; development</title>
	<atom:link href="http://www.bitbonsai.com/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bitbonsai.com</link>
	<description>Mauricio Wolff&#039;s geekness</description>
	<lastBuildDate>Fri, 27 Aug 2010 20:30:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>JS Tip: Revealing Module Pattern</title>
		<link>http://www.bitbonsai.com/revealing-module-pattern/</link>
		<comments>http://www.bitbonsai.com/revealing-module-pattern/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 17:59:00 +0000</pubDate>
		<dc:creator>mw</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.bitbonsai.com/?p=217</guid>
		<description><![CDATA[From Christian Heilmann. Nothing too fancy for those who are used to write jQ plugins, but nice to save it for reference... var myApp = function&#40;&#41;&#123; var nome = 'Mauricio Wolff'; var idade = 35; &#160; function insertPessoa&#40;&#41;&#123; // [...] &#125; &#160; function updatePessoa&#40;&#41;&#123; // [...] &#125; &#160; function setPessoa &#40;&#41; &#123; // [ usa [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>From Christian Heilmann. Nothing too fancy for those who are used to write jQ plugins, but nice to save it for reference...</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myApp <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> nome <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Mauricio Wolff'</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> idade <span style="color: #339933;">=</span> <span style="color: #CC0000;">35</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> insertPessoa<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// [...]</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> updatePessoa<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// [...]</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> setPessoa <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// [ usa insert ou update ]</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> getPessoa <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// [...]</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">return</span><span style="color: #009900;">&#123;</span>
		set<span style="color: #339933;">:</span> setPessoa<span style="color: #339933;">,</span>
		get<span style="color: #339933;">:</span> getPessoa
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Example usage:</span>
myApp.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bitbonsai.com/revealing-module-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Make an HTML5 iPhone App</title>
		<link>http://www.bitbonsai.com/html-iphone-app/</link>
		<comments>http://www.bitbonsai.com/html-iphone-app/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 13:12:44 +0000</pubDate>
		<dc:creator>mw</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[geek]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[webdesign]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://www.bitbonsai.com/?p=186</guid>
		<description><![CDATA[This is nice. An article on SixRevisions, short version here for my Archive. If you write a couple meta tags, your html5 app will look like any other iPhone App, but will also work on Android, PalmPre, etc... &#60;meta name=&#34;viewport&#34; content=&#34;user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0&#34;/&#62; &#60;meta name=&#34;apple-mobile-web-app-capable&#34; content=&#34;yes&#34; /&#62; &#60;meta name=&#34;apple-mobile-web-app-status-bar-style&#34; content=&#34;black&#34; /&#62; &#60;link rel=&#34;apple-touch-icon&#34; href=&#34;iphone_icon.png&#34;/&#62; [...]]]></description>
			<content:encoded><![CDATA[<h4><a href="http://img.skitch.com/20100329-k4k9rkinb4m8r2xebsqtb6d4s9.jpg"><img class="aligncenter" title="iPhone" src="http://img.skitch.com/20100329-k4k9rkinb4m8r2xebsqtb6d4s9.jpg" alt="" width="402" height="232" /></a>This is nice. An <a href="http://sixrevisions.com/web-development/html5-iphone-app/" target="_blank">article on SixRevisions</a>, short version here for my Archive.</h4>
<p>If you write a couple meta tags, your html5 app will look like any other iPhone App, but will also work on Android, PalmPre, etc...</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;viewport&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apple-mobile-web-app-capable&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apple-mobile-web-app-status-bar-style&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;black&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apple-touch-icon&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;iphone_icon.png&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apple-touch-startup-image&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;startup.png&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;styles.css&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;screen, mobile&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;main&quot;</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;</span></pre></div></div>

<ul>
<li>apple-mobile-web-app-capable: This is another tip-off that we want to be an offline app.</li>
<li>apple-mobile-web-app-status-bar-style: This hides the status bar, and nav bar when the app is offline.</li>
<li>apple-touch-icon:This is the pointer to the image that want to be the icon.</li>
<li>apple-touch-startup-image: This is a url pointing to the startup image.</li>
</ul>
<h4>Application Cache</h4>
<p>Application caching allows browsers to determine in advance all the files a web page will need for the web page to work.</p>
<p>One tricky part to this whole thing is that the manifest (the list of files that need to be cached offline) has to be passed with a filetype Header set to text/manifest. That is why you need access to a web server that can set HTTP headers.</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">    CACHE MANIFEST
&nbsp;
    <span style="color: #adadad; font-style: italic;"># Version 3 </span>
&nbsp;
    style.css
    index.html
    init.js
&nbsp;
    <span style="color: #adadad; font-style: italic;"># offline icons</span>
    startup.png
    iphone_icon.png</pre></div></div>

<h4>Offline Data</h4>
<p>Along with the ability to keep files that are needed offline, you can also store user data in an offline database. There are two major APIs for per user and/or per page data. The first is localStorage. localStorage, is an easy to use key-value store with a dead simple API.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">    localStorage.<span style="color: #660066;">dataToStore</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
    console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>localStorage.<span style="color: #660066;">dataToStore</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 5</span></pre></div></div>

<h4>Its also possible to use a webdatabase (SQLite):</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">    <span style="color: #006600; font-style: italic;">// Try and get a database object</span>
    <span style="color: #003366; font-weight: bold;">var</span> db<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">openDatabase</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            db <span style="color: #339933;">=</span> openDatabase<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;NoteTest&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1.0&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;HTML5 Database API example&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">200000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>db<span style="color: #009900;">&#41;</span>
                <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Failed to open the database on disk.  This is probably because the version was /
                bad or there is not enough space left in this domain's quota&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span>
            <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Couldn't open the database.  Please try with a WebKit nightly with this feature enabled&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span>err<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// Check and see if you need to initalize the DB</span>
    db.<span style="color: #660066;">transaction</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        tx.<span style="color: #660066;">executeSql</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SELECT COUNT(*) FROM WebkitStickyNotes&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            loadNotes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tx<span style="color: #339933;">,</span> error<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            tx.<span style="color: #660066;">executeSql</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;CREATE TABLE WebKitStickyNotes (id REAL UNIQUE, note TEXT, timestamp /
            REAL, left TEXT, top TEXT, zindex REAL)&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                loadNotes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// Insert a test Note.</span>
    <span style="color: #003366; font-weight: bold;">var</span> note <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        id<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #339933;">,</span>
        text<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot; This is a test note&quot;</span><span style="color: #339933;">,</span>
        timestamp<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;112123000&quot;</span><span style="color: #339933;">,</span>
        left<span style="color: #339933;">:</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span>
        top<span style="color: #339933;">:</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span>
        zIndex<span style="color: #339933;">:</span><span style="color: #CC0000;">2</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    db.<span style="color: #660066;">transaction</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>tx<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        tx.<span style="color: #660066;">executeSql</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;INSERT INTO WebKitStickyNotes (id, note, timestamp, left, top, zindex) VALUES /
        (?, ?, ?, ?, ?, ?)&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>note.<span style="color: #660066;">id</span><span style="color: #339933;">,</span> note.<span style="color: #660066;">text</span><span style="color: #339933;">,</span> note.<span style="color: #660066;">timestamp</span><span style="color: #339933;">,</span> note.<span style="color: #660066;">left</span><span style="color: #339933;">,</span> note.<span style="color: #660066;">top</span><span style="color: #339933;">,</span> note.<span style="color: #660066;">zIndex</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
    <span style="color: #006600; font-style: italic;">// Get all the notes out of the database.</span>
    db.<span style="color: #660066;">transaction</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        tx.<span style="color: #660066;">executeSql</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SELECT id, note, timestamp, left, top, zindex /
        FROM WebKitStickyNotes&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tx<span style="color: #339933;">,</span> result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> result.<span style="color: #660066;">rows</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>                 <span style="color: #003366; font-weight: bold;">var</span> row <span style="color: #339933;">=</span> result.<span style="color: #660066;">rows</span>.<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                 <span style="color: #003366; font-weight: bold;">var</span> note <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Note<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                 note.<span style="color: #660066;">id</span> <span style="color: #339933;">=</span> row<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>                 note.<span style="color: #660066;">text</span> <span style="color: #339933;">=</span> row<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'note'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>                 note.<span style="color: #660066;">timestamp</span> <span style="color: #339933;">=</span> row<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'timestamp'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>                 note.<span style="color: #660066;">left</span> <span style="color: #339933;">=</span> row<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'left'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>                 note.<span style="color: #660066;">top</span> <span style="color: #339933;">=</span> row<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'top'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>                 note.<span style="color: #660066;">zIndex</span> <span style="color: #339933;">=</span> row<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'zindex'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>                 <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>row<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> highestId<span style="color: #009900;">&#41;</span>
                    highestId <span style="color: #339933;">=</span> row<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>row<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'zindex'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> highestZ<span style="color: #009900;">&#41;</span>
                    highestZ <span style="color: #339933;">=</span> row<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'zindex'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>result.<span style="color: #660066;">rows</span>.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span>
                newNote<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tx<span style="color: #339933;">,</span> error<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Failed to retrieve notes from database - '</span> <span style="color: #339933;">+</span> error.<span style="color: #660066;">message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bitbonsai.com/html-iphone-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python x PHP: Finding IPs with regex</title>
		<link>http://www.bitbonsai.com/python-php-vs-find-ip-with-regex/</link>
		<comments>http://www.bitbonsai.com/python-php-vs-find-ip-with-regex/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 12:09:47 +0000</pubDate>
		<dc:creator>mw</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.bitbonsai.com/?p=147</guid>
		<description><![CDATA[Sometimes I just like to write code in Python and PHP to compare them, and admire both... Here's a little code to find IP adressess inside strings (returned from a nslookup). The code is not optimal, but illustrate how both languages works. Just for some friday fun... Python &#160; Python 2.6.1 &#40;r261:67515, Jul  7 2009, [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes I just like to write code in Python and PHP to compare them, and admire both...</p>
<p>Here's a little code to find IP adressess inside strings (returned from a nslookup). The code is not optimal, but illustrate how both languages works. Just for some friday fun...</p>
<h3>Python</h3>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
Python 2.6.1 <span style="color: black;">&#40;</span>r261:<span style="color: #ff4500;">67515</span>, Jul  <span style="color: #ff4500;">7</span> <span style="color: #ff4500;">2009</span>,  <span style="color: #ff4500;">23</span>:<span style="color: #ff4500;">51</span>:<span style="color: #ff4500;">51</span><span style="color: black;">&#41;</span>
 <span style="color: black;">&#91;</span>GCC 4.2.1 <span style="color: black;">&#40;</span>Apple Inc. <span style="color: black;">build</span> <span style="color: #ff4500;">5646</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> on darwin
 Type <span style="color: #483d8b;">&quot;help&quot;</span>, <span style="color: #483d8b;">&quot;copyright&quot;</span>, <span style="color: #483d8b;">&quot;credits&quot;</span> <span style="color: #ff7700;font-weight:bold;">or</span> <span style="color: #483d8b;">&quot;license&quot;</span>  <span style="color: #ff7700;font-weight:bold;">for</span>  more information.
&nbsp;
<span style="color: #66cc66;">&gt;&gt;&gt;</span> a  = <span style="color: #483d8b;">'yahoo.com IN A 69.147.114.224 18774s  (05:12:54)'</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> a += <span style="color: #483d8b;">'yahoo.com IN A 209.131.36.159 18774s  (05:12:54)'</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> a += <span style="color: #483d8b;">'yahoo.com IN A 209.191.93.53  18774s  (05:12:54)'</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">print</span> a
 <span style="color: #483d8b;">'yahoo.com IN A 69.147.114.224  18774s (05:12:54)yahoo.com IN A 209.131.36.159 18774s  (05:12:54)yahoo.com IN A 209.191.93.53  18774s (05:12:54)'</span>
<span style="color: #66cc66;">&gt;&gt;&gt;;</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> p = <span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'(?:<span style="color: #000099; font-weight: bold;">\d</span>{1,3}<span style="color: #000099; font-weight: bold;">\.</span>){3}<span style="color: #000099; font-weight: bold;">\d</span>{1,3}'</span><span style="color: black;">&#41;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;;</span> p.<span style="color: black;">findall</span><span style="color: black;">&#40;</span>a<span style="color: black;">&#41;</span>
 <span style="color: black;">&#91;</span><span style="color: #483d8b;">'69.147.114.224'</span>, <span style="color: #483d8b;">'209.131.36.159'</span>,  <span style="color: #483d8b;">'209.191.93.53'</span><span style="color: black;">&#93;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span></pre></div></div>

<h3>PHP</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$a</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'yahoo.com IN A 69.147.114.224 18774s (05:12:54)'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'yahoo.com  IN A 209.131.36.159 18774s (05:12:54)'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'yahoo.com  IN A 209.191.93.53  18774s (05:12:54)'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">print</span> <span style="color: #000088;">$a</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
saida: yahoo.com IN A 69.147.114.224 18774s (05:12:54)yahoo.com IN A  209.131.36.159 18774s (05:12:54)yahoo.com IN A 209.191.93.53 18774s  (05:12:54)
*/</span>
&nbsp;
<span style="color: #000088;">$re</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/(\d+).(\d+).(\d+).(\d+)/'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$re</span><span style="color: #339933;">,</span> <span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// saida 1</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// saida 2</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
saida 1:
&nbsp;
array(3) {
  [0]=&gt;
  string(14) &quot;69.147.114.224&quot;
  [1]=&gt;
  string(14) &quot;209.131.36.159&quot;
  [2]=&gt;
  string(13) &quot;209.191.93.53&quot;
}
&nbsp;
saida 2:
&nbsp;
array(5) {
  [0]=&gt;
  array(3) {
    [0]=&gt;
    string(14) &quot;69.147.114.224&quot;
    [1]=&gt;
    string(14) &quot;209.131.36.159&quot;
    [2]=&gt;
    string(13) &quot;209.191.93.53&quot;
  }
  [1]=&gt;
  array(3) {
    [0]=&gt;
    string(2) &quot;69&quot;
    [1]=&gt;
    string(3) &quot;209&quot;
    [2]=&gt;
    string(3) &quot;209&quot;
  }
  [2]=&gt;
  array(3) {
    [0]=&gt;
    string(3) &quot;147&quot;
    [1]=&gt;
    string(3) &quot;131&quot;
    [2]=&gt;
    string(3) &quot;191&quot;
  }
  [3]=&gt;
  array(3) {
    [0]=&gt;
    string(3) &quot;114&quot;
    [1]=&gt;
    string(2) &quot;36&quot;
    [2]=&gt;
    string(2) &quot;93&quot;
  }
  [4]=&gt;
  array(3) {
    [0]=&gt;
    string(3) &quot;224&quot;
    [1]=&gt;
    string(3) &quot;159&quot;
    [2]=&gt;
    string(2) &quot;53&quot;
  }
}
*/</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bitbonsai.com/python-php-vs-find-ip-with-regex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Porque adoro jQuery</title>
		<link>http://www.bitbonsai.com/porque-adoro-jquery/</link>
		<comments>http://www.bitbonsai.com/porque-adoro-jquery/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 08:10:54 +0000</pubDate>
		<dc:creator>mw</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.bitbonsai.com/?p=140</guid>
		<description><![CDATA[Pedido: Fazer com que todos os links de uma determinada página sejam externos. Abordagem 1: Alterar a classe em php, genérica, para ver se o link é externo e acrescentar o target; por regex. Abordagem 2: Colocar no init.js $&#40;&#34;a[href^='http://']&#34;&#41;.attr&#40;&#34;target&#34;,&#34;_blank&#34;&#41;; E todo site fica assim; links externos, para fora! Aff... que doce.]]></description>
			<content:encoded><![CDATA[<p>Pedido: Fazer com que todos os links de uma determinada página sejam externos.</p>
<ul>
<li>Abordagem 1: Alterar a classe em php, genérica, para ver se o link é externo e acrescentar o target; por regex.</li>
<li>Abordagem 2: Colocar no init.js</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a[href^='http://']&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;target&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;_blank&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>E todo site fica assim; links externos, para fora!<br />
Aff... que doce.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bitbonsai.com/porque-adoro-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lifesaver snippets</title>
		<link>http://www.bitbonsai.com/lifesaver-snippets/</link>
		<comments>http://www.bitbonsai.com/lifesaver-snippets/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 18:56:15 +0000</pubDate>
		<dc:creator>mw</dc:creator>
				<category><![CDATA[snippet]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://www.bitbonsai.com/lifesaver-snippets/</guid>
		<description><![CDATA[Alguns códigos são simplesmente salvadores da pátria... Por exemplo: Tens de subir um site por 3g, e mesmo targzipando o site ele fica com 12Mb por causa dos .svn escondidos... tar --exclude='.svn' -czvf file.tar.gz ./* 6MB. Simples e eficaz...]]></description>
			<content:encoded><![CDATA[<p>Alguns códigos são simplesmente salvadores da pátria...</p>
<p>Por exemplo: Tens de subir um site por 3g, e mesmo targzipando o site ele fica com 12Mb por causa dos .svn escondidos...</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--exclude</span>=<span style="color: #ff0000;">'.svn'</span> <span style="color: #660033;">-czvf</span> file.tar.gz .<span style="color: #000000; font-weight: bold;">/*</span></pre></div></div>

<p>6MB. Simples e eficaz...</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bitbonsai.com/lifesaver-snippets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>facyBox, um mashup do facebox + fancybox</title>
		<link>http://www.bitbonsai.com/facybox/</link>
		<comments>http://www.bitbonsai.com/facybox/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 18:16:09 +0000</pubDate>
		<dc:creator>mw</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.bitbonsai.com/blog/?p=51</guid>
		<description><![CDATA[Gosto de trabalhar com o facebox, mas é muito facebook alike; gosto do fancybox, mas não acho tão flexível quando o facebox. Solução? fazer um mashup dos dois e dar origem à facybox!!! Disponível no github e aqui no bitbonsai labs.]]></description>
			<content:encoded><![CDATA[<p><a href="http://bitbonsai.com/facybox"><img class="alignright" title="facyBox" src="http://bitbonsai.com/facybox/demo/logo-facybox.png" alt="" width="264" height="90" /></a>Gosto de trabalhar com o <a href="http://famspam.com/facebox">facebox</a>, mas é muito facebook alike; gosto do <a href="http://fancybox.net/">fancybox</a>, mas não acho tão flexível quando o facebox.</p>
<p>Solução? fazer um mashup dos dois e dar origem à <strong>facybox</strong>!!!</p>
<p>Disponível no <a href="http://github.com/mwolff/facyBox/">github</a> e aqui no <a href="http://bitbonsai.com/facybox">bitbonsai labs</a>.</p>
<p style="text-align: center;"><img class="aligncenter" title="Exemplo da Facybox" src="http://img.skitch.com/20090917-gcrmihig3u752umma3uu1b8u9g.jpg" alt="" width="321" height="241" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bitbonsai.com/facybox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mySQL Backup e Restore</title>
		<link>http://www.bitbonsai.com/mysql-backup-e-restore/</link>
		<comments>http://www.bitbonsai.com/mysql-backup-e-restore/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 21:15:07 +0000</pubDate>
		<dc:creator>mw</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.bitbonsai.com/blog/?p=14</guid>
		<description><![CDATA[Backup Método 1 mysqldump -u root -h mysqserver -p --result-file=dbname_dbtable.sql dbname dbtable Método 2 mysql&#62;mysqldump -u root -p dbname &#62; dbname_dbtable.sql Restaurar mysql -u root -h mysqserver -p dbname &#60; dbname_dbtable.sql]]></description>
			<content:encoded><![CDATA[<h3>Backup</h3>
<p><strong>Método 1</strong></p>
<p><code style="padding: 0px; margin: 0px;" lang="mysql">mysqldump -u root -h mysqserver -p --result-file=dbname_dbtable.sql dbname dbtable</code></p>
<p><strong>Método 2</strong></p>
<p><code style="padding: 0px; margin: 0px;" lang="mysql">mysql&gt;mysqldump -u root -p dbname &gt; dbname_dbtable.sql</code></p>
<p>Restaurar</p>
<p><code style="padding: 0px; margin: 0px;" lang="mysql">mysql -u root -h mysqserver -p dbname &lt; dbname_dbtable.sql</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bitbonsai.com/mysql-backup-e-restore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IphoneApp – Hello World</title>
		<link>http://www.bitbonsai.com/iphone/</link>
		<comments>http://www.bitbonsai.com/iphone/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 21:19:17 +0000</pubDate>
		<dc:creator>mw</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.bitbonsai.com/blog/?p=17</guid>
		<description><![CDATA[Decidi escrever iPhoneApps. Primeiro passo? Aprender Objective-C. Com uma cópia do Learn Objective-C on the Mac, de Mark Dalrymple &#38; Scott Knaster coloquei a mão na massa. Como já tenho uma noção de C, não é tão estranho assim… claro que pensei que emNSString o NS era de NameSpace e não de NextStep, mas para [...]]]></description>
			<content:encoded><![CDATA[<p>Decidi escrever iPhoneApps. Primeiro passo? Aprender <a style="color: #2970a6; text-decoration: none; padding: 0px; margin: 0px;" href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/">Objective-C</a>.</p>
<p>Com uma cópia do <a style="color: #2970a6; text-decoration: none; padding: 0px; margin: 0px;" href="http://www.apress.com/book/view/9781430218159">Learn Objective-C on the Mac</a>, de Mark Dalrymple &amp; Scott Knaster coloquei a mão na massa. Como já tenho uma noção de C, não é <strong>tão</strong> estranho assim… claro que pensei que em<em>NSString</em> o NS era de NameSpace e não de NextStep, mas para essas informações super úteis um livro é essencial. <img src='http://www.bitbonsai.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>A primeira coisa, depois de baixar os 1,5GB do SDK (acho que vem com o XCode junto, que já tinha instalado) é escrever um Hello World, certo? Nada muito impressionante, mas é preciso começar por algum lugar…</p>
<p>Como preciso fazer algo mais bonito que o sample do livro, coloquei o fundo preto e um título na app. O grande lance é fazê-lo girar em qualquer direção e a App acompanhar. Aeae…</p>
<p><a href="http://www.bitbonsai.com/wp-content/uploads/2009/08/iphone-hello-world-300x192.jpg"><img class="aligncenter size-full wp-image-18" title="iphone-hello-world-300x192" src="http://www.bitbonsai.com/wp-content/uploads/2009/08/iphone-hello-world-300x192.jpg" alt="iphone-hello-world-300x192" width="300" height="192" /></a></p>
<div style="padding-top: 2px; padding-right: 4px; padding-bottom: 2px; padding-left: 4px; vertical-align: top; color: #333333; margin: 0px;">
<pre style="background-image: none; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; width: auto; float: none; clear: none; overflow-x: visible; overflow-y: visible; font-size: 12px; line-height: 1.333; font-family: monospace; background-position: initial initial; padding: 0px; margin: 0px; border: 1px none #cccccc;"><span style="color: #002200; padding: 0px; margin: 0px;">-</span> <span style="color: #002200; padding: 0px; margin: 0px;">(</span><span style="color: #a61390; padding: 0px; margin: 0px;">BOOL</span><span style="color: #002200; padding: 0px; margin: 0px;">)</span>shouldAutorotateToInterfaceOrientation<span style="color: #002200; padding: 0px; margin: 0px;">:</span>
    <span style="color: #002200; padding: 0px; margin: 0px;">(</span>UIInterfaceOrientation<span style="color: #002200; padding: 0px; margin: 0px;">)</span>interfaceOrientation <span style="color: #002200; padding: 0px; margin: 0px;">{</span>
    <span style="color: #a61390; padding: 0px; margin: 0px;">return</span> <span style="color: #a61390; padding: 0px; margin: 0px;">YES</span>;
<span style="color: #002200; padding: 0px; margin: 0px;">}</span></pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bitbonsai.com/iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
