Archive for the 'Creations' Category

Portable centimetric measuring tape

Saturday, August 14th, 2010

This is a roll-up measuring tape that tucks neatly into my wallet, mostly so that I can compare sizes of products in the store without having to buy them or go find a ruler.

File: Centimetric_Ruler-portable.pdf

A US Letter page containing the ruler (20 cm long) and a specification for the cardboard handle you glue the ruler to.

Photos:

Photo of the portable centimetric measuring tape, rolled up, sitting on a table.

Photo of the portable centimetric measuring tape, with 6 cm unrolled, sitting on a table.

In case you're wondering about the pattern of the mm markings, I borrowed it from this New Zealand ruler that Dave posted about.

If I were to assemble this again, I would glue the “tape” to the other end of the handle, so that I can unroll the tape from left to right using my right hand. If you're left-handed, you might prefer to assemble yours the same way I did assemble mine.

My homemade A7 notebook

Monday, July 19th, 2010

I wanted a Moleskine Volant, but I didn't want to pay $3 each for them.

So I made my own notebook instead. It's A7, which is just a little wider than the Volants I'd been looking at.

Overall shot of the notebook.

I'd initially lettered the cover (to distinguish front from back) by hand, but wanted to make it a little more professional, so I bought a Fiskars Ultra ShapeXpress shape-cutter. Here's a video showing it in action. I printed out a template of the cover text, cut it out, and filled it in with my pen.

The notebook is ruled, and I keep a Zebra TS-3 mechanical pencil clipped into it.

Photo of me holding it open.

Here's the PDF of the rulings. I printed it double-sided onto regular copy paper. Obviously, I made it for US Letter, but it would be no different for A4, because each section is a little larger than A7, for reasons that will become clear in a moment.

Once printed, I cut the sections out with a paper-trimmer, then used a “medium” rounded corner punch, bought at Target in their scrapbooking section, to round off the corners (square corners will bunch up).

The cover is scrap cardboard from one of my T-shirt packs, cut to size using scissors (plus a ruler and pencil to mark where to cut) and rounded off with the same punch.

The binding is simple enough: Two staples in the spine of the book. This is why the sections I cut out are slightly larger than A7: Each page is A7, but I included a 5 mm gap between pages for the staples to go in. (This matters more for the outer sheets than for the inner ones.) If I were to leave out this gap, or shrink each notebook page by 2.5 mm to compensate, it would be possible to get four notebook sheets instead of three from an A4 sheet.

With this, I have a pocket-size notebook that's very inexpensive (being made from materials I have anyway), recyclable, and customizable to my taste. For a future notebook, I might make it with half ruled pages and half plain pages.

Centimetric ruler/measuring tape

Saturday, July 3rd, 2010

One mistake a lot of people make when trying to learn the metric system is trying to memorize and use conversion factors. Do you think people in other countries measure everything in inches and then convert to centimeters?

No, they have measuring tapes and rulers in centimeters or millimeters. Such rulers are easy to come by here in the US, but the measuring tapes are not.

So, in order to solve that problem and make it easier for fellow Americans to measure lengths in metric units, I present my Centimetric Ruler. It totals 2.5 meters, and looks like this:

Tick marks every 1 mm, with numbers over centimeter marks.

Despite the name, I use it as a measuring tape, coiled up and held in that shape (when not in use) by a small rubber band.

