<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>tpitale</title>
  <link href="http://tpitale.com/feed.xml" rel="self" />
  <link href="http://tpitale.com/" />
  <id>http://tpitale.com/</id>
  <updated>2013-09-06T07:20:07-07:00</updated>
  <author>
    <name>Tony Pitale</name>
    <email>tpitale@gmail.com</email>
  </author>

  
    <entry>
      <id>http://tpitale.com/prismjs-with-ruby-in-github-pages</id>
      <title>Prism.js with Ruby in Github Pages</title>
      <link href="http://tpitale.com/prismjs-with-ruby-in-github-pages.html" />
      <updated>2013-08-06T13:58:11-07:00</updated>
      <content type="html">
        &lt;p&gt;After quite a long time, and quite a few blog posts using gists for embedding code samples with highlighting and the rest, I&amp;#8217;m giving something else a try.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve added prism.js and a ruby language extension by &lt;a href='https://github.com/samflores'&gt;Sam Flores&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s the quick and dirty way to add prism.js to your own blog (or in my case, Github Pages).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add &lt;a href='http://prismjs.com/download.html'&gt;prism.js and prism.css&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;Add &lt;a href='https://github.com/samflores/prism-langs/blob/master/prism.ruby.js'&gt;prism.ruby.js&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;Link to both in your layout&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And then just write some code inside &amp;#60;pre&amp;#62;&amp;#60;code class=&amp;#8221;language-ruby&amp;#8221;&amp;#62; tags!&lt;/p&gt;
&lt;pre&gt;&lt;code class='language-ruby'&gt;class Cow
  def says
    puts 'moo'
  end
end

Cow.new.says #=&gt; moo&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Simple as that! I&amp;#8217;m gonna give it a try for a little while. Let me know how you think it looks, and how the code reads for you. Thanks!&lt;/p&gt;
      </content>
    </entry>
  
    <entry>
      <id>http://tpitale.com/how-ive-been-running-email-standups</id>
      <title>How I've Been Running Email Standups</title>
      <link href="http://tpitale.com/how-ive-been-running-email-standups.html" />
      <updated>2013-07-31T10:10:40-07:00</updated>
      <content type="html">
        &lt;p&gt;
  Lots of people do standups, but most frequently they're done synchronously;
  either in-person or over video chat of some variety. After
  &lt;a href=&quot;http://wellbredgrapefruit.com/blog/2013/05/28/daily-meetings-are-great-but-you-should-never-have-them/&quot;&gt;
    reading this post from the development team at Treehouse
  &lt;/a&gt;
  on why it might be best to do them asynchronously I decided to try out their
  ideas with my small team.
&lt;/p&gt;

&lt;p&gt;
  As suggested in the blog post, we set up Google Groups. In order to send
  the email from my own account to kick things off, I had to tweak some
  settings. First I had to enable sending as the group email from my own
  account. Then, in order to actually receive my own emails, I had to tweak
  a setting in Google Groups. See the instructions below.
&lt;/p&gt;

&lt;p&gt;
  And of course, since I have stuff to do every day and I'm a &quot;good&quot; developer :-),
  I automated the sending of the email with a little cron and a ruby script.
&lt;/p&gt;

&lt;p&gt;
  All in all, this as been a huge success for us. Our favorite benefits:
  &lt;ul&gt;
    &lt;li&gt;reduce this mundane but useful task to something I can do when it's convenient to take the time&lt;/li&gt;
    &lt;li&gt;do not pull me out of my own work for a standup&lt;/li&gt;
    &lt;li&gt;do not start other discussions not related to standup&lt;/li&gt;
    &lt;li&gt;link to PRs, commits, and code in Github directly from the email&lt;/li&gt;
    &lt;li&gt;it's all logged and searchable by the project/product managers&lt;/li&gt;
  &lt;/ul&gt;
&lt;/p&gt;

&lt;p&gt;
  Lots of win, there. We were happy to find even more reasons to stick with
  this approach than are given in the initial Treehouse post.
&lt;/p&gt;

&lt;p&gt;
  The only downside we could come up with is that we're taking away a time
  when we get to socialize. But this barely counts. First, we don't want to use
  the standup time for socializing and building camaraderie. And second, if
  standup is the only time your team is socializing, you'll want to make an
  attempt to correct that.
