Monday, September 23, 2013

Toggle a MacBook's Wifi with a Bash One-Liner

Sometimes the easiest way is a bash one-liner.  (Think Alfred shortcuts, BetterTouchTool gestures, Terminal.app.)  Running an applescript is all fine and dandy, but it's heavy.  Here's how to toggle your MacBook wifi on or off, where the wifi interface is en0.

( networksetup -getairportpower en0 | grep On ) \
   && ( networksetup -setairportpower en0 Off ) \
   || ( networksetup -setairportpower en0 On )

This is one of those messed-up bash-isms that uses conditional logic in the "wrong" way, elegantly.

Tuesday, September 17, 2013

Setting Processing's User-Agent for loadXML

In Processing, I'm fetching Yahoo's weather forecast for my location.  The loadXML() function is perfectly happy to take a URL, so I can just point it at my location's RSS feed.

In its default mode, this sends a user-agent string of "Java/1.6.0_51" which reflects my current Java version.  But I want to set my User-Agent, to something more descriptive.  If my project misbehaves, or an operator gets curious, it would be polite to have a more descriptive string with some contact info.

You can prepend a string to the user-agent by specifying it in your setup() function.

void setup () {
  System.setProperty("http.agent", "abstractForecast; https://github.com/fnaard/abstractForecast;");
}

Which results in the web server logging a user-agent of:

abstractForecast; https://github.com/fnaard/abstractForecast; Java/1.6.0_51

Oracle has some documentation on the network properties you can set.  There are more, notably: proxy settings, IPv4/v6 preference, and DNS caching behavior.

Sunday, September 1, 2013

Types of PS3 Hard Drive Caddies

I sent a friend's PS3 in for service, and they ask you to pull out your hard drive if you've upgraded it.  I did, but then at some point I discarded or lost the caddy that it belongs in.  There are four generations of PS3, and each has its own style of caddy.  Here's how it goes.

Generation
Models
Caddy
Old Fatty

CECHA01
CECHB01
CECHG01
CECHE01
Wire Pull-Tab

Newer Fatty


CECHH01
CECHK01
CECHL01
CECHP01
Flat Metal Pull-Tab

Slim

CECH-2001A
CECH-2001B
CECH-2101A
CECH-2101B
CECH-2501A
CECH-2501B
CECH-3001A
CECH-3001B
Side Flange

Slimmer


CECH-4001B
CECH-4001C
Swing-Out Tab

Friday, July 5, 2013

Loading 35 mm Film into a 126 Cartridge

A friend picked up a Kodak Instamatic 404 for me, a while ago.  It uses 126 film cartridges, which are 35 mm (-ish) film inside a sealed, easy-to-load cartridge.  Off I went to eBay, and found a used roll for ten dollars including shipping.

Fused spots.  Click for full size.
Pulling the cartridge apart is the hardest bit.  I found a great post on how to do it.  You'll need to twist, tease, and pry it apart.  The two halves of my Kodacolor II cartridge were glued/fused at four points inside, two on each side.  Pictured at right, the arrows are pointing to those spots, which may help you do it yourself.

With the cartridge eviscerated, I taped the start of some 35 mm film to the take-up spool and got to work in the changing bag.  I pulled out an arm's length of film, cut it, and rolled it up loose.  I wrangled the take-up spool into the big side, and held the loose roll in the small side, then snapped the cartridge back together.

Ready for the changing bag!
I'm assuming the Instamatic is reasonably light-tight once it's closed.  So rather than try to tape-up the edges of the cartridge -- so I could load a camera in daylight -- I just added the camera to my changing bag, dropped in the cartridge, and closed the camera's door.

As detailed in a fantastically technical post, there are some interesting differences between the teeth on 35 mm film and the "notches" on actual 126 film.  In short, the camera will think it has advanced a whole frame, before it's actually done it.  So, for each picture I took, I advanced the film, then held my hand over the lens and took a blank shot, so I could advance a second time.

The resulting photos are pretty gnarly.  For one thing, I was using 400 speed film in a 100 speed camera.  For another, the tape I put over the frame-count window on the cartridge was obviously not opaque enough.  Armed with these data, I think the next roll is going to be better.