<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>hi, it&#39;s mike</title>
    <link>https://mike.puddingtime.org/tags/sinatra/</link>
    <description>Recent content on hi, it&#39;s mike</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>mike@puddingtime.org (mike)</managingEditor>
    <webMaster>mike@puddingtime.org (mike)</webMaster>
    <copyright>© 2026, mike</copyright>
    <lastBuildDate>Mon, 18 Apr 2011 07:27:48 +0000</lastBuildDate>
    <atom:link href="https://mike.puddingtime.org/tags/sinatra/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Padrino</title>
      <link>https://mike.puddingtime.org/posts/2011-04-18-padrino/</link>
      <pubDate>Mon, 18 Apr 2011 07:27:48 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2011-04-18-padrino/</guid>
      
      <description>Neato! Sam tipped me to Padrino, which sits on top of Sinatra and provides a sort of bridge between Sinatra&#39;s minimalism and Rails&#39; ... uh ... Railsiness.
I&#39;ve been fiddling around with the idea of building an app that would help me keep track of client sites: What plugins they have installed, what …</description>
      <content:encoded><![CDATA[<p>Neato! Sam tipped me to <a href="http://www.padrinorb.com/">Padrino</a>, which sits on top of <a href="http://www.sinatrarb.com/">Sinatra</a> and provides a sort of bridge between Sinatra's minimalism and Rails' ... uh ... Railsiness.</p>
<p>I've been fiddling around with the idea of building an app that would help me keep track of client sites: What plugins they have installed, what version their core software is at, what needs to be added to them, etc. It's the kind of thing you could keep in a spreadsheet, but as I've sketched out what I want to keep track of, it's gotten more and more unwieldy. I'd like, for instance, to keep track of which version WordPress is at in one place by updating just my WordPress entry, then list all the sites and get some quick visual feedback on which ones need an update. Same with plugin versions, template versions, etc.</p>
<p>It'd also be nice to have on place to keep track of which hosts each site lives on, what the path to the site files on the server is, client contact info, client support/development rates, and a worklog for each site (the better to have invoicing at some point).</p>
<p>Padrino's cool because it provides a way to generate an admin interface that's a step beyond Rails' basic scaffolding. It's nothing you couldn't do in Rails pretty quickly, but Padrino makes it pretty and simple. For instance, here's how to generate a Site model for my app:</p>
<p>
<p><tt>g model site name:string url:string client_id:integer cms_package_id:integer server:string path:string</tt></p>
</p>
<p>And here's how to quickly create an admin panel to manage sites:</p>
<p>
<p><tt>padrino g admin_page site</tt></p>
</p>
<p>Then you just load up <code>/admin/sites</code>, enter your user name and password, and you have a password-protected Web admin interface from which you can create and edit sites:</p>
<div style="text-align:center;margin:1em;">![](https://media.puddingtime.org/archive/mph.puddingbowl.org/wordpress/wp-content/uploads/2011/04/padrino_panel1.jpg)</div>
<p>It doesn't figure out associations, so you have to hand-edit here and there to do stuff like create a select item to pick which of your clients a site belongs to. You can do that by defining a collection in the controller (e.g. "clients") and then use that collection with a form helper:</p>
<div id="snipplr_embed_52230" class="snipplr_embed"><a href="http://snipplr.com/view/52230/padrino-select-from-collection/">Code snippet - Padrino Select from Collection</a> on Snipplr</div><script type="text/javascript" src="http://snipplr.com/js/embed.js"></script><script type="text/javascript" src="http://snipplr.com/json/52230"></script>
<p>And that gets you this:</p>
<div style="text-align:center;margin:1em; border:1px solid ccc;">![](https://media.puddingtime.org/archive/mph.puddingbowl.org/wordpress/wp-content/uploads/2011/04/padrino-helpers.png)</div>
<p>Combined with <a href="http://mph.puddingbowl.org/2011/04/pow-etc/">Pow</a> and an hour of poking around the docs to figure out how to make the helpers work, Padrino gave me a working site manager app in under an hour. Nice.</p>
<p>#padrino #ruby #sinatra</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Padrino">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>Pow! etc.
It seems as if a few colleagues…</title>
      <link>https://mike.puddingtime.org/posts/2011-04-16-pow-etc-it-seems-as-if-a-few-colleagues-might/</link>
      <pubDate>Sat, 16 Apr 2011 05:41:13 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2011-04-16-pow-etc-it-seems-as-if-a-few-colleagues-might/</guid>
      
      <description>Pow! etc.
It seems as if a few colleagues might need to use that little Sinatra-based reclassifier ditty, which is always a nice thing: The first iteration of these things usually seems to come close to breaking even on time saved if I just use it once, but if I can make the same tool available to …</description>
      <content:encoded><![CDATA[<p>Pow! etc.</p>
<p>It seems as if a few colleagues might need to use that <a href="http://mph.puddingbowl.org/2011/03/sinatra-ftw/">little Sinatra-based reclassifier ditty</a>, which is always a nice thing: The first iteration of these things usually seems to come close to breaking even on time saved if I just use it once, but if I can make the same tool available to one or two more people, then it's a lock to earn the development time back and start saving a lot of time.</p>
<p>The problem with sharing stuff like Rails and Sinatra is deployment. Easy for me to set something up on my desktop that never seems to leave dev mode, but less of a pleasure to get it working for others, especially on shared hosting.</p>
<p>Several things will help with that:</p>
<p>First, <a href="https://github.com/37signals/pow">Pow! from 37 Signals</a> makes it easy to create a local development domain for webapps that use Rack. You just install it, create a <code>config.ru</code> file for your app in its directory, then symlink the app directory to <code>~/.pow</code> and it becomes available at <code>http://yourappdir.dev</code>. Besides being a great way to work on a number of webapps in parallel, it's a nice way to practice dealing with Rack.</p>
<p>Second, <a href="http://www.gittr.com/index.php/archive/deploying-rack-apps-on-dreamhost-via-passenger-including-sinatra/">it looks like it's not too hard to use those Rack-enabled apps on Dreamhost</a>. This worked for my <code>config.ru</code> file, and it's the same as the one I use for my desktop machine:</p>
<div id="snipplr_embed_52180" class="snipplr_embed"><a href="http://snipplr.com/view/52180/sinatra-on-dreamhost/">Code snippet - Sinatra on Dreamhost</a> on Snipplr</div><script type="text/javascript" src="http://snipplr.com/js/embed.js"></script><script type="text/javascript" src="http://snipplr.com/json/52180"></script>
<p>Third, <a href="http://www.sinatrarb.com/faq.htmlauth"> it's not too hard to add http authentication</a> to a Sinatra app. That means I can deploy little apps that don't require a robust user model to a subdomain and protect them for as long as they need to be up, which is just a day or two. Here's all I had to add to the top of my app file to get http authentication:</p>
<div id="snipplr_embed_52181" class="snipplr_embed"><a href="http://snipplr.com/view/52181/sinatra-http-auth/">Code snippet - Sinatra http auth</a> on Snipplr</div><script type="text/javascript" src="http://snipplr.com/js/embed.js"></script><script type="text/javascript" src="http://snipplr.com/json/52181"></script>
<p>This all makes me think back to 2008, when I <a href="http://mph.puddingbowl.org/2009/01/best-worst-of-2008-technology/">wrote about my recent discovery of Rails</a>: The combination of Sinatra, Pow! and Rack does even more to provide me with a comfortable replacement for lightweight databases, and makes it much easier to share my work, which is even better.</p>
<p>#37signals #dreamhost #pow #rack #ruby #sinatra</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Pow%21%20etc.%0AIt%20seems%20as%20if%20a%20few%20colleagues%E2%80%A6">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>Sinatra ftw (Updated)
So, I have this task to…</title>
      <link>https://mike.puddingtime.org/posts/2011-04-01-sinatra-ftw-updated-so-i-have-this-task-to/</link>
      <pubDate>Fri, 01 Apr 2011 01:57:20 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2011-04-01-sinatra-ftw-updated-so-i-have-this-task-to/</guid>
      
      <description>Sinatra ftw (Updated)
So, I have this task to accomplish:
I&#39;ve got 1,180 articles that were all placed in a website directory I no longer want to keep. The friendly dbas gave me an Excel spreadsheet showing me each article&#39;s title, url, pub date, author and current directory. I&#39;m to go down the list …</description>
      <content:encoded><![CDATA[<p>Sinatra ftw (Updated)</p>
<p>So, I have this task to accomplish:</p>
<p>I've got 1,180 articles that were all placed in a website directory I no longer want to keep. The friendly dbas gave me an Excel spreadsheet showing me each article's title, url, pub date, author and current directory. I'm to go down the list and reassign each article.</p>
<p>I made it through 15 entries before realizing it's hard to tell what an article's about from just the headline. Some things look like tutorials, but they're reviews, some things look like reviews, but they're analysis. I can either guess, or I can copy the URL, flip to my browser and load the article then decide how to classify it. This process sucks:</p>
<ul>
<li>Copying and pasting URLs is a drag
<li>Waiting for articles to load if an element on the page hangs is a drag</li>
<li>Entering stuff in an Excel spreadsheet is a drag</li>
</ul>
<p>So I gathered together a few tools:</p>
<ul>
<li><a href="http://www.sinatrarb.com/">Sinatra</a>, which is a Ruby micro-framework for Web apps</li>
<li><a href="http://blueprintcss.org">Blueprint CSS</a>, which is a CSS framework for quick/easy pretty (or at least not awful) HTML
<li><a href="http://rubygems.org/gems/summarize">Summarize</a>, a gem that can take a bunch of text and return the relevant parts for a given percentage of the original
</ul>
<p>Then I set up a sqlite database & fed the Excel spreadsheet into it and sat down with Sinatra.</p>
<p>Here's the finished app (minus the one template page I use):</p>
<div id="snipplr_embed_51417" class="snipplr_embed"><a href="http://snipplr.com/view/51417/reclasserrb/">Code snippet - reclasser.rb</a> on Snipplr</div><script type="text/javascript" src="http://snipplr.com/js/embed.js"></script><script type="text/javascript" src="http://snipplr.com/json/51417"></script>
<p>It's missing some affordances, but the long and short is demonstrated here:</p>
<div style="text-align:center;margin:1em;">![](https://media.puddingtime.org/archive/mph.puddingbowl.org/wordpress/wp-content/uploads/2011/03/reclasser.jpg)</div>
<p>You start with a given article. It shows you the headline, pub date and author. Using the summarizer gem, it pulls in a summary representing 25 percent of the total text. You pick a new category for it from the radio buttons, click "Reclassify," and it takes you to the next record (unless you're done, in which case it just reloads the current record. </p>
<p>The time gain? I dunno. If I worked like a machine, I'd probably be done in four hours. Now it takes less time to update a record and I don't have to do as much to update it: Just click a radio button, click a submit button, move on. Even if it turns out the time I save is offset by the coding time (two hours, with a break for coffee, chatting, answering mail), I guess I figured out a way to spend some time that would be wasted screwing with Excel getting to play with Sinatra. And since I'm going to have to do the same task in a few weeks for another site, I'll have time-saving code ready to go.</p>
<p><strong>Update:</strong> Even better with a bit of jQuery: Rather than loading the article summary every time (even though I don't always need it to tell what kind of article I'm dealing with), I wrote an additional route that handles providing just the summary and used jQuery's load function to pull in the summary for review when I click on a "load summary" button. That makes things a lot faster when I can tell what an article is just from the headline.</p>
<p><strong>Update2 :</strong> Sinatra uses Mongrel by default, which is fine, except I noticed that every now and then a page load would go from taking an average of a fifth of a third or so to five seconds. Meh. So I <code>sudo gem install thin</code>'d the thin gem, and got much more consistent, snappy performance.</p>
<p>#drudgery #ruby #sinatra</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Sinatra%20ftw%20%28Updated%29%0ASo%2C%20I%20have%20this%20task%20to%E2%80%A6">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>Oh, Frank ... You&#39;re Dreeeeaaammmy</title>
      <link>https://mike.puddingtime.org/posts/2009-01-22-oh-frank-you-re-dreeeeaaammmy/</link>
      <pubDate>Thu, 22 Jan 2009 03:11:13 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2009-01-22-oh-frank-you-re-dreeeeaaammmy/</guid>
      
      <description>Another plus for Sinatra:
![](https://media.puddingtime.org/archive/mph.puddingbowl.org/wordpress/wp-content/uploads/2009/01/sinatra-error.png) I was building a form hooked up to an action that doesn’t exist yet. Clicking ‘submit’ got me that for an error page.
#ruby #sinatra
</description>
      <content:encoded><![CDATA[<p>Another plus for Sinatra:</p>
<div style="text-align:center;">![](https://media.puddingtime.org/archive/mph.puddingbowl.org/wordpress/wp-content/uploads/2009/01/sinatra-error.png)</div>
<p>I was building a form hooked up to an action that doesn&rsquo;t exist yet. Clicking &lsquo;submit&rsquo; got me that for an error page.</p>
<p>#ruby #sinatra</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Oh%2C%20Frank%20...%20You%27re%20Dreeeeaaammmy">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>Start Spreadin&#39; the News</title>
      <link>https://mike.puddingtime.org/posts/2009-01-20-start-spreadin-the-news/</link>
      <pubDate>Tue, 20 Jan 2009 04:00:41 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2009-01-20-start-spreadin-the-news/</guid>
      
      <description> I’m sure I’m not the only male in America who, when Palin dropped her first wink, sat up a little straighter on the couch and said, ‘Hey, I think she just winked at me.’ And her smile. By the end, when she clearly knew she was doing well, it was so sparkling it was almost mesmerizing. It sent …</description>
      <content:encoded><![CDATA[<blockquote>
<p>I&rsquo;m sure I&rsquo;m not the only male in America who, when Palin dropped her first wink, sat up a little straighter on the couch and said, &lsquo;Hey, I think she just winked at me.&rsquo; And her smile. By the end, when she clearly knew she was doing well, it was so sparkling it was almost mesmerizing. It sent little starbursts through the screen and ricocheting around the living rooms of America.</p>
</blockquote>
<blockquote>
<p>-- Rich Lowry of the National Review</p>
</blockquote>
<p><a href="http://sinatra.github.com/">Sinatra</a> just made my day that way.</p>
<p>As much as I&rsquo;ve been enjoying Rails for a few things, I&rsquo;ve wanted something a little more lightweight for several others. I&rsquo;ve waffled between doing them as Ruby CGIs running under <a href="http://www.lighttpd.net/">lighttpd</a> on my MacBook or finally breaking down and trying to learn <a href="http://wxruby.rubyforge.org/wiki/wiki.pl">WXRuby</a> or something similar.  Both options lack a certain portability, which is to say they have a requirements list more than one item long.  I also just don&rsquo;t feel like dealing with learning a GUI toolkit.</p>
<p>So Sinatra holds out the promise of being able to put things together without the weight of Rails and without having to learn much of a Whole New Something to get decent results.</p>
<p>Starting with <a href="http://mph.puddingbowl.org/2009/01/wrapping-up-nnw-attention-tracking-with-ruby/">the last version of my NetNewsWire attentional graphing script</a>, I dropped this line:</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&lt;p&gt;</span></span></code></pre></div>
<p>[sourcecode language=&lsquo;ruby&rsquo;]
File.open(&quot;/Users/mph/Sites/attention/index.html&quot;, &lsquo;w&rsquo;) {|f| f.write(ERB.new(@page).result) }</p>
<p>[/sourcecode]</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&lt;/p&gt;</span></span></code></pre></div>
<p>and added this:</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&lt;p&gt;</span></span></code></pre></div>
<p>[sourcecode language=&lsquo;ruby&rsquo;]</p>
<p>eruby = ERB.new(@page)</p>
<p>get &lsquo;/&rsquo; do</p>
<p>eruby.result(binding()).to_s</p>
<p>end</p>
<p>[/sourcecode]</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&lt;/p&gt;</span></span></code></pre></div>
<p>Running that and visiting http://localhost:4567/ gives me the same thing I was outputting as a static HTML file, only wrapped up in a live server and with the promise that it would be a simple matter to make something even more ​<em>logic-ish</em>​.</p>
<p>I don&rsquo;t know much about how it compares to <a href="http://camping.rubyforge.org/files/README.html">Camping</a> except that I was able to grok it instantly and it sent little starbursts through the screen, ricocheting around my living room.</p>
<p>There&rsquo;s lots of neat stuff in there: Templating, routing, support for ERB, and other niceties wrapped up in a simple syntax.  More to the point, a Sinatra app can live in a single file and ride around on a thumbdrive, ready to operate anywhere there&rsquo;s Ruby and the ability to install the Sinatra gem.</p>
<p>#ruby #sinatra</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Start%20Spreadin%27%20the%20News">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
  </channel>
</rss>