&lt;/p&gt;

&lt;h3&gt;Make it Happen&lt;/h3&gt;
&lt;p&gt;
  At a high level, getting it set up involves:

  &lt;ul&gt;
    &lt;li&gt;Create a new google group.&lt;/li&gt;
    &lt;li&gt;Go to settings in your gmail to allow you to send mail as the email for the google group.&lt;/li&gt;
    &lt;li&gt;Confirm that you have access to that email by clicking the link.&lt;/li&gt;
    &lt;li&gt;Put the mail script somewhere in your path.&lt;/li&gt;
    &lt;li&gt;Set cron to trigger it when you would like to have your standup.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/p&gt;

&lt;h3&gt;Google Group Settings&lt;/h3&gt;
&lt;p&gt;
  Inside groups &gt; settings
  &lt;ul&gt;
    &lt;li&gt;Information &gt; general information: Allow posting by email.&lt;/li&gt;
    &lt;li&gt;Information &gt; Content control: Archive messages to the group.&lt;/li&gt;
    &lt;li&gt;Information &gt; Web view customization: Allow users to highlight code.&lt;/li&gt;
    &lt;li&gt;Permissions &gt; Posting permissions: Post As The Group should include Owners and Managers&lt;/li&gt;
  &lt;/ul&gt;
&lt;/p&gt;

&lt;h3&gt;The Ruby Script&lt;/h3&gt;
&lt;p&gt;
  &lt;script src=&quot;https://gist.github.com/tpitale/6124084.js&quot;&gt;&lt;/script&gt;
  &lt;a href=&quot;https://gist.github.com/tpitale/6124084&quot;&gt;standup_email ruby script gist&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
  Personally, I put this in my home directory .bin, and call it with the absolute path.
  Note: If you have two-factor authentication turned on for your Gmail, you'll need
  to generate a token to use.
&lt;/p&gt;

&lt;p&gt;
  &lt;h3&gt;Cron&lt;/h3&gt;
  &lt;pre&gt;&lt;code&gt;
    0 10 * * 1,2,3,4,5 /bin/zsh -ic '/Users/&lt;username&gt;/.bin/standup_email' &gt; /tmp/standup.log 2&gt;&amp;1
  &lt;/code&gt;&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;
  I've been running standups this way for 3+ months, and everyone on the team loves it.
  Surprisingly, everyone still knows what other people on the team are working on.
  Perhaps even more so, now!
&lt;/p&gt;

&lt;p&gt;
  I can't vouch for how this will scale to a team of greater than 5 people, so
  YMMV. I do expect there is an upper limit to how well this will work on large
  teams. That being said, it's probably the same constraint on time that
  holding a large synchronous standup would have anyway.
&lt;/p&gt;

&lt;p&gt;
  So please, give this a try, and see how it works for your team.
  &lt;a href=&quot;http://twitter.com/tpitale&quot;&gt;Tweet at me&lt;/a&gt; with your results, I
  would love to know how it goes for you!
&lt;/p&gt;

&lt;h3&gt;P.S.,&lt;/h3&gt;
&lt;p&gt;
  If you'd rather pay for this sort of functionality, and not mess with Google groups, you should
  check out &lt;a href=&quot;https://idonethis.com/&quot;&gt;iDoneThis&lt;/a&gt;.
&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <id>http://tpitale.com/developer-fear</id>
      <title>Developer Fear</title>
      <link href="http://tpitale.com/developer-fear.html" />
      <updated>2013-07-25T16:05:37-07:00</updated>
      <content type="html">
        &lt;p&gt;
  I loved Adam's post, &lt;a href=&quot;http://therealadam.com/2013/07/24/i-dont-have-time-to-not-teach/&quot;&gt;
  I don't have time to not teach&lt;/a&gt;. It's the perfect length. It's straight to
  the point. And, I've had a very similar experience.
&lt;/p&gt;
&lt;h3&gt;I Don't Have Time to be Afraid to Teach&lt;/h3&gt;
&lt;p&gt;
  Inspired by this, I wanted to share a thought, or sentiment, that I've had over the years:
  don't be afraid. Don't be afraid to teach, to share, or to guide. Someone, anyone.
