<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[There's no place like ::1]]></title>
  <link href="http://blog.0x82.com/atom.xml" rel="self"/>
  <link href="http://blog.0x82.com/"/>
  <updated>2014-11-26T08:43:09+00:00</updated>
  <id>http://blog.0x82.com/</id>
  <author>
    <name><![CDATA[Rúben Fonseca]]></name>
    <email><![CDATA[fonseka@gmail.com]]></email>
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[AWS Lambda Functions in Go]]></title>
    <link href="http://blog.0x82.com/2014/11/24/aws-lambda-functions-in-go"/>
    <updated>2014-11-24T22:01:08+00:00</updated>
    <id>http://blog.0x82.com/2014/11/24/aws-lambda-functions-in-go</id>
    <content type="html"><![CDATA[<p><strong>Update 1</strong>: Thanks <a href="http://twitter.com/miksago">@miksago</a> for the much more robust node.js wrapper. I guess you can now see the reason why I wanted to avoid node :-)</p>

<p>I’m a big fan of AWS, and every year I get super excited about a new technology/service they release. Last year, I spent too much time marvelling about the simplicity and beauty of <a href="http://aws.amazon.com/kinesis/">AWS Kinesis</a>. And in the meantime, I&rsquo;ve been applying the same principle on a smaller project I&rsquo;m working on.</p>

<p>But this year I was stoked about <a href="http://aws.amazon.com/lambda/">AWS Lambda</a>. AWS Lambda is a “compute service that runs your code in response to events and automatically manages the compute resources for you, making it easy to build applications that respond quickly to new information”. This is a perfect match for the event-driven and micro services way of thinking that I’ve been learning to love more and more.</p>

<p>But after skimming through the documentation, I’ve realised that the only supported runtime is Javascript (via Node.JS). I’m sure they will expand this support in the future, but I wanted to use it right now. Since in the meantime I’ve also been <a href="https://github.com/rubenfonseca/rails-configd">experimenting with Go lang</a>, I wanted to find a way to run Go code on AWS Lambda right now.</p>

<!--more-->


<p>Fortunately, it’s well known that you can statically cross compile your Go binary. This means I could generate a x86_64 Linux binary on my OS X system, and include it in the Lambda function distribution.</p>

<blockquote class="twitter-tweet" lang="en"><p>Just uploaded a cross compiled Golang binary to AWS Lambda and called it from the node.js function: it works flawlessly <a href="https://twitter.com/hashtag/happy?src=hash">#happy</a> <a href="https://twitter.com/hashtag/hack?src=hash">#hack</a></p>&mdash; Ruben Fonseca (@rubenfonseca) <a href="https://twitter.com/rubenfonseca/status/535590126798508032">November 21, 2014</a></blockquote>


<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>


<p>So first of all, cross compile your Go app:</p>

<figure class='code'><figcaption><span>test.go</span><a href='https://gist.github.com/anonymous/b9d76a9b342945793673#file-test-go'>link</a></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class='go'><span class='line'><span class="kn">package</span> <span class="nx">main</span>
</span><span class='line'>
</span><span class='line'><span class="kn">import</span> <span class="p">(</span>
</span><span class='line'>  <span class="s">&quot;fmt&quot;</span>
</span><span class='line'>  <span class="s">&quot;os&quot;</span>
</span><span class='line'><span class="p">)</span>
</span><span class='line'>
</span><span class='line'><span class="kd">func</span> <span class="nx">main</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>  <span class="nx">fmt</span><span class="p">.</span><span class="nx">Printf</span><span class="p">(</span><span class="s">&quot;HELLO FROM GOLANG WITH ARGS %v&quot;</span><span class="p">,</span> <span class="nx">os</span><span class="p">.</span><span class="nx">Args</span><span class="p">)</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>




<figure class='code'><figcaption><span>Cross compile go binary</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ GOOS</span><span class="o">=</span>linux <span class="nv">GOARCH</span><span class="o">=</span>amd64 go build test.go
</span></code></pre></td></tr></table></div></figure>


<p>This will generate a <code>test</code> binary compatible with AWS servers. The only supported way of running AWS Lambda functions is still Node.JS. That means we still have to write a quick Javascript module to fork to our binary:</p>

<figure class='code'><figcaption><span>main.js</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="kd">var</span> <span class="nx">child_process</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;child_process&#39;</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'><span class="nx">exports</span><span class="p">.</span><span class="nx">handler</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">event</span><span class="p">,</span> <span class="nx">context</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>  <span class="kd">var</span> <span class="nx">proc</span> <span class="o">=</span> <span class="nx">child_process</span><span class="p">.</span><span class="nx">spawn</span><span class="p">(</span><span class="s1">&#39;./test&#39;</span><span class="p">,</span> <span class="p">[</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nx">event</span><span class="p">)</span> <span class="p">],</span> <span class="p">{</span> <span class="nx">stdio</span><span class="o">:</span> <span class="s1">&#39;inherit&#39;</span> <span class="p">});</span>
</span><span class='line'>
</span><span class='line'>  <span class="nx">proc</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;close&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">code</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">if</span><span class="p">(</span><span class="nx">code</span> <span class="o">!==</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>      <span class="k">return</span> <span class="nx">context</span><span class="p">.</span><span class="nx">done</span><span class="p">(</span><span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s2">&quot;Process exited with non-zero status code&quot;</span><span class="p">));</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>    <span class="nx">context</span><span class="p">.</span><span class="nx">done</span><span class="p">(</span><span class="kc">null</span><span class="p">);</span>
</span><span class='line'>  <span class="p">});</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>Now you can follow AWS Lambda instructions, create a <code>.zip</code> file with both the Go binary and the JS file, upload and invoke it. At the end, you can see something like this on Cloudwatch:</p>

<p><img src="https://dl.dropboxusercontent.com/s/2b9r8ahcoz1f6jx/2014-11-26%20at%2008.42.png" alt="Cloudwatch" /></p>

<p>So while you wait for AWS to add more runtimes, have fun with Go today :-)</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Dropbox Sync for Titanium Mobile iOS]]></title>
    <link href="http://blog.0x82.com/2013/06/24/dropbox-sync-for-titanium-mobile-ios"/>
    <updated>2013-06-24T10:02:00+01:00</updated>
    <id>http://blog.0x82.com/2013/06/24/dropbox-sync-for-titanium-mobile-ios</id>
    <content type="html"><![CDATA[<p>I&#8217;me very happy to release today a brand new module for Titanium Mobile on the Marketplace:</p>

<h3><a href="https://marketplace.appcelerator.com/apps/5954">Dropbox Sync for iOS</a></h3>

<p><a href="https://marketplace.appcelerator.com/apps/5954"><img class="right" src="http://f.cl.ly/items/0G0j27193X1y0L0m1N0g/sync-logo-vflqICaXf.png"></a></p>

<p>I can&rsquo;t count how many people requested this module. It seems that syncing files between
devices is very common problem that people want to solve. When I saw the Dropbox Sync had come
out with a new SDK for doing that, I decided to start working on it.</p>

<p>The <a href="https://marketplace.appcelerator.com/apps/5954">module</a> allows you to have your own
private Dropbox inside your iOS application.
The Sync module takes care of syncing all your data with Dropbox through a
familiar, file system-like interface. It&rsquo;s like giving your app its own,
private Dropbox client.</p>

<p>The Sync module handles all the caching, retrying, and file change
notifications. Writes are local so changes are immediate. The Sync API syncs to
Dropbox behind the scenes. The Sync module lets your app work great even
when offline and automatically syncs when it&rsquo;s back online.</p>

<p>The module
<a href="https://marketplace.appcelerator.com/apps/5954">starts with a free 15 days trial</a>
. If you&rsquo;re still undecided to try it, look at
what the people are saying about my other modules :)</p>

<p><a href="https://marketplace.appcelerator.com/listing?q=0x82+Company"><img class="center" src="http://f.cl.ly/items/0f3243330l1i0a1l361G/quality.png"></a></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Urban Airship and iOS6 Social Framework]]></title>
    <link href="http://blog.0x82.com/2012/10/23/urban-airship-and-ios6-social-framework"/>
    <updated>2012-10-23T15:50:00+01:00</updated>
    <id>http://blog.0x82.com/2012/10/23/urban-airship-and-ios6-social-framework</id>
    <content type="html"><![CDATA[<p>Today I&rsquo;ve two new awesome Titanium modules into the Marketplace:</p>

<h2>Urban Airship</h2>

<p><img class="right" src="https://app-direct-www-cloudfront.s3.amazonaws.com/app_resources/3833/thumbs_112/img9082139346393578518.png"></p>

<p>There&rsquo;s already an Urban Airship module on the Marketplace. However, I client
got in contact with me because it was not happy with the existing module. It
mainly lacked usefull features like Location management, In-App-Purchases and
Subscriptions!</p>

<p>The new module is available <a href="https://marketplace.appcelerator.com/apps/3833?1116369444">here</a>. It&rsquo;s also my first monthly subscription module.</p>

<h2>iOS6 Social Framework</h2>

<p><img class="right" src="https://app-direct-www-cloudfront.s3.amazonaws.com/app_resources/3830/thumbs_112/img2104366109455403508.png"></p>

<p>After the success of my <code>iOS5 Twitter</code> module, I&rsquo;ve released the new
<code>Social.framework</code> module for iOS6 or later devices! You can now directly post
to <code>Twitter</code>, <code>Facebook</code> and <code>Sina Weibo</code>. Also, you can integrate with their
APIs and not worry about signing requests and parsing responses.</p>

<p>The new module is available <a href="https://marketplace.appcelerator.com/apps/3830?482986031">here</a></p>

<p>If you like the new modules, please don&rsquo;t forget to rate them :)</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Suggest My Next Titanium Mobile Module]]></title>
    <link href="http://blog.0x82.com/2012/05/08/suggest-my-next-titanium-mobile-module"/>
    <updated>2012-05-08T16:14:00+01:00</updated>
    <id>http://blog.0x82.com/2012/05/08/suggest-my-next-titanium-mobile-module</id>
    <content type="html"><![CDATA[<p>Today I&rsquo;m opening a UserVoice account so you can suggest and vote for my next
Titanium Mobile module. Right now I have a couple of ideas, but I&rsquo;ll let you
decide :)</p>

<p>You will find the forum <a href="http://0x82.uservoice.com/forums/161203-modules">here</a>. Thank
you for participating!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Titanium With Coffeescript and Backbone.js - Part 2]]></title>
    <link href="http://blog.0x82.com/2012/04/11/titanium-with-coffeescript-and-backbone-dot-js-part-2"/>
    <updated>2012-04-11T19:53:00+01:00</updated>
    <id>http://blog.0x82.com/2012/04/11/titanium-with-coffeescript-and-backbone-dot-js-part-2</id>
    <content type="html"><![CDATA[<p>In <a href="http://blog.0x82.com/2012/04/04/titanium-with-coffeescript-and-backbone-dot-js">Part 1</a> I looked into Titanium
with Coffeescript and a Rakefile for compiling and run from the CLI. Now it is time to see how
I integrate with <a href="http://documentcloud.github.com/backbone/">Backbone.js</a> for pure REST awesomeness.</p>

<p><strong>Warning</strong>: I will assume you are using Ruby on Rails as the server backend.</p>

<!-- more -->


<h2>Integrating backbone.js libraries</h2>

<p>Backbone.js is often used with
<a href="http://documentcloud.github.com/underscore/">underscore.js</a>, and I actually
use the later a lot. So the first thing I do is to install backbone and
underscore under <code>Resources/lib</code> directory, and import it on my <code>main.coffee</code> file.</p>

<p>Now the thing is, Backbone is pure Javascript and by default has no idea on how
to make a HTTP call, besides using jQuery for AJAX. So I dug a little on the
internet and found a Titanium compatible <code>Backbone.Sync</code> module that you can
see <a href="https://gist.github.com/rubenfonseca/2353736#file_backbone.sync.js">on this gist</a>. This version
uses <code>Ti.Network.HTTPClient</code> to proper transmit the HTTP requests.</p>

<h2>Making Rails accept the HTTP POST data</h2>

<p>Now that my Titanium App knows how to make proper HTTP requests, I have
another problem. During my tests I couldn&rsquo;t make Titanium send the model&rsquo;s
attributes in the correct format for Rails to recognize them. Somehow Rails is
supposed to accept the body encoded as JSON but I never got it to work. Also, I
found no way of sending Files (<code>TiBlob</code>) to Rails without using my custom
solution (how do you encode binary data on JSON?).</p>

<p>So I needed to invent a way of formatting the model&rsquo;s attributes using Rails&#8217;
standards. You&rsquo;ve probably noticed that on line 28 I call <code>model.toParams()</code>
if I&rsquo;m sending a POST body. So I hacked a quick way of generating Rails
compatible attributes, and extracted into a class called QueryStringBuilder:</p>

<div><script src='https://gist.github.com/2353736.js?file=query_string_builder.coffee'></script>
<noscript><pre><code>class QueryStringBuilder
  stringify: (obj, prefix, accum = {}) -&gt;
    if _.isArray(obj)
      this.stringifyArray obj, prefix, accum
    else if _.isString(obj) || _.isNumber(obj) || _.isDate(obj) || &quot;#{obj}&quot; == &quot;[object TiBlob]&quot;
      this.stringifyString obj, prefix, accum
    else if _.isBoolean(obj)
      this.stringifyBoolean obj, prefix, accum
    else if obj?
      if obj.attributes?
        this.stringifyObject obj.attributes, prefix, accum
      else
        this.stringifyObject obj, prefix, accum
    else
      return prefix

    accum

  stringifyBoolean: (bool, prefix, accum) -&gt;
    unless prefix
      throw new TypeError(&quot;Stringify expects an object&quot;)

    accum[prefix] = if bool then 1 else 0

  stringifyString: (str, prefix, accum) -&gt;
    unless prefix
      throw new TypeError(&quot;Stringify expects an object&quot;)

    accum[prefix] = str

  stringifyArray: (arr, prefix, accum) -&gt;
    unless prefix
      throw new TypeError(&quot;Stringify expects an object&quot;)

    i = 0
    for item in arr
      this.stringify(item, &quot;#{prefix}[#{i++}]&quot;, accum)

  stringifyObject: (obj, prefix, accum) -&gt;
    for key, value of obj
      continue if key.match(/_preview$/)

      new_key = key
      if _.isArray(value)
        new_key = &quot;#{key}_attributes&quot;

      new_prefix = &#39;&#39;
      if prefix
        new_prefix = &quot;#{prefix}[#{encodeURIComponent(new_key)}]&quot;
      else
        new_prefix = encodeURIComponent new_key

      this.stringify value, new_prefix, accum</code></pre></noscript></div>


<p>This class uses underscore calls to detect variable types, and should handle
most of the basic types on your application. It should handle nested attributes too,
and notice that when an attribute is a file (<code>TiBlob</code>) it just passes the object
down the stack, because later, the Titanium HTTP module will handle it and encode
on the POST body.</p>

<h2>Defining a Backbone model</h2>

<p>So armed with the previous tool, I could for instance write a Backbone module
to handle blog posts like this:</p>

<div><script src='https://gist.github.com/2353736.js?file=post_model.coffee'></script>
<noscript><pre><code>class Post extends Backbone.Model
  urlRoot: app.endpoint + &quot;/posts&quot;

  toParams: -&gt;
    # assuming you&#39;ve stored an instance of the previous QueryStringBuilder class...
    app.query_string_builder.stringify(this.attributes, &quot;post&quot;)

class Posts extends Backbone.Collection
  url: app.endpoint + &quot;/posts&quot;
  model: Post

app.models.Post = Post
app.models.Posts = Posts
</code></pre></noscript></div>


<h2>Binding to Titanium Views</h2>

<p>So with the previous mechanism, it&rsquo;s very easy to tie Backbone Models to
Titanium Views. Remember the way I did ViewControllers on part 1? Let&rsquo;s build
one that manages blog posts using a <code>TableView</code>:</p>

<div><script src='https://gist.github.com/2353736.js?file=posts_view_controller.coffee'></script>
<noscript><pre><code>class PostsViewController
  # assumming an existing @tableView and @window
  
  reload: -&gt;
    @posts = new app.models.Posts()
    @posts.fetch
      success: =&gt;
        @prepareData(@posts.models)

      error: (e) =&gt;
        Ti.API.error JSON.stringify(e)
        
  prepareData: (models) -&gt;
    @tableView.data = _.map models, (model) -&gt;
      { title: model.get(&#39;title&#39;), model: model, hasChild: true }
</code></pre></noscript></div>


<p>So a simple fetch and massage the data to fit the tableview. Nothing fancy so
far right? Now the best part comes when you&rsquo;re showing a <code>Post</code> model:</p>

<div><script src='https://gist.github.com/2353736.js?file=post_view_controller.coffee'></script>
<noscript><pre><code>class PostViewController
  initialize: (@post) -&gt;
    # create @window and @tableView
    
    data = []
    data.push @createTitleRow()
    data.push @createBodyRow()
    data.push @createAuthorRow()

    @tableView.data = data

  createTitleRow: -&gt;
    row = Ti.UI.createTableViewRow
      title: @post.get(&#39;title&#39;)

    @post.bind &#39;change:title&#39;, (e) =&gt;
      row.title = @post.get(&#39;title&#39;)

    row

  # ...
</code></pre></noscript></div>


<p>Notice line 16 and 17. We are literally binding the model attributes to a view
(in our case, a row). So imagine that for some reason, you change the title of
the post (by doing <code>@post.set({title:"foo"})</code>), Backbone would trigger the
change, and the table view row would automatically display the new value! For
instance, imagine an <code>Edit</code> button that shows a drill down view controller to
edit the post. As soon as you change a value on the model, the parent view will
be updated! That for me was plain awesome when it worked for the first time.</p>

<p>So by using this method, all I have to do is to bind model attributes to
Titanium views, and all changes are automatically propagated to the correct
places! Using this setup saved me <em>a lot of time and code</em> writing REST
applications with iOS and Titanium.</p>

<p>Now this blog post is getting big and there are some things I didn&rsquo;t talk, like
how to save models on our Rails backend, and how this setup works on Android
(hint: it does work!). Maybe I&rsquo;ll leave that and a few tricks for part 3? :-)</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[New Titanium Module: Sincerely]]></title>
    <link href="http://blog.0x82.com/2012/04/09/new-titanium-module-sincerely"/>
    <updated>2012-04-09T23:02:00+01:00</updated>
    <id>http://blog.0x82.com/2012/04/09/new-titanium-module-sincerely</id>
    <content type="html"><![CDATA[<p><a href="https://marketplace.appcelerator.com/apps/2416"><img class="right" src="http://0x82.blog.s3.amazonaws.com/09042012/img2253477772105568470.png" width="170"></a></p>

<p>I&rsquo;ve just published a new iOS Titanium Module on the Appcelerator&rsquo;s
Marketplace: <a href="https://marketplace.appcelerator.com/apps/2416">Sincerely</a> for
9.99 USD.  It integrates with the <a href="http://sincerely.com">Sincerely SDK</a> and
allows you to send greeting cards to the people you care about most.</p>

<p>The Sincerely Ship Library for iOS makes adding photo printing and postcard
functionality to your app as easy as including a library. Sincerely will handle
printing, delivery, billing and customer support. Your users will get a
physical product they&rsquo;ll love &amp; you&rsquo;ll extend your brand and monetize your app.</p>

<!-- more -->


<h3>Main features</h3>

<ul>
<li>Add print &amp; ship functionality to your app in under 1 hour.</li>
<li>Monetize your app; earn 70% of purchase price above 99 cents.</li>
<li>Leverage Sincerely Inc.&rsquo;s global printing and user network</li>
<li>Spread your brand; each printed postcard has developer branding area.</li>
</ul>


<h2>Sponsored by Jim Carter III</h2>

<p>I also want to publicly thank <a href="http://twitter.com/noinput">Jim Carter III</a> for
sponsoring the development of this module.  Thank you!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Titanium With Coffeescript and Backbone.js]]></title>
    <link href="http://blog.0x82.com/2012/04/04/titanium-with-coffeescript-and-backbone-dot-js"/>
    <updated>2012-04-04T18:40:00+01:00</updated>
    <id>http://blog.0x82.com/2012/04/04/titanium-with-coffeescript-and-backbone-dot-js</id>
    <content type="html"><![CDATA[<p>I&rsquo;ve been doing a lot of Titanium Mobile development lately. In my quest of
getting more efficient doing it, I think I finally found a sweet spot that
allows me to concentrate on implementing features, and not fight with
Titanium and CommonJS modules.</p>

<p>This is part 1 of this post. I will cover how I use CoffeeScript with Titanium
and automate stuff. On part 2 I will talk about how Backbone.js was the best thing
I could add to my Titanium project&hellip; yet :)</p>

<!-- more -->


<h3>CoffeeScript</h3>

<p>I personally dislike the Javascript syntax, and although I don&rsquo;t think
CoffeeScript is the holy grail, I think it does a pretty good job of hiding the
pieces I hate. I really feel 2 or 3 times more productive when writing
CoffeeScript. So <em>I had</em> to integrate it with my Titanium projects.</p>

<p>OTOH, I only use Titanium Studio when I really have to. Otherwise, I do my
daily code on the CLI with Vim and tmux. That meant I had to come up with
a solution to run Titanium projects from the CLI. I quickly found some random
Gist with the instructions to do that. (some weeks ago, Matt Apperson launched
his <a href="https://github.com/mattapperson/MakeTi">MakeTi</a> tool too, it is worth
checking out).</p>

<p>So I wrote a Rakefile. You&rsquo;ll notice it&rsquo;s a very lazy one, because most of the
values I hardcoded could be derived by inspecting the XML files on the project.
But it does the basic job.</p>

<div><script src='https://gist.github.com/1974242.js?file=Rakefile'></script>
<noscript><pre><code>DEV_PROVISIONING_UUID = &quot;3E4D9E49-E44B-4B73-AFAD-248C720ECD53&quot;
DEV_SIGN = &quot;Ruben Fonseca&quot;
DEV_APP_NAME = &quot;My greatest app&quot;
DEV_APP_ID = &#39;com.0x82.app&#39;

TITANIUM_SDK_VERSION = &#39;1.8.2&#39;
IPHONE_SDK_VERSION = &#39;5.0&#39;
BUILDER_PATH = &quot;/Library/Application Support/Titanium/mobilesdk/osx/#{TITANIUM_SDK_VERSION}/iphone/builder.py&quot;

if File.exists?(BUILDER_PATH)
  BUILDER = BUILDER_PATH
elsif File.exists?(File.expand_path(&#39;~&#39;) + BUILDER_PATH)
  BUILDER = File.expand_path(&#39;~&#39;) + BUILDER_PATH
else
  raise &quot;Couldn&#39;t found builder.py for iPhone Titanium SDK #{TITANIUM_SDK_VERSION}&quot;
end

task :run do
  sh &#39;coffee -c -l -o Resources/js coffee&#39;

  FileUtils.mkdir_p(&#39;build/iphone&#39;)
  sh BUILDER, &#39;simulator&#39;, IPHONE_SDK_VERSION, File.dirname(__FILE__), DEV_APP_ID, DEV_APP_NAME
end

task :clean do
  sh &quot;rm -rf ./build&quot;
end

task :fresh =&gt; %w(clean run)

task :coffee do
  sh &#39;coffee -c -w -l -o Resources/js coffee&#39;
end

task :default =&gt; [:run]
</code></pre></noscript></div>


<h3>Wiring it</h3>

<p>So you&rsquo;ve noticed the <code>coffee</code> command on line 19? That&rsquo;s where the magic
happen. So let me quickly explain how I organize the skeleton of an app. I
useually create an empty Titanium project, add the Rakefile, and then create
the following structure:</p>

<p><img class="center" src="https://img.skitch.com/20120304-1inmt48yq9s6m4ak51hrr8g2yw.jpg" title="Titanium Mobile application structure" ></p>

<p>Let me break files 1 and 2 individually:</p>

<h4>1 - app.js</h4>

<p>This will be the only Javascript file I will need to write. The contents? Just
create the main namespace for the app (more on that later) and include the
generated <code>main.js</code> file!</p>

<div><script src='https://gist.github.com/1974242.js?file=app.js'></script>
<noscript><pre><code>var app = {
  classes: { },
  models : { }
};

Ti.include(&#39;js/main.js&#39;);</code></pre></noscript></div>


<p>The <code>Resources/js/main.js</code> file is derived from the <code>coffee/main.coffee</code> fill
we will now write.</p>

<h4>2 - main.coffee</h4>

<p>On this CoffeeScript file, I start by including other classes that I will
need, and bootstrap the application. Example:</p>

<div><script src='https://gist.github.com/1974242.js?file=main.coffee'></script>
<noscript><pre><code>Ti.include &#39;/lib/underscore.js&#39;
Ti.include &#39;/lib/backbone.js&#39;

Ti.include &#39;/js/main_view_controller.js&#39;

mvc = new app.classes.MainViewController()
mvc.open()</code></pre></noscript></div>


<p>So the final question is, how do I create and manage a &ldquo;view controller&rdquo;?</p>

<h3>Building View Controllers</h3>

<p>I love to use CoffeeScript classes to build &ldquo;view controllers&rdquo; around a window.
I usually build a class for each window, and some times one class for each
specialized view. A typical view controller class would be like this:</p>

<div><script src='https://gist.github.com/1974242.js?file=main_view_controller.coffee'></script>
<noscript><pre><code>class MainViewController
  constructor: -&gt;
    @window = Ti.UI.createWindow
      title: &quot;Main Window&quot;

    @button = Ti.UI.createButton
      title: &quot;button&quot;
    @window.add @button
    @button.addEventListener &#39;click&#39;, this.handle_btn_click

  open: -&gt;
    @window.open()

  handle_btn_click: (e) =&gt;
    Ti.API.warn &quot;button clicked: #{JSON.stringify e}&quot;
    
app.classes.MainViewController = MainViewController</code></pre></noscript></div>


<p>So notice how I encapsulate the logic into one class, and then store a
reference to the class on the global <code>app</code> scope. This is probably bad practice
because of CommonJS and stuff, but I found it is the best compromise for me,
and it makes me really focus on the code itself.</p>

<p>So what about modules, Backbone.js and network operations? Stay tuned for part
2 of this module where I talk how I use Backbone.js for REST operations and
view bindings.</p>

<p><strong>UPDATE</strong>: Part 2 <a href="http://blog.0x82.com/2012/04/11/titanium-with-coffeescript-and-backbone-dot-js-part-2">is online</a></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[New Blog Layout and Hire Me Section]]></title>
    <link href="http://blog.0x82.com/2011/10/14/new-blog-layout-and-hire-me-section"/>
    <updated>2011-10-14T10:43:00+01:00</updated>
    <id>http://blog.0x82.com/2011/10/14/new-blog-layout-and-hire-me-section</id>
    <content type="html"><![CDATA[<p>This week I&rsquo;ve introduced a new static blog engine based on the awesome
<a href="http://octopress.org/">Octopress</a> blogging framework. I really love the
simplicity, the readability and the mobile support of the default template.</p>

<p>OTOH, you may be noticing there is a new section on the top of this blog called
<a href="http://blog.0x82.com/hire_me/">Hire me</a>. Since sometimes I have free time on my freelance work,
I created that central point where potential clients could contact me and see
my status.</p>

<p>Since for now there isn&rsquo;t any type of notification system, please bookmark that
page if you&rsquo;re interested on working with me.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Dropbox SDK Module for Titanium Mobile (iOS)]]></title>
    <link href="http://blog.0x82.com/2011/04/12/dropbox-sdk-module-for-titanium-mobile-ios"/>
    <updated>2011-04-12T12:48:00+01:00</updated>
    <id>http://blog.0x82.com/2011/04/12/dropbox-sdk-module-for-titanium-mobile-ios</id>
    <content type="html"><![CDATA[<p>Today marks the first day <a href="https://marketplace.appcelerator.com/apps/737">I&#8217;m selling a piece of software on the internet.</a></p>
<p>This is the full Dropbox <span class="caps">SDK</span> module for Titanium Mobile applications. This is <span class="caps">ONLY</span> <span class="caps">FOR</span> iOS <span class="caps">DEVICES</span> (iPhone/iPad). It implements the full Dropbox <span class="caps">SDK</span> <span class="caps">API</span> in a clean JavaScript way.</p>
<p>Included with the file there is documentation and two different Titanium applications where the <span class="caps">API</span> is exercised. One of them is a clone of DBRoulete found on the Dropbox <span class="caps">SDK</span>, but implemented on top of Titanium Mobile.</p>
<p>I&#8217;m using this module in production on two iOS applications, so the module will be maintained.</p>
<p><iframe title="YouTube video player" width="600" height="380" src="http://www.youtube.com/embed/rK3DZV_ThvM?rel=0&amp;hd=1" frameborder="0" allowfullscreen></iframe></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Vim + Rails + Ctags = Power Navigation (Screencast)]]></title>
    <link href="http://blog.0x82.com/2011/03/02/vim-rails-ctags-powerful-navigation-screencast"/>
    <updated>2011-03-02T06:38:00+00:00</updated>
    <id>http://blog.0x82.com/2011/03/02/vim-rails-ctags-powerful-navigation-screencast</id>
    <content type="html"><![CDATA[<p>The lack of a proper (read: simple, fast, non-java) <span class="caps">IDE</span> for Ruby and Rails projects is something I still miss when using Vim. Specially when I need to work on a legacy project, I would love to have a better way of navigating through the methods and classes.</p>
<p>Recently I found an old but very efficient way of doing that using vim and <a href="http://ctags.sf.net">ctags</a>. The following is a simple screencast where I show how to use ctags to solve that type of problems.</p>
<p><iframe src="http://player.vimeo.com/video/20523237" width="600" height="360" frameborder="0"></iframe><p><a href="http://vimeo.com/20523237">Vim + ctags demo</a> from <a href="http://vimeo.com/user887154">Ruben Fonseca</a> on <a href="http://vimeo.com">Vimeo</a>.</p></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Map Crowd Reduce]]></title>
    <link href="http://blog.0x82.com/2010/11/22/map-crowd-reduce"/>
    <updated>2010-11-22T07:06:00+00:00</updated>
    <id>http://blog.0x82.com/2010/11/22/map-crowd-reduce</id>
    <content type="html"><![CDATA[<p>My latest open project is a &#8220;<span class="caps">SETI</span>-at-home-like infrastructure for massively distributed <span class="caps">CPU</span>-intensive jobs based on HTML5 WebWorkers and node.js for distributing tasks&#8221; (quote from <a href="http://metaduck.com/post/1566446922/codebits-2010">Pedro Teixeira&#8217;s blog</a>).</p>
<p>It&#8217;s called <a href="https://github.com/rubenfonseca/map_crowd_reduce">Map Crowd Reduce</a> and it&#8217;s available on <a href="https://github.com/rubenfonseca/map_crowd_reduce">github</a>.</p>
<p>This project made into the final <a href="http://codebits.eu"><span class="caps">SAPO</span> Codebits 2010</a> programming contest, but unfortunately didn&#8217;t win :)</p>
<p>The project consists of a <a href="http://nodejs.org/">node.js</a> server that starts a <span class="caps">HTTP</span> server on port 3000. To start a new computation, you must supply some javascript functions: a split/segmenter function that generates jobs, a map function, and a reduce function.</p>
<p>After that, the system gives you an <span class="caps">URL</span> that you can share with anyone wanting to contribute with <span class="caps">CPU</span> to the computation. The client side functions are run inside a <a href="http://www.whatwg.org/specs/web-workers/current-work/">WebWorker</a> so it never blocks the main UI thread.</p>
<p><a href="http://0x82.blog.s3.amazonaws.com/22112010/map_crowd_reduce.png"><img src="http://0x82.blog.s3.amazonaws.com/22112010/map_crowd_reduce_small.png" alt="" /></a></p>
<p>With the code there are 2 prewritten examples:</p>
<ul>
	<li>find the number of primes between 0 and 60000 (brute force)</li>
</ul>
<p>this uses a brute-force method of testing if each number is a prime, from 0 to 60000. it runs very fast and can be used to debug.</p>
<ul>
	<li>find a MD5 collision with the <acronym title="&#39;code&#39;"><span class="caps">MD5</span></acronym> on all words with 5 or less alfa words</li>
</ul>
<p>this lasts 15 minutes on a single machine. when I tested it on the main stage, 50 people connected their browsers at it lasted like 20 seconds (#win).</p>
<p>We are currently trying to write a parallel <a href="http://en.wikipedia.org/wiki/Mandelbrot_set">Mandelbrot fractal</a> using map reduce :) it will be awesome.</p>
<p>Finally, I couldn&#8217;t have built this project without the <a href="http://codebits.eu/microft">help</a> <a href="http://codebits.eu/overflow">of</a> <a href="http://codebits.eu/regadas">some</a> <a href="http://codebits.eu/smash">friends</a>.</p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Twitterrsslinks Version 2]]></title>
    <link href="http://blog.0x82.com/2010/09/26/twitterrsslinks-version-2"/>
    <updated>2010-09-26T12:48:00+01:00</updated>
    <id>http://blog.0x82.com/2010/09/26/twitterrsslinks-version-2</id>
    <content type="html"><![CDATA[<p>Today I&#8217;m announcing version 2 of <a href="http://twitterrsslinks.com">twittersslinks</a>.</p>
<p>TwitterRSSLinks is a Twitter (OAuth) service that filter all your timeline tweets that contain <span class="caps">HTTP</span> links, so you can aggregate and watch them later and so on. The website outputs the tweets in a variety of formats including <span class="caps">JSON</span>, <span class="caps">RSS</span> and <span class="caps">ATOM</span>.</p>
<p>Version 1 was shutdown because I had no plan for monetizing the service, and at the time, there was a good alternative. Now the alternative is dead and <a href="http://dev.twitter.com/pages/user_streams">Twitter UserStreams</a> is in Beta.</p>
<p>There&#8217;s a good excuse to learn <a href="http://nodejs.org">node.js</a>. :)</p>
<p>Without further ado, here&#8217;s version 2 architecture (sorry for the quality, I am definitly not a drawing guy&#8230;):</p>
<p><a href="http://0x82.blog.s3.amazonaws.com/26092010/twitterrsslinks.png"><img src="http://0x82.blog.s3.amazonaws.com/26092010/twitterrsslinks_small.png" alt="" /></a></p>
<p>The site is completely free, and now beneficts from the real-time user-stream feeds. Also, I&#8217;m using <a href="http://pusherapp.com">pusherapp</a> for the first time, just in case you are on the browser and a new tweet arrives :)</p>
<p>The live website runs on a EC2 Micro instance, and I will definitly open the source in the near future. Happy tweets :)</p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Gowalla Spots Google Maps Mashup]]></title>
    <link href="http://blog.0x82.com/2010/03/01/gowalla-spots-google-maps-mashup"/>
    <updated>2010-03-01T09:29:00+00:00</updated>
    <id>http://blog.0x82.com/2010/03/01/gowalla-spots-google-maps-mashup</id>
    <content type="html"><![CDATA[<p>Sunday monday fun: <a href="http://github.com/pengwynn/gowalla">gowalla gem</a>, <a href="http://maps.google.com">google maps</a>, some Javascript stuff, and a Rails app.</p>
<p><a href="http://gowallamaps.heroku.com">Gowalla spots Google Maps Mashup</a> [http://gowallamaps.heroku.com]</p>
<p>It tries to use HTML5 geo location to get a position on the map (defaults to somewhere on <span class="caps">USA</span>). Probably best used on the iphone (tried on a friend&#8217;s Android and it failed :S). Screenshot:</p>
<p><img src="http://0x82.blog.s3.amazonaws.com/01032010/gowalla.png" alt="" /></p>
<p>Simple hack, and a reminder for <a href="http://www.gowalla.com">Gowalla</a> to open up their <span class="caps">API</span> :) Thnks @pengwynn for the awesome gem :)</p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[ActivityStreams Parser Ruby Gem]]></title>
    <link href="http://blog.0x82.com/2010/02/25/activitystreams-ruby-parser-gem"/>
    <updated>2010-02-25T07:02:00+00:00</updated>
    <id>http://blog.0x82.com/2010/02/25/activitystreams-ruby-parser-gem</id>
    <content type="html"><![CDATA[<p><a href="http://activitystrea.ms/">ActivityStreams</a> is the next big thing <sup>TM</sup>. It defines a protocol to syndicate activities taken from web applications (mainly social ones) and services. Just imagine a common spec for describing the activities a user do on Facebook, FriendFeed, Delicious, etc.</p>
<p>The protocol originally targeted the Atom <span class="caps">XML</span> Standard, via an extension. Later, some work has been done on standardizing a <span class="caps">JSON</span> format too.</p>
<p>With that in mind, I&#8217;ve tried to implement a Ruby parser that defines a common <span class="caps">API</span> to access both the Atom and the <span class="caps">JSON</span> specification. Is is now available on <a href="http://github.com/webcracy/activity_streams">github</a> and also as a <a href="http://rubygems.org/gems/activity_streams">Ruby gem</a>.</p>
<p>Here&#8217;s a simple demonstration on how it works. We take the excellent <a href="http://feedproxy.cliqset.com/">Cliqset feed proxy</a> and get an activity streams annotated Twitter Atom feed:</p>
<script src="http://gist.github.com/314594.js?file=activity_streams_example.rb"></script><p>The <span class="caps">JSON</span> <span class="caps">API</span> is very similar. Some documentation is up on <a href="http://rdoc.info/projects/webcracy/activity_streams">rdoc.info</a> and it is worth checking the spec too. Have fun :)</p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[OpenCL in MacRuby (Hack, Not Very Useful)]]></title>
    <link href="http://blog.0x82.com/2010/01/23/opencl-in-macruby-hack-not-very-useful"/>
    <updated>2010-01-23T12:39:00+00:00</updated>
    <id>http://blog.0x82.com/2010/01/23/opencl-in-macruby-hack-not-very-useful</id>
    <content type="html"><![CDATA[<p>Quick post to let you know about my latest hack: basic support for <a href="http://en.wikipedia.org/wiki/OpenCL">OpenCL</a> on <a href="http://macruby.org">MacRuby</a> and Snow Leopard.</p>
<ul>
	<li>it is my first Ruby C extension ever	<li>it is my first OpenCL approach ever	<li>it is my first MacRuby hack (ever)</ul>
<p>With this in mind, don&#8217;t expect real world usage from this code, nor that it will get merged into upstream: it was just written for fun!</p>
<p>The MacRuby branch with the changes is located <a href="http://github.com/rubenfonseca/macruby">here</a></p>
<h4>Example</h4>
<p>The hello world on OpenCL is probably &#8220;calculate each element&#8217;s square on a given array&#8221;. The code below shows how this can be done in MacRuby:</p>
<script src="http://gist.github.com/284779.js?file=test_macruby_opencl.rb"></script><p>This code runs the same computation on all available OpenCL devices on your hardware. The results on my hardware (2 GPUs, 1CPU) are:</p>
<script src="http://gist.github.com/284792.js?file=gistfile1.txt"></script><p>It was fun, and maybe it can inspire someone :) The OpenCL <span class="caps">API</span> is kinda complex and I&#8217;m not sure if there&#8217;s a good way of making it Rubyish enough. Suggestions are welcome! Have fun :)</p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Twitter AMQP WebSocket Example (No Polling)]]></title>
    <link href="http://blog.0x82.com/2009/12/28/twitter-amqp-websocket-example-no-polling"/>
    <updated>2009-12-28T10:18:00+00:00</updated>
    <id>http://blog.0x82.com/2009/12/28/twitter-amqp-websocket-example-no-polling</id>
    <content type="html"><![CDATA[<p>HTML5 is here! Urray!</p>
<p>I was tired of hearing about one of the new innovation in HTML5: the <a href="http://dev.w3.org/html5/websockets/">WebSocket <span class="caps">API</span></a>.</p>
<p>After reading the excelent blog post about <a href="http://www.igvita.com/2009/12/22/ruby-websockets-tcp-for-the-browser/">WebSockets and Ruby</a> by Ilya Grigorik I got inspired by <a href="http://rfw.posterous.com/musictweets-a-rediswebsocket-powered-experime">this experiment</a> which is a simple example of a <em>twitter-to-browser</em> usage of websockets.</p>
<p>Since the excelent <a href="http://github.com/igrigorik/em-websocket">em-websocket</a> was available on github, I decided to write my own &#8220;from twitter to the browser&#8221; real time updates, with no polling.</p>
<p>You can check the final result on <a href="http://github.com/rubenfonseca/twitter-amqp-websocket-example">my github repo</a>.</p>
<h3>General overview</h3>
<p>Twitter Stream <span class="caps">API</span> &#8594; Filter &#8594; RabbitMQ &#8594; <span class="caps">AMQP</span> &#8594; Eventmachine &#8594; WebSocket &#8594; HTML5 Brwser</p>
<p>Too much buzzwords? Lets look at some code.</p>
<h3>Filter</h3>
<p>The filter is responsible for eating the <a href="http://apiwiki.twitter.com/Streaming-API-Documentation">Twitter Stream <span class="caps">API</span></a> and puting the tweets on a queue (RabbitMQ in my case) using <span class="caps">AMQP</span>:</p>
<script src="http://gist.github.com/264450.js?file=gistfile1.rb"></script><p>Pretty easy right? Notice I am using a fanout exchange, which will allow me to broadcast the same message to all queues (clients) latter on.</p>
<h3>Server</h3>
<p>Now we just need to build a server that accepts websocket connections, and for each client deliver each message that arrives on the fanout exchange. The code will make this clear:</p>
<script src="http://gist.github.com/264453.js?file=gistfile1.rb"></script><p>So simple, yet so awesome!</p>
<h3>Client</h3>
<p>The client just have to connect the websocket, and for each <span class="caps">JSON</span> piece that arrives on the socket, present them on the screen:</p>
<script src="http://gist.github.com/264454.js?file=gistfile1.js"></script><p>It seems we&#8217;ve ended writing almost more JS than Ruby :P Note that I&#8217;ve only tested this on Webkit nightly and latest Google Chrome beta for Mac.</p>
<p>Overall it was a great and easy experience building this simple system, but it allowed me to realize how simple we can build scalable push systems with the WebSocket <span class="caps">API</span>!</p>
<p><strong>update</strong>: seems like <a href="http://twitter.com/igrigorik/status/7107086085">Ilya Grigorik liked it</a> :)</p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Cheap Calls to Any Portuguese Mobile Network]]></title>
    <link href="http://blog.0x82.com/2009/07/17/cheap-calls-to-any-portuguese-mobile-network"/>
    <updated>2009-07-17T14:18:00+01:00</updated>
    <id>http://blog.0x82.com/2009/07/17/cheap-calls-to-any-portuguese-mobile-network</id>
    <content type="html"><![CDATA[<p>Are you tired of calling your friends and family at prices from the last century? Do you feel frustrated every time you have to top-up the credit of your mobile phone, just because you are obliged to? Do you hate the obvious portuguese <em>cartel</em> around mobile operators?</p>
<p>Well, fell no more! Enter the VoIP world!</p>
<p><a href="http://www.betamax.com">Betamax</a> created <a href="http://backsla.sh/betamax">lots of</a> providers specialized in VoIP. Although almost all of them offer free calls to Portuguese landline numbers, I never realized how competitive they were on the mobile side.</p>
<p>So I dig a little, and found some pretty competitive Betamax VoIP providers:</p>
<ul>
	<li>12voip.com &#8211; 4.5 cent/min</li>
</ul>
<ul>
	<li>voipraider.com &#8211; 5.0 cent/min</li>
</ul>
<ul>
	<li>webcalldirect.com &#8211; 6.0 cent/min</li>
</ul>
<p>The best thing about these providers is</p>
<ul>
	<li>No required monthly payment</li>
</ul>
<ul>
	<li>You can use your own phone number as Caller ID (so people still answer your calls).</li>
</ul>
<ul>
	<li>They all support the <span class="caps">SIP</span> protocol (great for non-windows users like me)</li>
</ul>
<ul>
	<li>Same price for all the mobile operators (so you can jump the wall garden)</li>
</ul>
<p>I hope that this information helps you lowering your phone bill. Spread the word, and maybe your mobile operator starts lowering the prices too!</p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Optimus Webphone SIP Settings]]></title>
    <link href="http://blog.0x82.com/2009/05/23/optimus-webphone-sip-settings"/>
    <updated>2009-05-23T08:41:00+01:00</updated>
    <id>http://blog.0x82.com/2009/05/23/optimus-webphone-sip-settings</id>
    <content type="html"><![CDATA[<p>I am a client of the <a href="http://www.optimustag.pt">optimus tag</a> service (for English users, it&#8217;s a phone plan that includes free calls for any other phone using the same network plan).</p>
<p>Recently, I discovered they have a <a href="http://www.optimustag.pt/Servicos/Webphone.jsp">softphone like system</a> called Webphone (Windows only), that allows you to place and receive calls, <span class="caps">SMS</span>, <span class="caps">MMS</span>, and other stuff, right from your computer.</p>
<p>My first thought was &#8220;this must use some kind of <span class="caps">SIP</span> service&#8221;. Since the <span class="caps">SIP</span> settings are not posted anywhere on the internet, and I don&#8217;t want to use Windows to use their client, I decided to dig deeper and try to find the <span class="caps">SIP</span> configurations so it can work on any regular softphone.</p>
<p>Although it was easier than I thought (<a href="http://www.wireshark.org">Wireshark</a>, I love you), there is one serious limitation that I couldn&#8217;t solve without hacking some open source code. Anyway here&#8217;s the main settings:</p>
<h3>Optimus Tag <span class="caps">SIP</span> settings (to use with a <span class="caps">SIP</span> softphone)</h3>
<ul>
	<li><strong>server address</strong>: sip.optimus.pt</li>
	<li><strong>username</strong>: 351 <em>your number</em>@sip.optimus.pt</li>
	<li><strong>password</strong>: your webphone password</li>
	<li><strong><span class="caps">SIP</span> proxy</strong>: asbg.sip.optimus.pt</li>
	<li><strong>User Agent</strong>: Optimus-SoftPhone/7.0.1.4124</li>
</ul>
<p>Now, the last item is the worst part. If you don&#8217;t specify a <strong>User-Agent</strong> that starts with <code>Optimus-SoftPhone</code>, you&#8217;ll receive a &#8220;403 Forbidden User Agent&#8221; message. I tried to find a <span class="caps">SIP</span> softphone that allowed me to change the UserAgent but didn&#8217;t found one (I didn&#8217;t try hard).</p>
<p>So I decided to take the <a href="http://www.twinklephone.com">Twinkle</a> open source <span class="caps">SIP</span> client, changed the hard coded User Agent, and got surprised when it worked flawlessly from the first time! I tried placing and receiving calls and it worked perfectly :)</p>
<p>If you&#8217;re interested on the trivial patch (I used Twinkle version 1.4.2) you can find it <a href="http://gist.github.com/116644">here</a>.</p>
<p>If you know a <span class="caps">SIP</span> client for OS X or Linux that allows me to change the User Agent, don&#8217;t hesitate to comment bellow!</p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Two More Contributions to the Open Source World]]></title>
    <link href="http://blog.0x82.com/2009/05/22/two-more-contributions-to-the-open-source-world"/>
    <updated>2009-05-22T15:22:00+01:00</updated>
    <id>http://blog.0x82.com/2009/05/22/two-more-contributions-to-the-open-source-world</id>
    <content type="html"><![CDATA[<p>quick post to let you know my latest two mini-projects on <a href="http://www.github.com">github</a>:</p>
<h3>Ruby library to whit.me service <span class="caps">API</span></h3>
<p><a href="http://whit.me">whit.me</a> is a wonderful service to shorten URLs. They have a <a href="http://www.whit.me/api/docs">public <span class="caps">API</span></a>, and I wrote this library that allows you to use the service in the middle of any Ruby script.</p>
<p>The project is available <a href="http://github.com/rubenfonseca/whitme/tree/master">here</a>. It is compatible with Ruby 1.9 and JRuby, and contains a full RSpec test suite.</p>
<h3>newzbin <span class="caps">XMPP</span> search agent</h3>
<p>After spending some time learning <a href="http://xmpp.org"><span class="caps">XMPP</span></a>, I decided to try it and build something useful. So I hacked a simple search agent for the <a href="http://newzbin.com">newzbin</a> website to be used by me and my friends. It is poorly written, but it works.</p>
<p>Maybe you can learn something from the simple example. In case you&#8217;re  interested, the code is available <a href="http://github.com/rubenfonseca/newzbin_xmpp/tree/master">again on github</a>. It uses the XMPP4R gem and CouchDB (overkill, I know).</p>
<p>Feel free to comment on any of the code and send me suggestions on how to  improve it.</p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[24, Blowfish, Bruce Schneier, and LOL]]></title>
    <link href="http://blog.0x82.com/2009/03/20/24-blowfish-bruce-schneier-and-lol"/>
    <updated>2009-03-20T01:48:00+00:00</updated>
    <id>http://blog.0x82.com/2009/03/20/24-blowfish-bruce-schneier-and-lol</id>
    <content type="html"><![CDATA[<p>Quick note about the latest <a href="http://www.fox.com/24/">24</a> episode (7&#215;14). When <span class="caps">FBI</span> needed to decrypt an email that was sent using the <a href="http://whit.me/CwcyoP">Blowfish</a> cipher, a &#8220;level 6 analyst&#8221; walks into a computer and says:</p>
<blockquote>
<p>&#8220;The designer of this algorithm built a backdoor into the code. Decryption is a piece of cake if you know the override codes.&#8221;</p>
</blockquote>
<p>Five seconds later, the file is decrypted :)</p>
<p>I guess <a href="http://www.schneier.com/">Bruce Scheier</a>, the author of the original cipher, should not be happy to hear this on a TV show :P</p>]]></content>
  </entry>
  
</feed>
