Deploying Sinatra on Joyent’s Shared Accelerators with Thin

On Thursday afternoon, I had an idea for just about the smallest web app I could think of (since then, I’ve even cut out a couple features). It didn’t make sense to use all of Ruby on Rails for this considering how tiny it was.

Seemed like a great opportunity to try out Sinatra1

  1. Write the app
  2. Vendor Sinatra and Rack (that’s just good practice)
  3. Submit a ticket requesting a port
  4. Add a config.ru file to your app’s directory (for Rack) containing the following

    # PATH TO VENDOR-ED RACK AND SINATRA
    require 'vendor/rack-[VERSION]/lib/rack'
    require 'vendor/sinatra-[VERSION]/lib/sinatra'
    Sinatra::Application.set(
    :run => false,
    :environment => :production
    )
    require 'app'
    run Sinatra::Application
  5. Add a config.yml file to your app’s directory for Thin containing the following

    ---
    environment: production
    chdir: /path/to/app
    address: 127.0.0.1
    user: [USERNAME]
    port: [PORT]
    pid: /path/to/domain/tmp/thin.pid
    rackup: /path/to/app/config.ru
    log: /path/to/domain/logs/thin.log
    max_conns: 1024
    timeout: 30
    max_persistent_conns: 512
    daemonize: true
  6. Follow the Setting up and Configuring Lighttpd instructions on the Joyent Wiki (See update below)
  7. Add another Bootup Action for Thin
    Startup thin -s 1 -C /path/to/config.yml -R /path/to/config.ru start
    Shutdown thin -s 1 -C /path/to/config.yml -R /path/to/config.ru stop
  8. Follow the Proxying to a Port instructions on the Joyent Wiki
  9. 1. If the time I spent building this app was a cocktail, it’d be 1 part programming, 2 parts design, 3 parts deployment. That’s a huge part of why I wrote this post.

UPDATE: March 8, 2009
My gut says Lighttpd + Thin is redundant, so I’ve turned Lighttpd off.

Introducing the Minnesota Pineapple Economic Indicator

pineapple

It’s March in Minneapolis.

The thermometer just broke 40°F and there’s still inches of snow cover. Winter sustenance in the upper Midwest traditionally comes in two forms: canned or hotdish. Not the most uplifting and exciting dishes to get families through long, grueling winters, but economical.

Citrus fruits were a rarity, rare enough for oranges to be included in the treat bags given out after the elementary school Christmas program.

And according to the news media – we’re working through one of the hardest, coldest, financial winters in a nearly a century.

Yet, right now, at the Cub Foods up the street kiwi fruits are 4 for $1, mangos are 10 for $10, and pineapples are 2 for $5.

Admittedly, this isn’t as scientific as the Big Mac Index, but it’s quite remarkable, that a selection of tropical fruit can be grown, transported from South America (or Southeast Asia) to the middle of North America, in the middle of March, in the middle of a global economic winter, and sold for one or two dollars.

For my money it seems a more substantial – and more delicious – economic indicator is in the produce aisle.

16 April 2013 – Related:

“…bananas were first available commercially to American consumers in 1876…and sold for ten cents. In today’s dollars, that would be the equivalent of $3.00 per banana, or 1,150% more expensive than the 24 cents I paid at the local Safeway a few days ago!” – Mark J. Perry

March Forth

wecandoitposter

I’m proposing today as new American holiday.

A day of deliberate action.
A day of buckled-down confidence.
A day of bootstrap-up-pulling.
A day of To-Done-ed-ness.
A day of recovery.

The opposite of Labor Day – more along the lines of Independence Day.

Let’s go, there’s work to do.

March Forth.

“This country will be rescued by each of us doing what we can do in our own individual sphere of action as government works in its sphere of action. There are roughly 142 million men and women in the labor force. Their ingenuity, flexibility, energy, and confidence will make more difference than anything government does on an individual basis…In the free society, we rescue ourselves.” – Ben Stein

Device Agnostic Web Services

This morning I talked with John Vorwald‘s Multimedia Web Design class over at UW-Stout.