&lt;/p&gt;
&lt;p&gt;
  One of a developer's greatest fears is to be seen as ignorant. But, for a long time,
  I was very afraid to share something I had learned, thinking that &lt;i&gt;surely&lt;/i&gt;
  everyone else knew about it, and I would be found out for my ignorance.
&lt;/p&gt;
&lt;p&gt;
  As it turns out, there is always someone learning. Always someone who knows less
  than you do. So teach, share, and guide others. Do it through writing, speaking,
  or best of all: pairing with those nearest you.
&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <id>http://tpitale.com/sharing-photos-with-lightroom-publish-service-and-photodrop</id>
      <title>Sharing Photos with Lightroom Publish Service and PhotoDrop</title>
      <link href="http://tpitale.com/sharing-photos-with-lightroom-publish-service-and-photodrop.html" />
      <updated>2013-06-23T11:37:48-07:00</updated>
      <content type="html">
        &lt;p&gt;
  In this screencast I'm going to show how I use Lightroom's Publish Service to share my photos with &lt;a href=&quot;http://photodrop.in&quot;&gt;PhotoDrop&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
  &lt;!-- &lt;iframe src=&quot;http://player.vimeo.com/video/68958247&quot; width=&quot;100%&quot; height=&quot;450px&quot; frameborder=&quot;0&quot; webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt; --&gt;
  I would have normally embedded the screencast here, but Vimeo's embed has garbled the audio beyond recognition. &lt;a href=&quot;https://vimeo.com/68958247&quot;&gt;So, here's a link to it!&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
  Check out the PhotoDrop shared &lt;a href=&quot;http://photodrop.in/tpitale/favorites&quot;&gt;Favorites folder&lt;/a&gt; I just made.
&lt;/p&gt;

&lt;p&gt;
  Create as many more published smart folders in Lightroom and they'll all be available on PhotoDrop in no time!
&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <id>http://tpitale.com/activemodel-serializers-with-datamapper</id>
      <title>ActiveModel::Serializers with DataMapper</title>
      <link href="http://tpitale.com/activemodel-serializers-with-datamapper.html" />
      <updated>2013-03-10T12:25:19-07:00</updated>
      <content type="html">
        &lt;p&gt;
  Now that &lt;a href=&quot;http://twitter.com/steveklabnik&quot;&gt;Steve Klabnik&lt;/a&gt; has released ActiveModel::Serializers version 0.7.0, and &lt;a href=&quot;http://twitter.com/rbates&quot;&gt;Ryan Bates&lt;/a&gt; has produced a fantastic Railscast on its usage (&lt;a href=&quot;http://railscasts.com/episodes/409-active-model-serializers&quot;&gt;episode 409&lt;/a&gt;), I'd like to share how I'm using &lt;a href=&quot;https://github.com/rails-api/active_model_serializers&quot;&gt;ActiveModel::Serializers&lt;/a&gt; with DataMapper to build an API for Ember.js with ember-data.
&lt;/p&gt;

&lt;!-- I'll split the article into two parts, starting with getting ActiveModel::Serializers working seamlessly with DataMapper. --&gt;

&lt;p&gt;
  I love ActiveModel::Serializers and I love DataMapper. With a little work, they are a match made in heaven! Thankfully, the integration of the two is actually very easy, once you get down into it.
&lt;/p&gt;

&lt;p&gt;
  The biggest change was a &lt;a href=&quot;https://github.com/rails-api/active_model_serializers/commit/dcd412132249367c971abd545398e8184e88223c&quot;&gt;commit&lt;/a&gt; I added to ActiveModel::Serializers to make eager loading work properly in DataMapper. Steve has already released this as a gem, so be sure to use a version &gt;= 0.7.0.
&lt;/p&gt;

&lt;p&gt;
  Otherwise we just include the right support modules. I've chose to do this in an initializer in Rails called simply 'serializer.rb'.
&lt;/p&gt;

