samhuri.net


By Sami Samhuri

Structure of an Ember app

I made a diagram of an Ember app. There's a discussion about it on the Ember Discussion Forum. Here is the source file, created with OmniGraffle: Ember structure.graffle

Structure of an Ember app

Linky

Send links from mobile devices to your computers.

The last few months I've been annoyed by my workflow for sending links from my touch devices to my computers. For example if I come across a cool Mac app or an open source project I want to check out, or anything along those lines. Until now I have been mailing links to my work or home addresses, or saving links in Instapaper. The problem with both of those is the same: I have to remember to check something when I arrive at the correct machine. It sounds trivial but I have been annoyed by it nonetheless.

This weekend I finally decided to scratch that itch and ended up writing much less code than I imagined to accomplish it in a perfectly acceptable way. The components are:

Yup, that is a lot of moving parts. It is rather elegant in a Unixy way though.

I experimented with Gmail → IFTTT → BoxcarGrowl, but Boxcar's Mac app is really rough and didn't seem to pick up new messages at all, let alone quickly, so I fell back to a solution with more parts.

Gmail

Gmail allows you to append extra info to your email address in the username, which you can use for filtering and labeling. I send links to sami.samhuri+linky@gmail.com and then filter those messages out of my inbox, as well as applying the label linky. Using email as the entry point means that basically every app I use already supports sending links in this way.

IFTTT

IFTTT (If This Then That) can wire up services, so that events that happen in one place can trigger an action elsewhere, passing along some info about the event along with it. In this case when a new email arrives in my Gmail account with the label linky then I create a text file in Dropbox that contains two lines: the title, followed by the link itself.

For example, the following lines would be created in a file at ~/Dropbox/Linky/Ruxton/<generated filename>.txt for my machine named Ruxton.

Callbacks as our Generations' Go To Statement
http://tirania.org/blog/archive/2013/Aug-15.html

The filename field is defined as:

{FromAddress}-{ReceivedAt}

And the content is:

{Subject}<br>
{BodyPlain}<br>

That means that when you email links, the subject should contain the title and the body should contain the link on the first line. It's ok if there's stuff after the body (like your signature), they will be ignored later.

I create one recipe in IFTTT for each machine that I want links to appear on. You could get fancy and have different Gmail labels for individual machines, or aliases, groups, etc. I've kept it simple and just have every link I send go to both my home & work computers.

Dropbox

Dropbox is fantastic. My files are never not everywhere. IFTTT creates the file in Dropbox, and then Dropbox makes sure it hits all of my machines. Did I mention that Dropbox is awesome? It's awesome.

NorthWatcher

This is a quick and dirty thing I whipped up a couple of years ago, and now it's come in handy again. It's a program that watches directories for added and removed files, and then launches a program that can then react to the change. In this case, on each machine I want notifications on, I have it watch the Dropbox folder where IFTTT creates the text files. e.g. ~/Dropbox/Linky/Ruxton

It has a text configuration file kind of like cron. Here's mine from Ruxton:

+ Dropbox/Linky/Ruxton ruby /Users/sjs/bin/linky-notify

That tells NorthWatcher to run ruby /Users/sjs/bin/linky-notify when files are added to the directory ~/Dropbox/Linky/Ruxton.

NorthWatcher is on GitHub and npm. Install node and then run npm install -g northwatcher. After creating the config file at ~/.northwatcher you can run it automatically using this launchd config file. Drop that in ~/Library/LaunchAgents/net.samhuri.northwatcher.plist. Don't forget to update the working directory path, and run launchctl load ~/Library/LaunchAgents/net.samhuri.northwatcher.plist to load it up (afterwards it will load on boot).

A Ruby program, and terminal-notifier

Finally, we have the last two components of the system. A short Ruby program (/Users/sjs/bin/linky-notify) that reads in all the files NorthWatcher reports as added, and uses terminal-notifier to show a native OS X notification for each link. After displaying the notification it moves the text file into a subfolder named Archive, so I have a record of all the links I have sent myself.