One of the great questions asked by the students was:

“Where do you see the internet in 2 years?”

2 years? Easy.

  1. Everything has a web server in it.
  2. The internet is accessible everwhere.

On my desk, as I write this, there are 5 devices that can have web browsers in them. At least two of them also have web servers in them. Only one of them is a “computer”.

Dave Winer’s Denon Receiver has a web server in it, as do other devices like Chumby, TiVo, Eye-Fi.

Though the contexts are different, and the interfaces need to be different, the same internet-based service could make sense across all 9 of those disparate devices.

Two years from now?
Easy.

Kindle 2.0 – 2nd Impressions

180px-amazbuck rio800

Dave’s “Decade of Ebook Arguments” post took me back a decade, to my first portable MP3 player – the Diamond Rio‘s 800 1

If memory serves, the 800 had 64Mb of storage2 – just enough audio for the walk from the apartment for the L ride into Loop. Not even enough for something new on the way home. I still have fond memories of manually copying files onto it from Panic’s Audion3.

I don’t remember feeling like the Rio changed my life.

I do remember thinking it was pretty neat for offering a small, small, glimpse into a what could be. Like future predictions of personal air travel, video-phones, or the Monsanto House.

The Kindle 2 has a lot in common with that old Rio 800.

The Kindle also shows us a future world – one of of direct-to-reader digital publishing and digital distribution. Dave’s post also brought to mind all the indie ‘zine & comic publishers I knew decades ago. They would have killed for the Kindle’s distribution channel.

But, like the Rio, the Kindle (and ebook readers in general) don’t have the ‘changed my life’ quality Apple is regularly able to ship4. There are 3 huge deficiencies I see with the Kindle after living with it for nearly a week:

  • The typographic capabilities are too basic. Simple conventions like italics, blockquotes, and a great number of typefaces would make the reading experience far more book-like (and actually usable for technical reference ebooks).
  • Navigating the Kindle is kludgy and unsophisticated. I mentioned this in my initial Kindle review. It’s annoying to navigate. It shouldn’t be annoying to navigate.
  • Getting new, free, independent stuff onto the Kindle isn’t as easy as it needs to be. No, I don’t think iTunes’ podcast directory should be used as a model – there are far simpler and equally sophisticated ways to handle this.

If there’s one reason why I’m happy with the Kindle, it’s that I’m a sucker for the glimpses into the future.

1. At the time, I was working for a startup funded by Diamond Multimedia.
2. Fast-forward to today, and on a normal week I download hundreds of Mb of audio from independent producers that’s only distributed digitally.
3. Still the friendliest, nicest, and simplest audio player for the Mac.
4. As you know, none of Apple’s products are first-to-market, and why I don’t expect to see an Apple-branded eBook reader any time soon.

King of Kong: This is How Small You Are

41nsga6d7cl_sl160_

Earlier this week, I watched The King of Kong: A Fistful of Quarters1

What I expected to be a light-hearted documentary about competitive video gamers took an unexpected turn into the dark, bizarre, lengths small people go to keep their name in the #1 spot, their clique tight, and outsiders out.

Since you’ve lived through your teen years, you know this phenomenon isn’t unique to video games. Kurt Schmidt talked about in the professional BMX Freestyle world in my podcast with him. There’s a decent chance it exists right now in one of your social circles.

The King of Kong’s editing showed Billy Mitchell avoiding his own restaurant, avoiding his challenger, avoiding directly reclaiming the title he holds so dearly. This sucks the life out of everyone is potentially a death sentence for Twin Galaxies. By contrast it showed Steve Weibe with a loving, supportive family – comfortable in the knowledge that this challenge is just one of the many he’ll be overcoming.

Happy ending.

Bonus: How Small You Are by Wonderlick

1. Netflix Instant Play via Boxee.

iPod Touch 2nd Generation 16GB: First Impressions

A couple weeks back, I picked up a 2nd Generation Apple iPod Touch – partially so I could start playing with web apps for it and partially cause my much beloved 3rd Gen 40gig iPod is starting to flake out.