&lt;p&gt;
  &lt;a href=&quot;https://gist.github.com/tpitale/5130038&quot; class=&quot;gist-link&quot;&gt;Serializer Gist&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
  Now you should be able to create Serializers to your heart's content and everything from DataMapper should work just like we want it. Thank you Steve and Ryan!
&lt;/p&gt;

&lt;p&gt;
  I'll followup with a blog on how I'm using ActiveModel::Serizliers to build APIs to work with well with ember-data and Ember.js.
&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <id>http://tpitale.com/receive-gmail-email-messages-in-rails</id>
      <title>Recieve Gmail Email Messages in Rails</title>
      <link href="http://tpitale.com/receive-gmail-email-messages-in-rails.html" />
      <updated>2013-02-04T17:40:00-08:00</updated>
      <content type="html">
        &lt;p&gt;I want to announce the release of &lt;a href=&quot;https://github.com/tpitale/mail_room&quot;&gt;mail_room&lt;/a&gt; and tell you a little bit about it and how it fits in with your Rails app.&lt;/p&gt;

&lt;p&gt;Suppose you have a Rails application, and you would like to receive email from your customers, your users, or someone else. Out of the box, the &lt;a href=&quot;https://github.com/mikel/mail#getting-emails-from-a-pop-server&quot;&gt;mail gem can get messages from a POP3 server&lt;/a&gt; and allows you to query for messages in a very nice way. Unfortunately, in order to receive new mail, you have to ask the server at regular intervals.&lt;/p&gt;

&lt;p&gt;With mail_room, we can let gmail's IMAP do the work, using the IDLE command. As soon as a message arrives, mail_room will get it to your application.&lt;/p&gt;

&lt;h3&gt;mail_room&lt;/h3&gt;

&lt;p&gt;At its simplest &lt;a href=&quot;https://github.com/tpitale/mail_room&quot;&gt;mail_room&lt;/a&gt; will forward your incoming gmail email to a URL you define.&lt;/p&gt;

&lt;p&gt;It starts and runs as a process on its own. Given a configuration file &lt;a href=&quot;https://github.com/tpitale/mail_room/blob/master/spec/fixtures/test_config.yml&quot;&gt;like this&lt;/a&gt;, mail_room will open a connection for each gmail account and use the IMAP IDLE command to wait for new mail to come in. As soon as new mail arrives, mail_room will POST to the delivery_url you have configured.&lt;/p&gt;

&lt;p&gt;Messages are sent to your application's delivery_url as RFC822 and can be received and parsed by the mail gem. From the mail object, you can see from, to, subject, body, and html for the message.&lt;/p&gt;

&lt;p&gt;A delivery_token can be set to provide a simple mechanism to verify the sender. If an https delivery_url is provided, mail_room uses the excellent Faraday under the covers. By default, Faraday will attempt to use a verify_mode of &lt;span class=&quot;inline-code&quot;&gt;OpenSSL::SSL::VERIFY_PEER&lt;/span&gt;.&lt;/p&gt;

&lt;h3&gt;Trying it out&lt;/h3&gt;

&lt;p&gt;If you'd like to try it out, but don't have an endpoint to receive the messages from mail_room, it can be configured to do more. Messages can be written to a log file, or better yet, they can be received and opened by Ryan Bates' (of &lt;a href=&quot;http://railscasts.com/ &quot;&gt;Railscasts&lt;/a&gt;) fantastic gem, &lt;a href=&quot;https://github.com/ryanb/letter_opener &quot;&gt;letter_opener&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Descriptions of the other configuration parameters for delivery methods can be found in this &lt;a href=&quot;https://github.com/tpitale/mail_room#delivery_method &quot;&gt;section of the README&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Start it up from your terminal using &lt;span class=&quot;inline-code&quot;&gt;mail_room -c /path/to/config.yml&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;When you're ready, you can simply use the mail gem to parse the body that mail_room sends using &lt;span class=&quot;inline-code&quot;&gt;Mail.read_from_string(message)&lt;/span&gt;. In this example 'message' is the POST body.&lt;/p&gt;

&lt;h3&gt;Next Steps&lt;/h3&gt;

