<?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>SPARQ.BLOG</title>
	<atom:link href="http://blog.sparqcode.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sparqcode.com</link>
	<description>The insider&#039;s guide to everything sparqcode</description>
	<lastBuildDate>Tue, 16 Aug 2011 00:22:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Using Mixins With Ruby</title>
		<link>http://blog.sparqcode.com/2011/04/20/using-mixins-with-ruby/</link>
		<comments>http://blog.sparqcode.com/2011/04/20/using-mixins-with-ruby/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 20:34:43 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Technical Development]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[ruby mixin programming]]></category>

		<guid isPermaLink="false">http://blog.sparqcode.com/?p=668</guid>
		<description><![CDATA[If you&#8217;re used to a language like C++ or Java the common way to share behavior across classes was to use inheritance. This has some problems because you should only really use inheritance in a is-a relationship. A politican class would probably behave like the fool class, but I don&#8217;t think it&#8217;s appropriate for the &#8230; <a href="http://blog.sparqcode.com/2011/04/20/using-mixins-with-ruby/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re used to a language like C++ or Java the common way to share behavior across classes was to use inheritance.  This has some problems because you should only really use inheritance in a is-a relationship.  A politican class would probably behave like the fool class, but I don&#8217;t think it&#8217;s appropriate for the politician to be a fool because then any changes to the fool would also the change the politician.</p>
<p>Now to have classes behave like others we use a strategy called encapsulation.  Using the previous example, you would do something like this:</p>
<pre name="code" class="ruby">
class Fool
  def speak
  end
end

class Politician < Fool
  def initialize
    @fool = Fool.new
  end

  def speak
    @fool.speak
  end
end
</pre>
<p>Now what if the implementation for speak was the same across the fool and politician classes and would always be the same?  Well we could use a mixin to define that behavior.</p>
<pre name="code" class="ruby">
module Speaking
  def speak
  end
end

class Fool
  include Speaking
end

class Politician
  include Speaking
end
</pre>
<p>Now this has one downside, lets say the Speaking module was written like this:</p>
<pre name="code" class="ruby">
module Speaking
  def speak
    "I say " + @motto
  end
end
</pre>
<p>This definition assumes and requires that both the Fool class and the Politician class have a @motto instance variable.  This would also apply to any method definitions that are  referenced as well.</p>
<p>The mixin is not the <a href="http://en.wikipedia.org/wiki/Law_of_the_instrument">golden hammer</a> but it is a very powerful tool to have in your toolbox.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sparqcode.com/2011/04/20/using-mixins-with-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Publishing A Gem With Jewler</title>
		<link>http://blog.sparqcode.com/2011/04/13/publishing-a-gem-with-jewler/</link>
		<comments>http://blog.sparqcode.com/2011/04/13/publishing-a-gem-with-jewler/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 01:30:38 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.sparqcode.com/?p=665</guid>
		<description><![CDATA[In order to do this you will need two things: the jeweler gem an account with rubygems.org Jeweler is pretty useful utility for managing your gem&#8217;s lifecycle. To get the jeweler gem run gem install jeweler To create your project run jeweler yournewgemname It will create a new git repository called yournewgemname. You are basically &#8230; <a href="http://blog.sparqcode.com/2011/04/13/publishing-a-gem-with-jewler/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In order to do this you will need two things:</p>
<ol>
<li>the jeweler gem</li>
<li>an account with rubygems.org</li>
</ol>
<p>Jeweler is pretty useful utility for managing your gem&#8217;s lifecycle.  To get the jeweler gem run</p>
<pre>
gem install jeweler
</pre>
<p>To create your project run</p>
<pre>
jeweler yournewgemname
</pre>
<p>It will create a new git repository called yournewgemname.  You are basically ready to go at this point.  You can add your source code files, test your gem, etc at this point.</p>
<h3>Publishing</h3>
<p>To publish your gem first you have to create a gem verison number</p>
<pre>
rake version:write
</pre>
<p>And then to publish your gem to rubygems.org</p>
<pre>
rake gemcutter:release
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.sparqcode.com/2011/04/13/publishing-a-gem-with-jewler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s Your Mobile Presence?</title>
		<link>http://blog.sparqcode.com/2011/04/06/whats-your-mobile-presence/</link>
		<comments>http://blog.sparqcode.com/2011/04/06/whats-your-mobile-presence/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 20:28:10 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://blog.sparqcode.com/?p=660</guid>
		<description><![CDATA[Soon there is going to be more cellular phone subscriptions in the United States than there are people. Does this scare you? Unless you&#8217;ve figured out how to present yourself online, it should. What do I mean by mobile presence? Well it&#8217;s not hard to imagine a future where all of your customers access your &#8230; <a href="http://blog.sparqcode.com/2011/04/06/whats-your-mobile-presence/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
Soon there is going to be more cellular phone subscriptions in the United States than there are people.  Does this scare you? Unless you&#8217;ve figured out how to present yourself online, it should.   What do I mean by mobile presence?  Well it&#8217;s not hard to imagine a future where all of your customers access your website and information about you/your company entirely through the customer&#8217;s mobile phone.  I think a lot of people out there still do not have a handle on how to deal with this shift in access patterns.  I&#8217;ll share my thoughts on different ways you can deal with your mobile presence.
</p>
<h3>Don&#8217;t</h3>
<p>
A lot of the modern smartphones (iPhone and Android specifically) have very good browsers in them.  It&#8217;s quite likely that your web page already renders just fine and your customers will be able to access the information they need.  There&#8217;s a slight problem with this though, smart phones work on a different aspect ratio than your computer does so a lot of pages don&#8217;t look right, require a lot of scrolling, and generally make it harder for the user to navigate effectively.
</p>
<h3>Mobile Friendly Pages/JQuery Mobile</h3>
<p>
Another option is to make a mobile centric version of the page.  Your mobile site is designed with the constraints of the mobile device in mind.  The problem with this approach is that not all mobile phone browsers are created equal.  As I mentioned both iPhone and Android have very capable browsers, but the experience you get on older blackberries and Windows Mobile can be downright painful.
</p>
<p>The fine folks over at JQuery have been working to solve this problem with <a href="http://jquerymobile.com/">jquery mobile</a>.  Basically it&#8217;s a javascript framework that will adjust your UI to match the capabilities of the phone viewing it and do its best to make your page look like a native phone app. Even though <a href="http://jquerymobile.com/">jquery mobile</a> is still in the alpha stage, it&#8217;s still remarkably mature.  It&#8217;s really easy to get a really nice looking app up and running quickly, I highly recommend checking it out if you&#8217;re building a mobile web site.
</p>
<h3>Facebook</h3>
<p>
If you don&#8217;t already, you should have a <a href="http://www.facebook.com/">Facebook</a> page.  The nice thing about maintaining an up to date facebook page is that Facebook has already done all the hard work of creating a mobile app and optimizing their site for mobile devices.  If you direct your users to your facebook page, all you need to worry about is making sure your personal or company page is up to date.
</p>
<h3>SPARQ.ME</h3>
<p>
Available to all of our registered users is a feature called SPARQ.ME.  It lets you quickly and easily create a mobile friendly site for yourself or for your business.  You can <a href="http://sparq.me/mike.emery">check out my SPARQ.ME here</a>.  Like Facebook, we do all the work to make sure it looks good on mobile phones, but we let you customize the page with custom widgets so you can tailor the page to who you think will be viewing it.
</p>
<h3>In Conclusion&#8230;</h3>
<p>
Think about your mobile presence.  As mobile phone usage increases in the US, being accessible through a mobile device is going to become more and more important.  It&#8217;s better to think about this kind thing now rather than being blindsided by it in the future.
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sparqcode.com/2011/04/06/whats-your-mobile-presence/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accessing Yahoo Contacts Using the Ruby OAuth Gem</title>
		<link>http://blog.sparqcode.com/2011/03/30/accessing-yahoo-contacts-using-oauth-gem/</link>
		<comments>http://blog.sparqcode.com/2011/03/30/accessing-yahoo-contacts-using-oauth-gem/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 02:54:33 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Technical Development]]></category>
		<category><![CDATA[ruby oauth yahoo]]></category>

		<guid isPermaLink="false">http://blog.sparqcode.com/?p=653</guid>
		<description><![CDATA[Recently I implemented a feature for our up and coming referral program that lets you refer people using your Yahoo and Google contacts. As part of this I needed to work with Yahoo&#8217;s own implementation of the OAuth standard. This interaction caused me quite a bit of pain, so I decided to write up a &#8230; <a href="http://blog.sparqcode.com/2011/03/30/accessing-yahoo-contacts-using-oauth-gem/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently I implemented a feature for our up and coming referral program that lets you refer people using your Yahoo and Google contacts.  As part of this I needed to work with Yahoo&#8217;s own implementation of the OAuth standard.  This interaction caused me quite a bit of pain, so I decided to write up a little tutorial to help out other struggling with this problem.</p>
<p>In order to access a Yahoo contact your first order of business will be to get an application key and an application secret from https://developer.apps.yahoo.com/projects.</p>
<p>Yahoo verifies the callback url you provide to be from the same domain as what you registered for (you can&#8217;t register with localhost).  Because of this you will need to override your hosts file to match your domain, in my case I had an entry like</p>
<pre>
127.0.0.1 www.sparqcode.com
</pre>
<p>With all that in place, you will need two oauth consumers: one to authenticate and one to actually consume the data from Yahoo.</p>
<pre name="code" class="ruby">
  def yahoo_oauth_consumer
    OAuth::Consumer.new(YahooOauthCredentials::KEY,
        YahooOauthCredentials::SECRET, {
          :site                 => 'https://api.login.yahoo.com',
          :scheme               => :query_string,
          :request_token_path   => '/oauth/v2/get_request_token',
          :access_token_path    => '/oauth/v2/get_token',
          :authorize_path       => '/oauth/v2/request_auth'
        })
  end

  def yahoo_calendar_consumer
    OAuth::Consumer.new(YahooOauthCredentials::KEY,
        YahooOauthCredentials::SECRET,
        {
          :site => 'http://social.yahooapis.com'
        })
  end
</pre>
<p>In your initial view, you need to redirect to Yahoo&#8217;s authorization URL.</p>
<pre name="code" class="ruby">
    request_token = yahoo_oauth_consumer.get_request_token(:oauth_callback => yahoo_callback_contact_import_url)
    redirect_to request_token.authorize_url
</pre>
<p>Once your user has granted your application access to her contact list, you need to actually parse the response.</p>
<pre name="code" class="ruby">
  def yahoo_callback
    if(params[:oauth_token] &#038;&#038; params[:oauth_verifier])
      request_token = OAuth::RequestToken.new(yahoo_oauth_consumer, session['request_token'], session['request_secret'])

      access_token = request_token.get_access_token(:oauth_verifier => params[:oauth_verifier])

      access_token.consumer = yahoo_calendar_consumer
      yahoo_guid = access_token.params[:xoauth_yahoo_guid]

      response = access_token.get("/v1/user/#{yahoo_guid}/contacts?format=json&#038;count=max")
      json = ActiveSupport::JSON.decode(response.body)

      @name_email_map = parse_yahoo_contacts_response(json)
    end
  end

  def parse_yahoo_contacts_response(json)
    name_email_map = {}

    return name_email_map if json['contacts']['contact'].nil?

    json['contacts']['contact'].each do |contact| 

      name = nil
      email = nil

      contact['fields'].each do |field|
        field['type']

        if field['type'] == 'name'
          name = "#{field['value']['givenName']} #{field['value']['familyName']}"
        end 

        if field['type'] == 'email'
          email = field['value']
        end
      end

      if(email)
        name ||= email
        name_email_map[name] = email
      end
    end

    name_email_map
  end
</pre>
<p>Any questions please leave a comment and I&#8217;ll do my best to answer.</p>
<p>Full code for handling storing session variables and redirecting</p>
<pre  name="code" class="ruby">

  def yahoo_import
    request_token = yahoo_oauth_consumer.get_request_token(:oauth_callback => yahoo_callback_contact_import_url)
    session['request_token'] = request_token.token
    session['request_secret'] = request_token.secret
    redirect_to request_token.authorize_url
  end

  def yahoo_callback
    if(params[:oauth_token] &#038;&#038; params[:oauth_verifier])
      request_token = OAuth::RequestToken.new(yahoo_oauth_consumer, session['request_token'], session['request_secret'])

      access_token = request_token.get_access_token(:oauth_verifier => params[:oauth_verifier])

      yahoo_guid = access_token.params[:xoauth_yahoo_guid]

      access_token.consumer = yahoo_calendar_consumer
      yahoo_guid = access_token.params[:xoauth_yahoo_guid]

      response = access_token.get("/v1/user/#{yahoo_guid}/contacts?format=json&#038;count=max")
      json = ActiveSupport::JSON.decode(response.body)

      @name_email_map = parse_yahoo_contacts_response(json)

    end
  end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.sparqcode.com/2011/03/30/accessing-yahoo-contacts-using-oauth-gem/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sending Attachments using ActionMailer 2.3</title>
		<link>http://blog.sparqcode.com/2011/03/23/sending-attachments-using-activerecord-2-3/</link>
		<comments>http://blog.sparqcode.com/2011/03/23/sending-attachments-using-activerecord-2-3/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 03:45:23 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Technical Development]]></category>
		<category><![CDATA[Ruby Rails ActionMailer]]></category>

		<guid isPermaLink="false">http://blog.sparqcode.com/?p=646</guid>
		<description><![CDATA[This took me about an hour to get working properly so I figured I would share this with everyone. The big thing to keep in mind is that multipart emails don&#8217;t automatically pick up which template they need to render, so you need to specify render_message. def email_file(email, zipfile) recipients email content_type "multipart/mixed" subject "Yo" &#8230; <a href="http://blog.sparqcode.com/2011/03/23/sending-attachments-using-activerecord-2-3/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This took me about an hour to get working properly so I figured I would share this with everyone.  The big thing to keep in mind is that multipart emails don&#8217;t automatically pick up which template they need to render, so you need to specify render_message.</p>
<pre name="code" class="ruby">
	def email_file(email, zipfile)
		recipients email
		content_type "multipart/mixed"
		subject "Yo"
		from "noreply@sparqcode.com"

		part 'text/html' do |p|
			p.body = render_message("the_template_you_want_to_render", {})
		end

		attachment "application/zip" do |a|
			a.body = zipfile.read
			a.filename = "somefile.zip"
		end
	end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.sparqcode.com/2011/03/23/sending-attachments-using-activerecord-2-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Posting Facebook Wall Messages with the OAuth2 gem</title>
		<link>http://blog.sparqcode.com/2011/03/16/posting-facebook-wall-messages-with-the-oauth2-gem/</link>
		<comments>http://blog.sparqcode.com/2011/03/16/posting-facebook-wall-messages-with-the-oauth2-gem/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 17:18:43 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Technical Development]]></category>
		<category><![CDATA[OAuth Facebook Ruby Howto]]></category>

		<guid isPermaLink="false">http://blog.sparqcode.com/?p=639</guid>
		<description><![CDATA[I found facebook&#8217;s documentation confusing, almost hair-rippingly so, when it came to posting a message to somebody&#8217;s wall through facebook.  Facebook uses a method called OAuth2 to do authentication.  If you&#8217;re not familiar with OAuth2, from a high level it&#8217;s a security scheme that lets you do things on behalf of somebody else without ever &#8230; <a href="http://blog.sparqcode.com/2011/03/16/posting-facebook-wall-messages-with-the-oauth2-gem/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I found facebook&#8217;s documentation confusing, almost hair-rippingly so, when it came to posting a message to somebody&#8217;s wall through facebook.  Facebook uses a method called OAuth2 to do authentication.  If you&#8217;re not familiar with OAuth2, from a high level it&#8217;s a security scheme that lets you do things on behalf of somebody else without ever having to obtain that other person&#8217;s username or password.</p>
<p>To prepare you will need a few things.</p>
<p>The OAuth2 gem</p>
<pre>gem install oauth2</pre>
<p>You will also need to setup a Facebook Application.</p>
<p>And finally you should probably put your application credentials somewhere easily accessible.  Using some tricks with const_missing I created a FacebookOauthCredentials file that will have relevant information regardless of what environment I&#8217;m in.</p>
<pre name="code" class="ruby">class FacebookOauthCredentials

  production = {
    :APP_ID =&gt; '',
    :API_KEY =&gt; '',
    :APP_SECRET =&gt; ''
  }

  test = {
    :APP_ID =&gt; '',
    :API_KEY =&gt; '',
    :APP_SECRET =&gt; ''
  }

  development = {
    :APP_ID =&gt; '',
    :API_KEY =&gt; '',
    :APP_SECRET =&gt; ''
  }

  OAUTH_CREDENTIALS = {
    "development" =&gt; development,
    "test" =&gt; test,
    "production" =&gt; production
  }

  def self.const_missing(key)
    value = OAUTH_CREDENTIALS[Rails.env][key]

    unless value
      super
    end
    value
  end
end</pre>
<p>This lets me do something like FacebookOauthCredentials::APP_ID and it will be relevant no matter what environment I&#8217;m in.</p>
<p>Now we need a way to use those credentials to authenticate with Facebook.  I added this in application_controller.rb:</p>
<pre  name="code" class="ruby">def facebook_client
    OAuth2::Client.new(FacebookOauthCredentials::APP_ID, FacebookOauthCredentials::APP_SECRET, :site =&gt; 'https://graph.facebook.com')
 end</pre>
<p>Now we need to actually talk to facebook, this action is linked to directly from one of the pages in the app.:</p>
<pre name="code" class="ruby">def facebook_session_create(poster)
    redirect_to facebook_client.web_server.authorize_url(:scope =&gt; 'publish_stream', :redirect_uri =&gt; 'http://www.yourdomain.com/facebook_callback')
end</pre>
<p>In this example it will ask the user for permission to publish to the user&#8217;s stream.  Regardless of whether or not the user accepts the user is redirected to the :redirect_uri parameter.</p>
<p>In the code below, when I call get_access_token the redirect_uri paramter is not actually used as a redirect, it is used to validate against the redirect_uri parameter that was passed in the facebook_session_create step.</p>
<pre name="code" class="ruby">  def facebook_callback
    if(params[:code])
      access_token = facebook_client.web_server.get_access_token(params[:code], :redirect_uri =&gt; 'http://www.yourdomain.com/facebook_callback'

      access_token.post('/me/feed', :message =&gt; "hi, I'm posting a message from ruby"
    end

    redirect_to "http://www.facebook.com"
  end</pre>
<p>And that&#8217;s all there is to it.  Happy posting!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sparqcode.com/2011/03/16/posting-facebook-wall-messages-with-the-oauth2-gem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedding a Url in a QR Code</title>
		<link>http://blog.sparqcode.com/2011/03/09/embedding-a-url-in-a-qr-code/</link>
		<comments>http://blog.sparqcode.com/2011/03/09/embedding-a-url-in-a-qr-code/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 08:30:02 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[howto bestpractices]]></category>

		<guid isPermaLink="false">http://blog.sparqcode.com/?p=628</guid>
		<description><![CDATA[This may seem like a silly topic to a lot of people.  Using Google&#8217;s charts API is very easy to generate a QR Code that points to your website.  Like so much in life, the devil is in the details.  If you&#8217;re CNN and you&#8217;re just embedding a URL in your QR code you&#8217;re going &#8230; <a href="http://blog.sparqcode.com/2011/03/09/embedding-a-url-in-a-qr-code/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This may seem like a silly topic to a lot of people.  Using Google&#8217;s charts API is very easy to generate a QR Code that points to your website.  Like so much in life, the devil is in the details.  If you&#8217;re CNN and you&#8217;re just embedding a URL in your QR code you&#8217;re going to end up with something like this:</p>
<p><img class="aligncenter" title="Cnn Uncompressed" src="http://www.sparqcode.com/qrgen?qt=raw&amp;data=http%3A%2F%2Fmoney.cnn.com%2F2011%2F03%2F08%2Ftechnology%2Fgoogle_algorithm_change%2Findex.htm&amp;col=000000&amp;width=200" alt="" width="200" height="228" /></p>
<p>The biggest problem with this method is that it will be very hard to scan unless the person scanning has a high resolution camera with a macro lens.  The reason this QR code is hard to scan is because it there&#8217;s a lot of data.  Simply speaking, the larger the data payload in a QR Code smaller the dots are, and the harder it is for phones to scan.  How do you combat this?  Url shortening.</p>
<p>The gist of URL shortening is to take some url like http://www.google.com and turn it into something smaller like http://ab.cd/1234.  The idea being is that any arbitrarily long url will turn into something very small and QR Code friendly.  Here is that same CNN url shortened:</p>
<p><img class="aligncenter" title="CNN Shortened" src="http://www.sparqcode.com/qrgen?track=1&amp;qt=url&amp;data=http%3A%2F%2Fmoney.cnn.com%2F2011%2F03%2F08%2Ftechnology%2Fgoogle_algorithm_change%2Findex.htm&amp;col=000000&amp;width=200" alt="" width="200" height="243" /></p>
<p>There are two ways you can shorten a URL: Case sensitive and Case insensitive.  Case sensitive shortening converts your url into a series of characters consisting of a-z, A-Z, and 0-9.  Case insensitive just uses a-z and 0-9.</p>
<p>The benefit of case sensitive is that you get more URLS per character, for example bit.ly will basically be able to store every URL in the universe with six characters.  The downside is that if you ever have to type your url in on a phone manually the user will have trouble.  Case insensitive on the other hand doesn&#8217;t practically require any more characters, but it means if the user ever needs to type in the url they will have a much easier time.  I&#8217;ll cover the actual algorithms to compress the URL in a future post.</p>
<p>When you encode URLs in a QR code you should definitely shorten it, but the method you use should be determined by how you expect people to use it.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sparqcode.com/2011/03/09/embedding-a-url-in-a-qr-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom user-agent strings with Cucumber and Capybara</title>
		<link>http://blog.sparqcode.com/2011/03/07/custom-user-agent-strings-with-cucumber-and-capybara/</link>
		<comments>http://blog.sparqcode.com/2011/03/07/custom-user-agent-strings-with-cucumber-and-capybara/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 09:35:03 +0000</pubDate>
		<dc:creator>yowhan</dc:creator>
				<category><![CDATA[Technical Development]]></category>
		<category><![CDATA[capybara]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[user-agent]]></category>

		<guid isPermaLink="false">http://www.sparqcode.com/msky-blog/?p=389</guid>
		<description><![CDATA[This problem has been bugging me for quite a while and the usual googling did not get me a solution that worked. After some experimentation and a bit more research, I found the answer in the comments section of a blog post here: http://aflatter.de/2010/06/testing-headers-and-ssl-with-cucumber-and-capybara/ So let me share the solution I ended up with. First, &#8230; <a href="http://blog.sparqcode.com/2011/03/07/custom-user-agent-strings-with-cucumber-and-capybara/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.sparqcode.com/wp-content/uploads/2011/03/capybara_cucumber_2.png" alt="" title="capybara_cucumber_2" width="90" height="150" class="alignright size-full wp-image-630" />This problem has been bugging me for quite a while and the usual googling did not get me a solution that worked.</p>
<p>After some experimentation and a bit more research, I found the answer in the comments section of a blog post here: <a href="http://aflatter.de/2010/06/testing-headers-and-ssl-with-cucumber-and-capybara/" target="_blank">http://aflatter.de/2010/06/testing-headers-and-ssl-with-cucumber-and-capybara/</a></p>
<p>So let me share the solution I ended up with. First, we have to hack the Capybara Driver and allow the headers to be overridden. This part I just copied verbatim from the blog post. You can put this file anywhere in features/support.</p>
<pre name="code" class="ruby:nocontrols">
module RackTestMixin

  def self.included(mod)
    mod.class_eval do
      # This is where we save additional entries.
      def hacked_env
        @hacked_env ||= {}
      end

      # Alias the original method for further use.
      alias_method :original_env, :env

      # Override the method to merge additional headers.
      # Plus this implicitly makes it public.
      def env
        original_env.merge(hacked_env)
      end
    end
  end

end

Capybara::Driver::RackTest.send :include, RackTestMixin

module HeadersHackHelper

  def add_headers(headers)
    page.driver.hacked_env.merge!(headers)
  end

end

World(HeadersHackHelper)
</pre>
<p>Now, we need to add a new step definition. This is where we diverge from the blog post.</p>
<pre name="code" class="ruby:nocontrols">
Given /^my user agent is "(.+)"$/ do |agent|
  add_headers({'HTTP_USER_AGENT'=> agent})
end
</pre>
<p>So that&#8217;s it for testing user agent strings. Now, I was trying to figure this out because I wanted cucumber to run tests for different mobile phone types. So it made sense for me to throw in another step definition that would make this easier.</p>
<pre name="code" class="ruby:nocontrols">
Given /^I have an? (.+)$/ do |phone_name|
  add_headers({‘HTTP_USER_AGENT’=> SAMPLE_AGENT_STRING[phone_name]})
end
</pre>
<p>SAMPLE_AGENT_STRING can be defined as a constant hash like below:</p>
<pre name="code" class="ruby:nocontrols">
#Sample user agent strings
SAMPLE_AGENT_STRING={
  “iPhone” => “Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7″,
  “Android” => “HTC_Eris Mozilla/5.0 (Linux; U; Android 4.0; en-ca; Build/GINGERBREAD) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1″,
  “Windows Mobile” => “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; HTC_Touch_Diamond2_T5353; Windows Phone 6.5)”,
  “Windows Phone 7″ => “Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0) Asus;Galaxy6″,
  “Blackberry” => “BlackBerry9700/5.0.0.351 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/123″,
  “Palm Pre” => “Mozilla/5.0 (webOS/1.0; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pre/1.0″,
  “Nokia N97″ => “Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/20.0.019; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.18124″
}
</pre>
<p>Now I can write scenarios like:</p>
<pre name="code" class="gherkin:nocontrols">
Given I have an iPhone
And I am viewing “/detect-phone”
Then I should see “You are using an iPhone!”
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.sparqcode.com/2011/03/07/custom-user-agent-strings-with-cucumber-and-capybara/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to achieve PCI compliance with Braintree in one day</title>
		<link>http://blog.sparqcode.com/2011/03/04/how-to-achieve-pci-compliance-with-braintree-in-one-day/</link>
		<comments>http://blog.sparqcode.com/2011/03/04/how-to-achieve-pci-compliance-with-braintree-in-one-day/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 15:30:18 +0000</pubDate>
		<dc:creator>simon</dc:creator>
				<category><![CDATA[Technical Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Braintree]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[payments]]></category>
		<category><![CDATA[PCI]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.sparqcode.com/msky-blog/?p=397</guid>
		<description><![CDATA[Several months ago we needed to implement a billing system. Conceptually, recurring payments are simple &#8211; ask for a customer&#8217;s payment card, save it, and then process it at later dates through a payment gateway. Implementing it, on the other hand, is tricky, all because of one thorny issue: security. Hosting our site on the &#8230; <a href="http://blog.sparqcode.com/2011/03/04/how-to-achieve-pci-compliance-with-braintree-in-one-day/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.braintreepaymentsolutions.com" target="_blank"><img src="http://blog.sparqcode.com/wp-content/uploads/2011/03/441840_braintreelogo.gif" alt="" title="Braintree logo" width="292" height="100" class="alignright size-full wp-image-499" /></a><br />
Several months ago we needed to implement a billing system. Conceptually, recurring payments are simple &#8211; ask for a customer&#8217;s payment card, save it, and then process it at later dates through a payment gateway.</p>
<p>Implementing it, on the other hand, is tricky, all because of one thorny issue: security.  Hosting our site on the EC2 cloud didn&#8217;t make PCI compliance matters easier either.</p>
<p>That&#8217;s when we found <a href="http://www.braintreepaymentsolutions.com" target="_blank">Braintree</a>. </p>
<p>Braintree&#8217;s a relatively recent newcomer to the payment game. They&#8217;re young, and they&#8217;re growing fast. Since 2007, they&#8217;ve been picked up by hotshot Web 2.0 companies like 37signals, Github, Disqus.</p>
<p>Now I can&#8217;t say it enough: I. Heart. Braintree.</p>
<p>Their secret sauce? Excellent customer service, a clean API, and a little thing they like to call <em>Transparent Redirect.</em></p>
<p>Here&#8217;s how it works.</p>
<p>A standard transaction model usually goes something like this,</p>
<ol>
<li>User enters credit card information</li>
<li>Credit card information is sent to a secure server hosted by you</li>
<li>Card is processed through the payment gateways&#8217;s API.</li>
</ol>
<p>All the extraneous work is done in securing your own server. To bypass that, the other option is to redirect &#8211; albiet jarringly &#8211; to a 3rd-party site. </p>
<p>But here&#8217;s the cleverness of Braintree&#8217;s transparent redirect.</p>
<ol>
<li>User enters credit card information</li>
<li>Credit card information is <strong>sent directly to Braintree&#8217;s server</strong>, bypassing your servers</li>
<li>Braintree <strong>silently redirects to a callback</strong> you supply</li>
<li> Your callback handles the credit card through <strong>encrypted tokens</strong></li>
</ol>
<p>The best part is that during this whole process users will never know they&#8217;ve left the site. And since you never look at or deal with sensitive information directly, the need to take any extra steps to secure your servers is minimal.</p>
<p>From a code level, here are the steps to process a transaction.</p>
<h3>1. Encrypt transaction details</h3>
<pre name="code" class="ruby:nocontrols">tr_data = Braintree::TransparentRedirect.transaction_data(
                   :redirect_url =&gt; "http://example.com/your_callback",
                   :transaction =&gt; {
                     :type =&gt; "sale",
                     :amount =&gt; "10.00"
                    })</pre>
<h3>2. Construct the form and embed the transaction details</h3>
<pre name="code" class="html:nocontrols">
<form method="POST" action="<%= Braintree::TransparentRedirect.url %>">
<input type="hidden" name="tr_data" value="<%= ERB::Util.html_escape tr_data %>" />
<input type="text" name="transaction[credit_card][number]" />
<input type="text" name="transaction[credit_card][expiration_date]" />
</form>
</pre>
<h3>3. Handle the callback</h3>
<pre name="code" class="ruby:nocontrols">
def your_callback
  result = Braintree::TransparentRedirect.confirm(query_string)
  if result.success?
    puts "Hoorah!"
  else
    puts "Oh FUBAR!!"
  end
end
</pre>
<p>That&#8217;s it. Simple eh?</p>
<p>They have APIs written for Ruby, Java, PHP, Phython, and .NET.</p>
<p>Did I also mention their excellent customer service? Check out how fast they reply!<br />
<a href="http://blog.sparqcode.com/wp-content/uploads/2011/03/Screen-shot-2011-03-03-at-5.02.05-PM.png"><img src="http://blog.sparqcode.com/wp-content/uploads/2011/03/Screen-shot-2011-03-03-at-5.02.05-PM.png" alt="" title="Braintree customer support" width="483" height="563" class="alignleft size-full wp-image-496" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sparqcode.com/2011/03/04/how-to-achieve-pci-compliance-with-braintree-in-one-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SPARQCode Named Washington Technology Industry Association’s Best Seed Stage Company of the Year</title>
		<link>http://blog.sparqcode.com/2011/02/24/sparqcode-named-washington-technology-industry-association%e2%80%99s-best-seed-stage-company-of-the-year/</link>
		<comments>http://blog.sparqcode.com/2011/02/24/sparqcode-named-washington-technology-industry-association%e2%80%99s-best-seed-stage-company-of-the-year/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 08:44:14 +0000</pubDate>
		<dc:creator>Scopes</dc:creator>
				<category><![CDATA[Press]]></category>

		<guid isPermaLink="false">http://www.sparqcode.com/msky-blog/2011/02/24/sparqcode-named-washington-technology-industry-association%e2%80%99s-best-seed-stage-company-of-the-year/</guid>
		<description><![CDATA[SPARQCode Named Washington Technology Industry Association’s Best Seed Stage Company of the Year Company’s QR Code sales lead generation services honored with prestigious award SEATTLE, Washington – February 24, 2011 – SPARQCode announced today that its QR Code sales lead generation services was named the Best Seed Stage Company of the Year, as part of &#8230; <a href="http://blog.sparqcode.com/2011/02/24/sparqcode-named-washington-technology-industry-association%e2%80%99s-best-seed-stage-company-of-the-year/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="text-align:center" align="center"><span style="color:Black"><strong><span style="mso-bidi-font-family: ">SPARQCode Named Washington Technology Industry Association’s Best Seed Stage Company of the Year</span></strong></span></p>
<p class="MsoNormal" style="text-align:center" align="center"><span style="color:Black"><em><span style="mso-bidi-font-family: ">Company’s <strong>QR Code sales lead generation services</strong> honored with prestigious award</span></em></span></p>
<p class="MsoNormal" style="line-height:125%"><span style="color:Black"><strong><span style="mso-bidi-font-family: ">SEATTLE, Washington – February 24, 2011 –</span></strong></span> <span style="color: Black; mso-bidi-font-family: ">SPARQCode announced today that its QR Code sales lead generation services was named the Best Seed Stage Company of the Year, as part of the Washington Technology Industry Association’s 16<sup>th</sup> annual Industry Achievement Awards (IAA). The awards honor those companies, products and individuals in Washington State who exemplify the best in innovation and excellence in their respective categories.</span></p>
<p class="MsoNormal" style="line-height:125%"><span style="color: Black; mso-bidi-font-family: ">“This year, as in year&#8217;s past, the IAA award winners represent the best and brightest of the Washington technology scene,&#8221; said Susan Sigl, CEO of WTIA. &#8220;We take distinct pleasure in honoring companies and individuals that are making an impact here at home, across the nation and even around the world.&#8221;</span></p>
<p class="MsoNormal" style="line-height:125%"><span style="color:Black"><strong><span style="mso-bidi-font-family: ">SPARQCode is one of the largest QR Code makers in the United States and specializes in helping companies generate qualified sales leads from their marketing efforts.<span style="mso-spacerun:yes"> </span> Our goal is to help turn anyone carrying a mobile phone into a potential customer.</span></strong></span><strong> </strong></p>
<p class="MsoNormal" style="line-height: 125%;"><span style="color: #000000;">“We are very honored to receive this award, &#8221; said Jesse Chor, founder and CEO of SPARQCode.  &#8221;This is further proof that Seattle is a great place to create a high-tech mobile startup.”</span></p>
<p class="MsoNormal" style="line-height:125%"><span style="color:Black"><strong>About WTIA</strong></span></p>
<p class="MsoNormal" style="line-height:125%"><span style="color: Black; mso-bidi-font-family: ">The Washington Technology Industry Association, founded in 1984, is one of the largest statewide associations of technology companies, IT departments and individual technology professionals in North America. With more than 1,000 members representing more than 125,000 employees in Washington State, the association is a catalyst for sharing expertise, fostering collaboration, delivering key business services and advancing the value and global impact of technology companies doing business in Washington.</span></p>
<p class="MsoNormal"><strong><span style="mso-bidi-font-size: 12pt; mso-bidi-font-family: Arial; color: black">About SPARQCode</span></strong></p>
<p class="MsoNormal"><span style="mso-bidi-font-size: 12pt; color: black; mso-bidi-font-family: Arial">SPARQCode (</span><span style="color:Black"><span style="font-family: Arial"><a href="http://www.sparqcode.com/"><span style="mso-bidi-font-size: 12pt">www.sparqcode.com</span></a></span></span><span style="mso-bidi-font-size: 12pt; mso-bidi-font-family: Arial; color: black">) is a mobile vertical marketing company focused on turning mobile phone users into customers. SPARQCode’s 2d barcode platform enables mobile phone users to purchase products or services, get updates on a purchase, engage with a business on Facebook or Twitter, and much more. SPARQCode was founded in 2007 and is now one of the largest and highest quality providers in the industry, with many fortune 500 clients. To learn more, visit us at</span><span style="mso-bidi-font-size: 12pt; mso-bidi-font-family: Arial; color: black"> </span><span style="color:Black"><span style="font-family: Arial"><a href="http://www.sparqcode.com/"><span style="mso-bidi-font-size: 12pt">www.sparqcode.com</span></a></span></span><span style="mso-bidi-font-size: 12pt; mso-bidi-font-family: Arial; color: black">.</span></p>
<p><span style="color:Black"><strong><img src="https://s3.amazonaws.com/msky-blog/WTIA/button_winner.jpg" alt="" /></strong></span></p>
<p><span style="color:Black"><strong>Media Links:</strong><br />
</span><a href="http://investing.businessweek.com/research/sectorandindustry/news/article.asp?docKey=600-201102250000MRKTWIREUSPR____0725674-1&amp;params=timestamp||02/25/2011%2012:00%20AM%20ET||headline||WTIA%20Announces%20Winners%20of%20the%202011%20Industry%20Achievement%20Awards%20at%20Gala%20Event||docSource||Market%20Wire||provider||ACQUIREMEDIA">Bloomberg Businessweek</a><br />
<a href="http://www.msnbc.msn.com/id/41772516/ns/business-press_releases">MSNBC &#8211; WTIA Announces Winners of the 2011 Industry Achievement Awards at Gala Event</a><br />
<a href="http://finance.yahoo.com/news/WTIA-Announces-Winners-of-the-iw-1968834326.html?x=0">Yahoo Finance &#8211; Marketwire</a><br />
<span style="color:Black"><a href="http://www.washingtontechnology.org/IAA/" target="_blank">WTIA – 16th Annual Industry Achievement Awards</a><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sparqcode.com/2011/02/24/sparqcode-named-washington-technology-industry-association%e2%80%99s-best-seed-stage-company-of-the-year/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