I’ve been primarily for programming-related movies (PeepCode, SDRuby, and Pragmatic Programers), a calendar & address book, and some ongoing mobile experiments.

Compared to a Palm device, the iPod Touch is a far better experience. No question. As a music player compared against my iPod Nano or 40gig – it’s a miserable failure – especially in the car. Even as a video player it’s awkward if only because video and audio are treated differently in terms of navigation and rating.

The ‘slide to unlock’ gesture is the most elegant, convenient way to wake a device up – far better than the 2 key combo sequence phones require.

I was surprised to see the iPod Touch doesn’t have a camera. I fully expected it to. The omission makes me think the iPhone is far more heavily subsidized by AT&T than I originally calculated.

I’ve added a only a small handful of free apps from the App Store, and deleted all but 3 of them; Alocola, Fring, and WordPress (which may be deleted shortly.)

The apps the iPod ships with fared about as well, but I can’t delete them easily, which makes me grumbly.

Mail is nearly worthless for anything more than 1 (non-.me, non-Google) account, because there’s no rolled-up aggregate view of mail and it relies on server-side spam filtering.

Calendar is such a nice app. Good monthly and list views, easy to move events around and update their information. This is best calendar I’ve worked with.

Maps – Google Maps itself is an amazing piece of technology, then wrapped into tiny, tiny, highly-mobile Apple computer – astounding. There are a couple oddities I’ve found though; when I ‘drop pin’, ‘edit bookmark’ is the action for changing the name of the pin’s location (shouldn’t it be ‘edit pin’ or ‘edit location’) also, I haven’t figured out how to access my list of pins/bookmarks. Any idea?

Stocks, YouTube, Music, Clock, iTunes Music Store, Mail, and Settings have all been relegated to a secondary app screen, cause that’s most effective way to hide them.

Overall, I’m ‘eh’ on the device. It still has what I consider the iPod’s fatal flaw – required tethering to iTunes (my phone can update wirelessly from across the room, why do the iPod need to be plugged in?) and I’m not sure what – aside from basic PDA and media playback – I’d want applications on the device to do.

So, the numbers in the AppStore Secrets report from PinchMedia don’t surprise me (punch line: apps have ~30 day lifespan).

Kindle 2: 9 First Impressions

kindle

Amazon’s Kindle 2 arrived today. It’s the 3rd mobile internet device I’ve picked up this year, and a few hours in, I’m more pleased with it than the other two.

My initial impressions:

  1. The monochrome screen is gorgeous, and looks almost textured – as if there were a digital compliment to letterpress.
  2. The slim, flat, form factor and white case make me want to treat the Kindle like a piece of paper. It seems OK with that, comfortably setting where ever I put it, ready to be picked up whenever – just like book or more accurately a newspaper. Like a newspaper, it feels comfortable in one hand with a cup of coffee in the other. I now have no guilt about dropping our Sunday newspaper tradition.
  3. The navigation elements are slow and sticky. I’m never quite sure if I pressed the Next/Prev Page button hard enough – for the ‘click’ and the on-screen reaction seem to be off by a beat. The joystick is nearly flush with the face of the device and square (square?) with sharp edges, making it just uncomfortable and kind of painful to use. So far, using my thumbnail seems to be the least awkward way to manipulate it. Oh, and it doesn’t fly across the screen – it’s more stumbles from active area to active area.
  4. I’m already annoyed by the famous-author-portrait screensaver. I’d much prefer the screen to be black when not in use, especially considering sliding the power-switch toggle is an easy and explicit gesture that I want it to wake up. (If you know how to turn off the screensaver, please post it in the comments, thanks.)
  5. The reverse-text-on-page-turn is a jarring reminder that I’m reading an electronic device. Dramatically minimizing any chance you’ll get lost in the story. Remind me of a time when cars couldn’t drive faster than horses. Hopefully, this will go away (I’ll stop noticing it and the next revision will use a more subtle indicator).
  6. OS X does recognize the Kindle as a drive. Excellent – I wish the iPods were this accommodating. Then, I was disappointed to discover PDFs need to be converted before the Kindle recognizes them. I found Lexcycle’s Stanza – works fair for converting (good for documents, useless for presentations) – and loaded up my library of Pragmatic Programmers PDFs.
  7. Amazon’s ‘Recommended for You’ is built into the device and should be classified as a national economic stimulus package. Unlike every other commerce venue – including Apple’s iTunes Stores – it’s far easier to make the purchase within the Kindle thank to not.
  8. Overall, the least interesting thing to me is the Kindle as an “eBook” reader – though I finally feel like I have a comfortable device to read PDFs on. I’m far more interested that the Kindle has a free, persistent 3G wireless connection, a full QWERTY keyboard and a very basic browser (javascript is off by default). I find it both terribly amusing and annoying that, long webpages on the Kindle are navigated with next/previous page buttons – instead of scrolling.
  9. The mobile versions of Cullect and Twitter are completely usable.