&lt;p&gt;mail_room has greatly simplified the code I need to have in my Rails applications in order to have email pushed to me.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Try it out for yourself.&lt;/li&gt;
  &lt;li&gt;Watch the code for updates, new features, and an end-to-end example Rails integration.&lt;/li&gt;
  &lt;li&gt;Open an issue for any problems or questions you have.&lt;/li&gt;
&lt;/ul&gt;

      </content>
    </entry>
  
    <entry>
      <id>http://tpitale.com/dividing-our-views-and-templates-in-rails</id>
      <title>Dividing Our Views and Templates in Rails</title>
      <link href="http://tpitale.com/dividing-our-views-and-templates-in-rails.html" />
      <updated>2013-02-03T13:00:00-08:00</updated>
      <content type="html">
        &lt;p&gt;TL;DR: I created a gem called simplest_view that makes it easy to move logic out of your Rails templates and into a class, in a conventional way.&lt;/p&gt;

&lt;p&gt;You can see it on Github at &lt;a href=&quot;https://github.com/tpitale/simplest_view&quot;&gt;tpitale/simplest_view&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to start using it, but read on to see how I made it.&lt;/p&gt;

&lt;h3&gt;Is it a View or a Template?&lt;/h3&gt;

&lt;p&gt;Rails views are actually ERB templates. However, they're found under app/views. I think this manifests as a problem when our ERB templates grow in complexity as:&lt;/p&gt;

&lt;ul class=&quot;post-list&quot;&gt;
  &lt;li&gt;more data (in more instance variables) is passed to the ERB template&lt;/li&gt;
  &lt;li&gt;logic is embedded within the template&lt;/li&gt;
  &lt;li&gt;none of this is sufficiently tested&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My goal was to be able to put my code in views, rather than letting my templates handle logic. That meant I needed to split the view from the ERB templates, so I could have a real view object. The template's only responsibility should be the display of markup, json, xml, etc. &lt;!-- We don't have to be hardcore to do this, we don't have to switch to handlebars or liquid for our tempting language. We just need a little discipline. --&gt;&lt;/p&gt;

&lt;h3&gt;Moving the Templates&lt;/h3&gt;

&lt;p&gt;The easy part is the existing templates.&lt;/p&gt;

&lt;p&gt;I started by moving any existing &quot;view&quot; templates from app/views into app/templates. To make my app work I added &lt;span class=&quot;inline-code&quot;&gt;self.view_paths = ['app/templates']&lt;/span&gt; to my ApplicationController.&lt;/p&gt;

&lt;p&gt;If you're following along, you could run your tests and this should work.&lt;/p&gt;

&lt;h3&gt;A Little Spelunking&lt;/h3&gt;

&lt;p&gt;Now, for the fun part: views!&lt;/p&gt;

&lt;p&gt;If you've ever done something like &lt;span class=&quot;inline-code&quot;&gt;&amp;lt;% puts self.inspect %&amp;gt;&lt;/span&gt; inside of an ERB template, you'll see that it's just a class. To know what functionality it has and where it comes from, I had to dig into Rails just a bit.&lt;/p&gt;

&lt;p&gt;The first thing I saw was that the class's ancestors include some interesting things like &lt;span class=&quot;inline-code&quot;&gt;ActionView::Base&lt;/span&gt; and, of course, my &lt;span class=&quot;inline-code&quot;&gt;ApplicationHelper&lt;/span&gt; that gets included. The real question is, 'Where does this view get made?'&lt;/p&gt;

&lt;h3&gt;And the Views&lt;/h3&gt;

&lt;p&gt;The answer is found within the rendering module that is mixed in with AbstractController. Within, I found two methods: &lt;span class=&quot;inline-code&quot;&gt;view_context&lt;/span&gt; and &lt;span class=&quot;inline-code&quot;&gt;view_context_class&lt;/span&gt;. An anoymous class is created, which inherits from &lt;span class=&quot;inline-code&quot;&gt;ActionView::Base&lt;/span&gt; and is used as the context for any ERB templates.&lt;/p&gt;

&lt;p&gt;I made some small changes to &lt;span class=&quot;inline-code&quot;&gt;view_context_class&lt;/span&gt; to make it use my own view classes.&lt;/p&gt;