The page is US Letter (because that's the paper I have), and you'll need to cut out the pieces and tape them together. I recommend cutting through the tick marks so that there is no gap between them and the bottom of the “tape”.

Note that every 25th centimeter appears twice in the printout. This is to give you one centimeter in which to lay each segment over the previous/next one.

There's nothing I can do for you for measuring mass (but scales that measure in grams are easy to come by; you can buy a digital one at Target for $20), but volume is easy, and demonstrates the elegance of the metric system pretty well:

  1. A liter is equal to the volume of a cube that is 1 decimeter (= ¹⁄₁₀ meter = 10 cm) to a side. That volume is 1 dm × 1 dm × 1 dm, or 1 dm³—one cubic decimeter.
  2. ¹⁄₁₀ of a decimeter is one centimeter (¹⁄₁₀₀ of a meter).
  3. Imagine, or construct, a cube one decimeter to a side. Starting from one corner, make a cut in each edge, one-tenth of the way from the corner. This will produce a cube that is one centimeter to a side—one cubic centimeter.
  4. Note that this cube is ¹⁄₁₀ of the larger cube in each dimension, which means its volume is (¹⁄₁₀ × ¹⁄₁₀ × ¹⁄₁₀) = ¹⁄₁₀₀₀ of the volume of the larger cube.
  5. The volume of the larger cube being one liter, the volume of the smaller cube is ¹⁄₁₀₀₀ of that. ¹⁄₁₀₀₀ of a liter. One milliliter.
  6. QED: One cubic centimeter (1 cc) = one milliliter (1 ml).

Knowing how volume and length relate to each other in metric, you can use the measuring tape (most easily on cuboid objects) to measure volume as well.

Non-obvious solutions

Sunday, May 9th, 2010

I've started a site cataloging non-obvious, simple, superior ways of performing everyday tasks.

The visual theme is Fluid by Andrew Wilkinson, with a custom background image I made in Pixelmator:

Feel free to use that image on your own site.

Capture Cursor

Saturday, March 13th, 2010

Most people don't know how to get the cursor that's currently on the screen—a useful ability, especially if you're writing screenshot or screen-recording software. I've written an app that demonstrates the technique, or at least tries to.

It's a bit flaky. The API it uses, IOFramebuffer, doesn't tell me how many frames there are or what format they're in, so the app assumes ARGB in native byte-order and doesn't worry about frames. This gives wrong results more of the time than I like.

I've filed a request for a higher-level API, which would make the task much easier and the app much shorter.

I've posted a build in the repository's downloads area, in case you'd like to see it in action. If you want to build it yourself, you'll need to download SGHotKeysLib and put the source where the Capture Cursor Xcode project expects it to be.

UPDATE 2010-08-28: I've pushed a change, [9cbec7dd5169], that deletes the IOFramebuffer-based category method and uses Snow Leopard's new, far more reliable [NSCursor currentSystemCursor] instead. I suggest you do the same.

Easy main-thread performing category

Saturday, February 13th, 2010

Anyone who's ever had to perform a message on the main thread knows how ugly the code can be:

[obj performSelectorOnMainThread:@selector(receiveAnswer:)
                      withObject:[NSNumber numberWithUnsignedInteger:42]
                   waitUntilDone:NO];

I've written a category that changes the above code to something much simpler:

[[obj performOnMainThread_PRH] receiveAnswer:42];

Notice that not only is the code much easier to read and to write, but you no longer need to box and unbox primitive values.

You can get the code, under a BSD license, from the higher-order main-thread perform repository.

Back when I originally mentioned my creation of the category on Twitter, Dave Dribin replied that he had already written one of his own. His is part of his DDFoundation framework, and requires DDInvocationGrabber (a fork of Jonathan Wight's CInvocationGrabber), also part of that framework.

My category requires nothing but Cocoa and is not part of a larger framework. That said, it's interesting to read in his code how the functionality of the Invocation Grabber makes his implementation nothing but a thin wrapper around it. (Also, his version lets you say waitUntilDone:YES.)

Nearest Neighbor Image Unit

Saturday, February 6th, 2010

I originally wrote this as an application using NSImage (with NSImageInterpolationNone), but decided to rewrite it as an Image Unit. So, here it is.

An introduction to Cocoa and Cocoa Touch

Wednesday, February 3rd, 2010

If you know someone who's recently taken up programming the Mac or the iPhone (or both), please give them one (or both) of these links:

As a frequent answerer of questions on Stack Overflow, I see certain patterns—not just frequently-asked questions, but also frequently-unasked questions: Things that are biting the questioner that they don't know about.

Sometimes they're thinking about things the wrong way (e.g., using property list objects where they should have a model). Sometimes there is a route to a solution (“my app is slow” “run Instruments”), but they don't know about that route. Often, they'll use wrong terms that are right on another platform (like “member variable”), like a speaker using their native language's pronunciation rules when speaking a foreign one.

To help people over these speed bumps, I've composed an introduction for new Cocoa and Cocoa Touch programmers. (Both of the above links redirect to it.)

If any part of it doesn't help them (i.e., is unclear or wrong), I'd appreciate it if you'd let me know, either here or by email.

Ship-It Saturday: Shorten URLs service

Saturday, January 30th, 2010

When posting links on Twitter, your Twitter client will automatically shorten the URLs to make them fit.

There are many, many general shorteners, including TinyURL, Notlong, Metamark, and Bit.ly. One of the complaints about these is that they hide the true destination of the link: From the URL alone, you don't know whether you're going to be educated, RickRolled, or worse. (TinyURL and Bit.ly both offer a way to preview the link, but that's not as easy as just looking at the URL.)

To help with this, several non-shortening-related websites have added their own shorteners that use their own domains, particularly for use on their official Twitter accounts or with a built-in post-to-Twitter feature.

The problem is that it's not always easy to tell what the shortened link will be. Flickr is among the most difficult: Their regular links use decimal numbers, but their shortened links use base-58, which is not a trivial conversion to perform in any programming environment I know how to use. (Not so easy as, say, decimal to octal.) It's certainly doable, but would require extensive tests to verify that your base-58 numbers match Flickr's. There's sample code, but it's in PHP, so if you're writing in anything else, that means porting it, which means (again) extensive tests.

So, rather than write my own shortener, it's much easier to just use Flickr's: curl the canonical long URL, then scrape the short one out of the body. (Yay for <link rev="canonical">!) I wrote a service to do this.

For Ship-It Saturday, I retooled it. No longer is it just a Flickr shortening service: It now handles YouTube, Amazon, and a few other sites as well. A single service invocation shortens all links to websites that have their own shorteners.

So, here you go: The Shorten URLs service.

finder, a command-line tool

Sunday, January 24th, 2010

Today's Ship-It Saturday is a command-line interface to the Finder.

The two most useful commands are:

  • finder reveal file, which will select the file in a Finder window, and
  • finder update (or updated) file, which will tell the Finder that the file has been updated.

The latter command probably is not too useful anymore, but the command-line tool should work on no less than 10.4, and could probably be recompiled for even older versions of Mac OS X, so you may still have a use for it.

CocoaHeads Lake Forest videos

Monday, January 18th, 2010

It's been in editing for over a month, but now, it's finally done. I've just uploaded the second part of last month's meeting of CocoaHeads Lake Forest. There's one more to go from last month, and then I can start posting the video from this month.

This one's a lot more random than the first one. Portions of my own presentation are only part of what you'll see in this video.

More long-term, I've created a channel on Vimeo for all past and future CocoaHeads LF videos.

Pointers tutorial 1.3

Saturday, January 16th, 2010

At long last, a new version of Everything you need to know about pointers.

The most significant changes are long-overdue corrections regarding declarations of const pointers and the difference between arrays and pointers. You can—and, if you learned how to work with pointers from this tutorial, should—read all of the changes in the delta between 1.2 and 1.3.

Application Locator

Friday, January 8th, 2010

This is a little one, inspired by a Growl discussion list thread. Enter the bundle identifier or name of an application, and Application Locator will reveal it in the Finder.

Translate Text 1.0.1

Tuesday, January 5th, 2010

The new version adds a Sparkle public key, which should fix updating. Since updating was broken in all versions before 1.0.1, you'll need to update manually from the Translate Text web page.

Ship-It Saturday: IconGrabber 2.0.1

Sunday, January 3rd, 2010

The last time I released a version of IconGrabber was only a week after Valve released Half-Life 2—way back in 2004. That game wasn't even on my radar then, since I couldn't run it on my PowerPC-based Mac!

Just over five years later, I've played all of the Half-Life 2 games and love them, and IconGrabber returns with some bug fixes and support for the new bigger icon sizes introduced in Tiger and Leopard. Version 2.0.1 is available from the IconGrabber home page.

Ship-It Saturday: Translate Text

Sunday, December 27th, 2009

Real artists ship.

Steve Jobs

With the idea that an application that's 95% finished and in active use is better than an application waiting for 100% in the seclusion of my hard drive, Ship-It Saturday is where I dust off a program that I have 95% finished, call it done, and just ship it already. I hope to make this a regular feature, although I have no idea how frequently I'll do it.

Today's winner is Translate Text, an app I wrote to make handling Adium feedback emails easier. Just select some text, then choose the service corresponding to the language it's in (or the auto-detect-language-and-then-translate service). A window will open with the original, a couple of language pop-up menus, and the translation.

Screenshot of myself invoking the French-to-English service through a contextual menu.

More information, both screenshots, and the downloads at the Translate Text web page.

RAM disks on Snow Leopard

Friday, October 23rd, 2009

Make RAM Disk still works, which is not surprising, considering it's based on a few built-in commands.

What's changed is that the disk images system is now 64-bit, so if you have a 64-bit-capable Mac, you can create a single RAM disk bigger than 2 GiB—you no longer need to make multiple RAM disks and RAID them.

TimeMachineGrowler 1.0.1

Saturday, September 5th, 2009

The new version of TimeMachineGrowler includes compatibility with Snow Leopard and a few fixes. Plus, I've created a Google group for it, so you can get news of any further updates there.

TimeMachineGrowler 1.0

Thursday, August 27th, 2009

Just in time for tomorrow's release of Snow Leopard, TimeMachineGrowler is an app that will tell you how long Time Machine takes to create a back-up by posting Growl notifications when the back-up starts and finishes.

One of the promised “refinements” in Snow Leopard is faster back-ups, so you may find it interesting to compare how long a back-up takes on your machine running Leopard to how long it takes on Snow Leopard (assuming, of course, that you haven't already abandoned Leopard for the Snow Leopard GM).

Copy UNIX path to Finder selection

Thursday, August 13th, 2009

UPDATE 2009-08-14: Or just use CopyPath, which looks like a much better implementation of exactly the same thing. Thanks to David Keegan, its author, for suggesting it in the comments.

The original post content follows.


This is a script application, which apparently you can drag into your Finder toolbar. (If it doesn't let you, you didn't drop it in the right spot. Finder is finicky about this. Keep trying.)

Once you've added it to your toolbar, you can just click on it to run it. The script will copy the UNIX path of whatever you have selected in Finder to the clipboard.

Inspired by a conversation with Alan Boyd.

Bad Behavior has blocked 250 access attempts in the last 7 days.