You can get terminal-notifier with homebrew in a few seconds: brew install terminal-notifier. After you have used terminal-notifier you will be able to go into Notifications in System Preferences and change it from Banners to Alerts. Banners are transient, while Alerts are persistent and have action buttons: Show and Close.

Cool story, bro

It may not be exciting, but as someone who typically suffers from NIH syndrome and writes too much from scratch, I found it pretty rewarding to cobble something seemingly complicated together with a bunch of existing components. It didn't take very long and only involved about 10 lines of code. It's not exactly what I wanted but it's surprisingly close. Success!

Zelda Tones for iOS

Zelda

Matt Gemmell recently shared some sweet Super Nintendo wallpapers for iPhone 5. Although I don't have an iPhone 5 I was happy to snap them up and crop them for my 4S.

If you like that sort of thing then you might want these tones that I whipped up. The first pack is a few Zelda ringtones along with a few more SMS tones. Most of them are from A Link to the Past.

Get the Zelda tones

Pacman

The second pack is two Pacman tones.

Get the Pacman tones

O Fortuna

Okay okay, one last one. O Fortuna from Carmina Burana, composed by Carl Orff, performed by the London Philharmonic Orchestra.

Get the O Fortuna ringtone

Enjoy!

→ Fujitsu has lost their mind

Does this even warrant any comments on why it's already a massive failure? The many, many drawbacks seem so apparent I cannot believe this escaped from their drawing board.

→ SOPA lives - and MPAA calls protests an "abuse of power"

rather than coming to the table to find solutions to a problem that all now seem to agree is very real and damaging.

No. All most certainly do not agree.

It is also an abuse of power given the freedoms these companies enjoy in the marketplace today. It's a dangerous and troubling development when the platforms that serve as gateways to information intentionally skew the facts to incite their users in order to further their corporate interests.

This must be a joke. It's a joke, right? Please tell me this joker is joking. The hypocrisy is too much.

stop the hyperbole and PR stunts and engage in meaningful efforts to combat piracy.

There is absolutely nothing reasonable that anyone can do to "combat piracy". Digital copies are cheap. Adapt or die.

The VCR did not kill media industries. Nor the cassette, CD, DVD. Why should anyone believe that computers and the Internet are going to kill music and movies?

If the MPAA displayed even a shred of sanity maybe they would be taken seriously in their efforts to curb piracy. The biggest problem I can see is that studies have given us evidence that they are not hurt by it at all. Their tactic of choice seems to be to loudly decry "Nuh-uh! Piracy does hurt us!" and then strong arming everyone worldwide while suing anyone and everyone. If times are so tough maybe they should cut some of their budgets for lawyers and lobbyists.

→ Recovering From a Computer Science Education

Something to keep in mind.

→ The $40 Standup Desk

Ultimately, I decided I might as well just do something cheap for now. So I built my own. I had thinking about doing it for a while when my coworker Steve Smith built his desk. After seeing his, I was convinced this was what I wanted to do. It turns out, the cheap option is pretty awesome.

This looks great. Might have to consider it when or if I get a desk.

→ Yak shaving

The best plain-english explanation of yak shaving I have seen.

→ The Broken Pixel Theory

For example, a clean desk tends to stay clean until a piece of paper stays on it for a couple of days. Similarly, I'm much less likely to care about a 2-3 pixel UI bug when the whole UI is a mess.

Great insight from Majd Taby.

→ New Release of Firefox for Android, Optimized for Tablets

On the other hand, watch this video. Even in Mozilla's own demo - which presumably puts Firefox for Android in its best light - doesn't the whole thing look a bit herky-jerky, in terms of touch responsiveness and scrolling smoothness?

Surely they could do better on iOS though. I have faith in the Firefox team to provide a good experience because they have done so in the past. Modern versions of Firefox are excellent.

[New Release of Firefox for Android, Optimized for Tablets](http://blog.mozilla.com/blog/2011/12/20/new-firefox-for-android-ex= perience-optimized-for-tablets/)