&lt;p&gt;To start I made up a convention for the view class that mirrors the templates. Something like app/views/posts/index_view.rb will have the view for &lt;span class=&quot;inline-code&quot;&gt;PostsController#index&lt;/span&gt; defined as &lt;span class=&quot;inline-code&quot;&gt;class Posts::IndexView &amp;lt; ActionView::Base&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;Using that class name, I just did what Rails 3 does, which is to create an anonymous class, and include the routing and misc helpers. This class then becomes the context for my ERB templates.&lt;/p&gt;

&lt;p&gt;It will have access to all the instance variables from the controller, and the ERB template will have access to any methods defined on the view.&lt;/p&gt;

&lt;p&gt;What I've got now is the simplest split between Rails templates and views. This lets me clean up any logic that may have crept into my ERB templates over many months or years of development.&lt;/p&gt;

&lt;p&gt;You can see the completed code module &lt;a href=&quot;https://github.com/tpitale/simplest_view/blob/master/lib/simplest_view.rb&quot;&gt;on Github&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;Test Drive&lt;/h3&gt;

&lt;p&gt;If you would like to try this out in your project, please give &lt;a href=&quot;https://github.com/tpitale/simplest_view&quot;&gt;SimplestView&lt;/a&gt; a spin.&lt;/p&gt;

&lt;h3&gt;Next Steps&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;It would definitely be a huge help if you could try it out, see how the approach feels in your project.&lt;/li&gt;
  &lt;li&gt;If you can spot a better way to hook into the view_context, let me know.&lt;/li&gt;
  &lt;li&gt;And lastly, open an issue if you find anything wrong or broken!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <id>http://tpitale.com/dropbox-thumbnails-to-s3-with-carrierwave</id>
      <title>Dropbox Thumbnails Into S3</title>
      <link href="http://tpitale.com/dropbox-thumbnails-to-s3-with-carrierwave.html" />
      <updated>2012-11-27T19:00:00-08:00</updated>
      <content type="html">
        &lt;p&gt;
  While building &lt;a href=&quot;http://photodrop.in&quot;&gt;PhotoDrop&lt;/a&gt; I needed to upload thumbnails returned from Dropbox into S3. This should be an easy task, and it is, once you get passed this one little snag: the thumbnails from Dropbox are strings of data representing as if you just called File.read on the image file.
&lt;/p&gt;

&lt;p&gt;
  Dropbox is, of course, doing the right thing here. And, so is the rubygem dropbox-api. Rather than writing out a file, even a temporary one, these small thumbnail files can remain in memory and be quickly disposed of after we've sent them on to S3 for storage.
&lt;/p&gt;

&lt;p&gt;
  &lt;a href=&quot;https://github.com/jnicklas/carrierwave&quot;&gt;CarrierWave&lt;/a&gt; is an excellent gem. It makes uploading, processing, manipulating, and storing images/files quite pleasant. The challenge is to trick CarrierWave into using the string as if it was a file. Happily, this is an easy task.
&lt;/p&gt;

&lt;h3&gt;ThumbnailIO&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://gist.github.com/4146418&quot; class=&quot;gist-link&quot;&gt;ThumbnailIO Class&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
  We simply take the string, wrap it up as a StringIO, and give it an original_filename. To assign the image to a CarrierWave handler just pass the name and data to a new instance, like so: &lt;span class=&quot;inline-code&quot;&gt;image = ThumbnailIO.new(some_filename, entry.thumbnail(format: 'jpeg', size: 's'))&lt;/span&gt; and save. That's all there is to it!
&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <id>http://tpitale.com/sunspot-with-datamapper</id>
      <title>Sunspot with Datamapper</title>
      <link href="http://tpitale.com/sunspot-with-datamapper.html" />
      <updated>2012-11-26T09:01:00-08:00</updated>
      <content type="html">
        &lt;p&gt;
  Expanding search beyond simple queries is not easy. I tend to be lazy. For a long time this meant chaining queries and just letting PostgreSQL sort it all out, adding indexes along the way. This all falls down of course when we need to find one word – or part of one – within a body of text. Even worse is joining across tables all with one query. It can get very ugly, very quickly.