Elsewhere:

” The iPhone UI, right down to its flowing scrolling on its touchscreen, is elegant and happy; the Kindle is klunky and irritating.” – Jeff Jarvis

The New Project Setup Checklist

As I mentioned earlier, one of my goals for this year is to launch 2 revenue-generating projects. I took a couple hours this morning and started the ball rolling on 2 of the potential candidates to fulfill that goal.

Here’s the checklist I use to lay the foundation for a project:

  1. Declare a descriptive code name
    A good code name (aka working title) has 3 characteristics; articulate the interesting aspects of the project, define the personality of the project, and be completely disposable. The original code name for Cullect was ‘FeedSeeder’. While ‘FeedSeeder’ worked for defining and building the system – it’s a horrid name. The code name for one of the projects inspiring this post is ‘cashboard’, which leads me to..
  2. Create a place for the project
    For me, this means creating a directory in my projects directory (~/Documents/Projects/) and an iCal calendar titled [code-name].
  3. Buy a good domain name
    If anything, the search for a good domain name confirms the need for a disposable code name. I search for domain names after I’m sure I’m serious about the project, though again, this might not be the final project name – Cullect was almost called ‘seedacres.com’ (again, bleeech). Once I’ve got the domain name, I usually dispose of the code-name and re-do Step 2 for the domain name.
  4. Set up the website and email at that domain
    For me, this means creating a ‘garrick@…’ user and installing WordPress on one of my servers at Joyent. This could also mean pointing a WordPress.com account at your domain, or something similar.
  5. Set up the Twitter account for that domain name.
    Finding a Twitter username can be as tricky as finding the domain name, and definitely stay as close to the domain name as possible. Use the email address you just set up – I even use a variation of it for my non-username Twitter ‘name’. Oh, and be sure to follow yourself 🙂
    Note: Whether or not Twitter is where people will be next year, it’s where they are now. Plus, if your project is a software application – there’s a good chance Twitter could be an interface to it.

Rule 1. Success Metrics are Things Robots Can’t Do.

The funny thing about metrics – the wrong one distracts more than it helps. And in this modern age, a technological hack can be built (if it doesn’t already exist) to give you the desired numbers.

Bernard Madoff
Click Fraud

This is why I’m not a big fan of measuring the success of a website based on click-through-rates or unique visitors. Both of which are distractions, and things automated scripts can be written to steadily increase the rates of.

On a much smaller scale, take a look at my “Twitter influence” according to Web Analytics Demystified.

For kicking Twitter’s tires for 2 years, I’m ok with my influence “becoming apparent” – it just betrays this report is worth exactly what I paid for it.

WebAnalyticsDemystified’s algorithm is obviously heavily weighting ‘retweets’ – the act of someone else repeating what you’ve said within Twitter. If you’ve followed along, I’ve railed against the act of retweeting that I’ve fostered an echo. I find @retweetgarrick an amusing joke. WebAnalyticsDemystified says it1 increases my influence.

Ummm.

So, to increase my ‘influence’ on Twitter, I should create an army of @retweetgarricks?

Yeah, we should probably just find a different metric.

1. Robots are neuter.