Torii for Ember.js Lightning Talk

The slides for my recent Torii for Ember.js Lightning Talk (it ran a little long, so it was more of a “thunder” talk) are now available to download. They closely follow my post about Ember.js and Torii from September, and indeed the slides link to that post for the code walkthrough. Please let me know in the comments if you have any questions, and of course I’m available to chat in the EmberJS Community Slack team as @mwpmaybe (invite yourself here if you’re not already signed up).

I think there’s a video of my talk, but I understand the quality is not that great. I’ll post it here as soon as possible, assuming it’s not too bad.

Rack::Deflater in Sinatra

“Can I use Rack::Deflater in my Sinatra application?” Yes, absolutely. It’s a piece of Rack middleware and therefore super easy to use:

use Rack::Deflater

Furthermore, the RubyDoc for Rack::Deflater gives a cool little example of how to conditionally enable Rack::Deflater based on the size of the response body:

use Rack::Deflater, :if => lambda {
  |env, status, headers, body| body.length > 512
}

Unfortunately, this doesn’t work in Sinatra, or at least not on Sinatra 1.4.6, Rack 1.6.4, and Ruby 2.2.3. Why? Well, body is (for some reason) an array, so its length is probably zero (nil body) or one. It also occurs to me that we care more about the byte size of the body than its string length; if you think a 513-byte response is worth compressing, 512 characters encoded in UTF-32 (2,048 bytes) certainly is!

Here’s a modified (and code-golfed) version of the above snippet for Sinatra:

use Rack::Deflater, :if => lambda {
  |*, body| body.map(&:bytesize).reduce(0, :+) > 512
}

Happy deflating!

Easy login sessions with Ember.js and Torii

This is an easy and simple session lifecycle solution pattern for Ember.js 1.13/2.0 using Torii 0.6.0 that I’d like to share. Ember is a framework for building single-page web applications (SPAs) in JavaScript and HTMLBars. Torii abstracts authentication (authn) and authorization (authz) services in Ember and gives you powerful hooks into authn providers (social media login, e.g. Facebook or Twitter, or your company’s internal directory service) and customizable authz adapters (i.e. your application’s backend). It can inject the session object returned by your API into routes and controllers, and protect routes that require authorization.

Continue reading

Yosemite on unsupported Mac Mini

I have an ancient Mac Mini running Yosemite and OS X Server “headless”—after a bit of finagling—and all is well and good for the most part. However, my system log is getting spammed with the following every 10 seconds or so:

Jul 20 12:27:32 foo.bar watchdogd[80881]: [watchdog_daemon] @( wd_watchdog_open) - IOIteratorNext failed (kr=0)
Jul 20 12:27:32 foo.bar watchdogd[80881]: [watchdog_daemon] @( wd_daemon_init) - could not initialize the hardware watchdog
Jul 20 12:27:32 foo.bar watchdogd[80881]: [watchdog_daemon] @( main) - cannot initialize the watchdog service
Jul 20 12:27:32 foo com.apple.xpc.launchd[1] (com.apple.watchdogd): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.

Google is not turning up anything useful. It looks tricky to disable, and I’m not convinced that’s the best (or only) course of action. Any suggestions, lazyweb?

Twitter continues to suck…

Look, don’t get me wrong, I love Twitter. I really do. It’s a great way to keep tabs on icons of industry, musicians and comedians, politicians and pundits, and friends and acquaintances. But there are some pretty frustrating and maddening little issues that prevent me from becoming completely enamored with the platform. I’ve already laid out my beefs with Twitter’s Direct Messaging feature; here’s a Part Two of sorts.

Continue reading

Review: Monoprice HDMI with RedMere

If you aren’t already buying all your A/V and computer cables and adapters from Monoprice, you’re doing it wrong! Monoprice has the best selection and prices you’ll ever find. They also manufacture (or possibly rebrand) a lot of high-quality original products, such as DisplayPort adapters, battery packs, and Apple-compatible 30-pin dock connector cables. (And no, they’re not a sponsor.)

Earlier this year, Monoprice announced a partnership with an Irish firm called RedMere. RedMere has developed a new technology that several OEMs, including Monoprice, have integrated or plan to integrate into their HDMI cables. RedMere adds circuitry into the HDMI connector on one end of the cable that effectively steals a little voltage from the display/sink device (e.g. a TV or A/V receiver) to boost the signal. This allows them to use a much thinner, lighter, and more flexible strand than usual.

Continue reading

Yes, Virginia, the rMBP does have optical out

There’s been some question and debate around the interwebs about whether or not the new MacBook Pro with Retina display has an optical out or not. Pretty much every Mac released for the past ten years or so has provided digital audio output via the 3.5 mm stereo jack, requiring a mini-TOSLINK cable or adapter to utilize. However, the Apple does not list such functionality on the rMBP tech specs, leading to some speculation about whether Apple has decided to EOL this feature.

Here’s some pretty definitive proof that the feature is in fact still available and ready to go, courtesy of a Monoprice mini-TOSLINK adapter. Ooh, shiny red glow. Do not look directly into laser with remaining eye.