&lt;/p&gt;
&lt;p&gt;
  Thankfully, I had read about &lt;a href=&quot;http://outoftime.github.com/sunspot/&quot;&gt;Sunspot&lt;/a&gt;, a well-designed wrapper around the powerful Solr search daemon. To get started, I watched the excellent introductory &lt;a href=&quot;http://railscasts.com/episodes/278-search-with-sunspot&quot;&gt;&quot;Search with Sunspot&quot; Railscast&lt;/a&gt; by Ryan Bates (you should really &lt;a href=&quot;http://railscasts.com/pro&quot;&gt;buy a pro account&lt;/a&gt;, it's worth every penny).
&lt;/p&gt;

&lt;p&gt;
  Unfortunately, out-of-the-box, Sunspot comes with ActiveRecord support and not much mention of other ORM's in the documentation. Here's what's working for me.
&lt;/p&gt;

&lt;h3&gt;Install and Setup&lt;/h3&gt;

&lt;p&gt;
  Installation is cake. Simply add &lt;span class=&quot;inline-code&quot;&gt;gem &quot;sunspot_rails&quot;&lt;/span&gt; to your Gemfile as in any other case, and &lt;span class=&quot;inline-code&quot;&gt;bundle install&lt;/span&gt; away.
&lt;/p&gt;

&lt;p&gt;
  Thanks to &lt;a href=&quot;http://gist.github.com/1291094&quot;&gt;a gist by Dan Kubb&lt;/a&gt;, there is an example of how to create an adapter for DataMapper to work with Sunspot. I &lt;a href=&quot;http://gist.github.com/1291094&quot;&gt;forked it and added a few more pieces&lt;/a&gt; that seem to be required for it to work.
&lt;/p&gt;

&lt;p&gt;
  After the adapter is in place, we can generate the Sunspot configuration with &lt;span class=&quot;inline-code&quot;&gt;script/rails generate sunspot_rails:install&lt;/span&gt;. We'll want to be sure to add &lt;span class=&quot;inline-code&quot;&gt;solr/data&lt;/span&gt; to our .gitignore file.
&lt;/p&gt;

&lt;h3&gt;Model Configuration&lt;/h3&gt;

&lt;p&gt;
  To get our models set to be indexed, we can simply follow Sunspot's README and configure our models using a &lt;span class=&quot;inline-code&quot;&gt;searchable&lt;/span&gt; block. &lt;a href=&quot;https://gist.github.com/4146210&quot;&gt;Here's what I'm using to search a Problem class&lt;/a&gt;, though it uses a lot of &quot;text&quot; fields. Many more, better examples can be found in the Sunspot docs.
&lt;/p&gt;

&lt;h3&gt;Searching&lt;/h3&gt;

&lt;p&gt;
  For some reason, I was unable to call &lt;span class=&quot;inline-code&quot;&gt;Problem.search {}&lt;/span&gt; and instead I have to call &lt;span class=&quot;inline-code&quot;&gt;Sunspot.search(Problem) {}&lt;/span&gt;. Happily, I like this form better. It makes it clear that I can pass in multiple model class names to search across and that I'm only really searching the Problem in this example.
&lt;/p&gt;

&lt;h3&gt;Sunspot/Solr Tweaks&lt;/h3&gt;

&lt;p&gt;
  I've made only a few minor modifications to solr's schema.xml configuration as generated by Sunspot. Under the solr.TextField fieldType I've added just a bit to use &lt;a href=&quot;https://gist.github.com/4146175&quot;&gt;PorterStemFilterFactory&lt;/a&gt; to stem words in the index. Stemming is the process of removing common endings from words, to normalize when searching. For example, &quot;riding&quot; and &quot;rides&quot; would both be stemmed to &quot;ride&quot;. Be careful, &lt;a href=&quot;http://wiki.apache.org/solr/LanguageAnalysis&quot;&gt;each language will have its own stemmer&lt;/a&gt;.
&lt;/p&gt;

&lt;h3&gt;Quirks&lt;/h3&gt;

&lt;p&gt;
	Without specifying the models you wish to use explicitly, the rake tasks for Sunspot will attempt to load ActiveRecord, which we obviously do not have. The simple solution is to use &lt;span class=&quot;inline-code&quot;&gt;rake sunspot:index models=Problem+Task+OtherModel&lt;/span&gt; to tell the task exactly which models we would like to be indexed.
&lt;/p&gt;

&lt;h3&gt;Testing&lt;/h3&gt;

&lt;p&gt;
  I would be remiss if I didn't write about how I'm testing. Stubbing is advisable in most scenarios where you don't want to actually test the functionality within Sunspot.
&lt;/p&gt;

&lt;p&gt;
  However, I would also ensure the results you want are coming back from your search, a small, precise set of integration tests should be built.
&lt;/p&gt;

&lt;h3&gt;In Conclusion&lt;/h3&gt;

&lt;p&gt;
  I'm happy to report that, in combination, Sunspot and DataMapper get along quite beautifully and I have had no real problems with this arrangement. The declarative nature of both DataMapper and Sunspot make for models that are extremely easy to understand and maintain. Now, my search pains are eased.
&lt;/p&gt;

      </content>
    </entry>
  
    <entry>
      <id>http://tpitale.com/server-sent-events-with-celluloid-and-reel</id>
      <title>Server-Sent-Events with Celluloid and Reel</title>
      <link href="http://tpitale.com/server-sent-events-with-celluloid-and-reel.html" />
      <updated>2012-11-02T14:22:00-07:00</updated>
      <content type="html">
        &lt;p&gt;
  There's a lot of buzz around websockets, and rightly so. They provide very
  powerful, two-way communication between you and the user's browser. Sadly,
  the current level of compatibility, along with the Flash-based fallbacks,
  leave me shuddering at the thought of using them in almost every scenario.
&lt;/p&gt;

&lt;p&gt;
  More recently, the half-a-websocket alternative server-sent-events (SSE),
  has been getting a fair amount of press, too. Aaron Patterson (aka,
  &lt;a href=&quot;https://twitter.com/tenderlove&quot;&gt;@tenderlove&lt;/a&gt;) &lt;a href=&quot;http://tenderlovemaking.com/2012/07/30/is-it-live.html&quot;&gt;
  showed us how to do it using  ActionController::Live in Rails 4&lt;/a&gt;. 
  Even better, Tony Arcieri (aka &lt;a href=&quot;https://twitter.com/bascule&quot;&gt;@bascule&lt;/a&gt;)
  &lt;a href=&quot;https://github.com/celluloid/reel/blob/master/examples/websockets.rb&quot;&gt;
  has an example of how to use websockets&lt;/a&gt; within his brilliant project
  &lt;a href=&quot;http://github.com/celluloid/celluloid&quot;&gt;Celluloid&lt;/a&gt; and its offshoot
  webserver, &lt;a href=&quot;http://github.com/celluloid/reel&quot;&gt;Reel&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
  Thanks goes entirely to these two giants of the Ruby community, I've simply
  patched their work together to show a simplistic example of how to do a SSE
  broadcast using a Reel webserver and Aaron's basic SSE class.
&lt;/p&gt;

&lt;h3&gt;The Code&lt;/h3&gt;
&lt;p&gt;
  &lt;a class=&quot;gist-link&quot; href=&quot;http://gist.github.com/4004298&quot;&gt;SSE with Reel&lt;/a&gt;
  &lt;br&gt;
  &lt;a class=&quot;raw-gist-link&quot; href=&quot;https://raw.github.com/gist/4004298/82c120f868d14029e9247301a0056782552e45d7/server.rb&quot;&gt;Raw Code&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
  As you might imagine, SSE probably serves the needs of most everyone that
  wants to push up events and data to a browser. Thankfully, SSE is based on
  http and there are a handful of pure-javascript polyfills available. Check
  out MDN for &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Server-sent_events&quot;&gt;
  more information on SSE&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
  Thanks for reading! &lt;a href=&quot;http://twitter.com/tpitale&quot;&gt;Tweet at me&lt;/a&gt;
  with any comments, suggestions, or questions. Check back later or follow
  me to see when I share how I'm using this with &lt;a href=&quot;http://emberjs.com&quot;&gt;
  Ember.js&lt;/a&gt;.
&lt;/p&gt;

      </content>
    </entry>
  
</feed>
