Archive for the 'Technology' Category

Geotagging Photos With Aperture & QStarz BT-1300S

Thursday, March 11th, 2010

With the release of Aperture 3, geotagging photos is now an integral part of the application’s workflow. Aperture grew the Faces & Places features like iPhotos!

In particular, the Places feature allows you to import GPS data from iPhone photos or from GPS data captured by pretty much any device that can spew a standard GPX format data file.

ImportFromiPhone.png

Tagging from the iPhone is straightforward. With the iPhone connected to your computer, go to Places in Aperture and then select Import from iPhone Photos…. Aperture will then display all the photos on your iPhone that have GPS metadata and you can pick the photos from which the GPS data is to be imported. Once picked, Aperture will apply the GPS data to photos taken near the same time as the imported data.

However, one issue with the iPhone is that it really isn’t a terribly good GPS logging device. Using it as one eats the battery and the data generated often has holes. And, because the iPhone uses A-GPS (GPS assisted by cellular signal), it doesn’t work at all when hiking in areas without cell signal. Apparently, I’m mistaken about A-GPS — it should fall back to regular GPS behavior. My experience, though, is that the iPhone just isn’t a terribly good GPS device when it doesn’t have a cell signal and has often been off by miles when in the hinterlands. It works great when on the road or near cities, though.

Read the rest of this entry »

Review: Celestron Digital Microscope

Wednesday, February 24th, 2010
BloodCells.jpg
Human blood cells

Roger has always excelled in math and sciences — no surprise given lineage — and is of the age (9) where the science education is moving into bigger and smaller areas of study.

So far, he has gotten by with a QX-5 Digital Microscope
and mixScope. While the QX-5 is great for looking at money, the veins in leaves, bits of mushroom and tiny critters, high magnification is pretty much useless because the construction makes focus impossible.

Thus, the desire to get something more like a real microscope. In particular, I really wanted a microscope that allows for live viewing on a computer screen (like the QX-5). While, there were some good ones for less than $500 — 3MP digital camera model microscopes that included simultaneous use binocular eyepieces, even — their software is pile of Windows only crapware.

No, thank you. Next!

SpinalColumn.jpg
Close-up of cross section of spinal column.

Enter the Celestron 44340 LCD Digital LDM Biological Microscope. It replaces the normal eyepiece with a 2.1MP digital camera and a color LCD screen. More importantly, the build quality is actually quite decent such that focusing at, even, the 400x maximum optical zoom is quite smooth!

Unlike the QX-5, the Celestron 44340 is really only for use with proper microscope slides (The QX-5 still has a purpose!). blank microscope slides and slide covers are cheap, so I picked up a bunch of those, too.

The slide table includes a very nice set of caliper style adjusters for moving the slide around in a highly controlled fashion. Slides are held in place by an easy to use spring loaded caliper.

The microscope can illuminate the subject from either the top or bottom and the bottom illumination includes a variety of color filters that can be quite useful. Intensity of illumination can be adjusted.

The top illumination is nearly useless at all but the lowest magnification (otherwise there isn’t enough distance between lens and subject).

The digital controls include an EV adjustment, a digital zoom, and the ability to take snapshots. Digital zoom only works when the snapshot resolution is configured for less than 1600×1200. Digital zoom works by interpolating data across the sensor into a lower-than-sensor resolution image that provides a higher-than-optical zoom factor. It actually works fairly well (unlike most digital zooms).

Pollen.jpg
Pollen. Evil, evil, pollen.

The unit also comes with a really nice hard sided carrying case, a dust cover, and power adaptors for global use. A surprisingly complete kit — I was completely blown away by the quality of the case for a device this relatively inexpensive.

My only real complaint is that the LCD is effectively physically attached to the camera & lenses. That, combined with the relative stiffness of the buttons means it is hard to take an image that isn’t blurry. However, it seems that the unit has a slight delay between button push and recording such that is isn’t as big of a problem as it could be. But, still… stupid design — just move the damned shutter button to the base. I’ll probably hack the unit to add an external shutter button.

All in all, I’m thoroughly impressed by the build quality and feature set of this microscope. I would still have been impressed if my $180 had purchased a microscope with this optical performance, sans awesome case and really nice slide table.

All of the images in this blog post were taken with the microscope, no surprise. It is a boxed set of prepared slides that I also picked up from Amazon.



No, iTunes, I don’t want to listen to holiday music in February….

Monday, February 22nd, 2010

We have a ton of Christmas music — 400 or so tracks, with it growing by about 50-75 tracks each year — that ranges across all genres. It is some awesome stuff; blues, reggae, pop, traditional, you name it…

However, it is music that should only be in the rotation starting December 1st, heavy rotation by about the 15th-20th and then no more from December 26th to the next December 1st.

Of course, iTunes is agnostic and, thus, does not follow my holiday music filtration wishes.

Easy to fix.

  1. On all Christmas/Holiday music, add a grouping of “Holiday” or “Christmas” (or whatever you want).
  2. Create a smart playlist that finds all music in said grouping. Make sure the smart playlist matches unchecked items.
  3. On December 26th, select all, ctrl-click, and select uncheck selection
  4. On Decmber 1st of the next year, select the smart playlist, select all, ctrl-clik, and select check selection

Done. iTunes will not select unchecked songs when constructing genius playlists or when playing through the library on shuffle play. Smart playlists can optionally include checked songs.

Review: Breville Toaster Oven (of awesomeness)

Sunday, February 21st, 2010

I have long wanted a really good toaster oven. One that had decent capacity, was versatile, and insulated such that it doesn’t lose a ton of heat when sticking food into it. As well, I can’t deal with poorly designed products and will often choose dead simple over a full featured item simply because simple is harder to screw up.

After 8 months of research and comparisons, I finally settled on the Breville BOV800XL Smart Oven. It isn’t simple and it certainly isn’t cheap, but the Breville is really quite an excellent piece of technology.

The Breville’s controls are straightforward. You select the mode first, then there are two additional dials that configure, effectively, temperature and time. For toasting, the two additional buttons select slices and darkness; seemingly silly, but it actually works quite well!

As well, the toaster oven has a convection setting and a “frozen” setting that automatically adjusts the cooking times to account for cooking frozen foods. The “frozen” button is the one feature that borders on frivolous gadgetry. Then again, cooking random frozen foods really isn’t a part of our diet. If it was, the adjustment it makes actually does make sense.

The interior capacity is large enough to bake a 13″ pizza or roast a whole chicken (though you might have to cut it into two halves). Combining decent insulation with high wattage, the Breville both heats relatively quickly, holds heat well, and the outside does get warm, but not terribly hot.

When the internal rack is in toasting position, opening the door magnetically slides the rack out a few inches. Very convenient.

All in all, the Breville is a well engineered kitchen tool. It can easily replace your toaster and can often fill in for your full sized oven while both pre-heating more quickly and using less electricity overall. And, of course, the Breville can act as a secondary oven for those times when you need two ovens.

Since the addition of the Breville to our cooking toolset, it sees daily use.



Read the rest of this entry »

objc_msgSend() Tour Part 4: Method Lookup & Some Odds and Ends

Thursday, February 4th, 2010

Table of Contents

  1. objc_msgSend() Tour Part 1: The Road Map
  2. objc_msgSend() Tour Part 2: Setting the Stage
  3. objc_msgSend() Tour Part 3: The Fast Path
  4. objc_msgSend() Tour Part 4: Method Lookup & Some Odds and Ends

In the first three parts, I gave an overview, explained a bit of the ABI used by Objective-C, and took a near instruction by instruction tour of what happens on the fast path of Objective-C method dispatch. By fast path, I mean what happens 99.9% of the time; a very fast, no overhead, no function call, no locking, set of instructions that grabs the method implementation from the cache and does a tail-call jump to that implementation.

The slow path is used rarely. As little as once per unique selector invoked per class with a goal of filling the cache such that the slow path is never used again for that selector/class combination. A handful of operations will cause a class’s cache to be flushed; method swizzling, category loading, and the like.

Note that during +initialize, methods won’t always be cached. Yet another reason to not do any real work during +initialize! Read the rest of this entry »

Using malloc to Debug Memory Misuse in Cocoa

Sunday, January 10th, 2010

Every few months, there is a discussion on cocoa-dev or a question on stackoverflow.com that basically boils down to “I have a leak or over-release and I can’t use Instruments to debug it. Help?”.

Quite often, the questioner can actually use Instruments just fine, but simply lacks the know-how or hasn’t tried in a while and doesn’t realize that Instruments has improved significantly with each release of the developer tools. No, really, Instruments is a fantastic tool and I use it whenever I can; what you see below is for the exceptional case, not the norm.

There are cases where using Instruments is either inconvenient or impractical. Namely, trying to track down an intermittent crasher or trying to gain insight into memory leaks over a long running session will create a prohibitively large dataset for Instruments to process (Instruments allows for much more detailed analysis of the object graph and this analysis loads a lot more data than the tools I’ll demonstrate below).

Thus, it is helpful to be familiar with the rather powerful set of tools available from the command line and within the debugger.

Almost always, you are going to want to enable a bit of additional data via the malloc infrastructure. Have a look at the malloc(3) man page. There is an entire section devoted to ENVIRONMENT variables and there are a handful of extremely useful variables!

First and foremost, you are almost always going to want to use MallocStackLoggingNoCompact. When enabled, malloc stack logging writes the stack trace of every allocation and free event to an efficiently compact binary file in /tmp/ (it used to be in memory and, thus, used to be a great way to exhaust heap. No longer!!). Unfortunately, it doesn’t record the retain and release events, but simply knowing where the object was allocated is generally quite useful (it is generally relatively easy to track down who retained an object once you know which object it is). Under GC, you can set the AUTO_REFERENCE_COUNT_LOGGING and CFRetain/CFRelease events will be logged to the malloc history.

You can then use the malloc_history command line tool to query for all events related to a particular address in memory.

While malloc_history requires that the process still exists, it doesn’t have to be running! If you run your app under gdb, you can still use malloc_history to query the application even when it is stopped in the debugger!

Speaking of gdb, you can use the info malloc command in gdb to query the same information. Under GC, the info gc-roots and info gc-referers commands can be used to interrogate the collector for information about the connectivity of the object graph in your running application.

If you enable zombies via setting the NSZombieEnabled environment variable to YES, the address spewed in the error message when messaging a zombie can be passed directly to malloc_history.

The leaks command line tool scans memory and detects leaks in the form of allocations of memory for which the address to that memory is not stored anywhere else within the application. The leaks tool has been vastly improved in the Snow Leopard release of the Xcode tools; it is much much faster and spits out false positives almost never. It is still possible to have a leak that leaks cannot detect, of course. And, remember, even if you can still reach memory, it is still a total waste if you never use that memory’s contents again!

So, that is a brief summary of the state of command line memory debugging on Mac OS X as of Snow Leopard. Of course, that’s just a bunch of words. How about an example?

Read the rest of this entry »

objc_msgSend() Tour Part 3: The Fast Path

Friday, December 18th, 2009

Table of Contents

  1. objc_msgSend() Tour Part 1: The Road Map
  2. objc_msgSend() Tour Part 2: Setting the Stage
  3. objc_msgSend() Tour Part 3: The Fast Path
  4. objc_msgSend() Tour Part 4: Method Lookup & Some Odds and Ends

In any case, with the foundation set — with the id of the object to be targeted in %rdi and the selector of the method to be invoked in %rsi — we can jump into objc_msgSend() and understand exactly what happens instruction by instruction. Or more specifically, the compiler issues a call into objc_msgSend() (which sets up a stackframe for objc_msgSend() which, through tail call optimization, turns into the stackframe for the called method) and the method implementation that objc_msgSend() jumps to will issue a ret instruction to unwind the stack back to the original caller’s frame.

It is pretty easy to correlate the disassembly with the comments and code in the original source file. However, if you ever need to step through the messenger (si steps by instruction in gdb), this will be easier to follow as this is closer to the reality during a debug session.

For almost all method dispatches, dispatch takes what is called the “fast path”. That is, objc_msgSend() finds the implementation in the method cache and passes control to the implementation. Since this is the most common path, it is a good opportunity to break the tour of objc_msgSend() into two parts; the fast path and the slow path (with administrivia).

Read the rest of this entry »

objc_msgSend() Tour Part 2: Setting the Stage

Friday, December 18th, 2009

Table of Contents

  1. objc_msgSend() Tour Part 1: The Road Map
  2. objc_msgSend() Tour Part 2: Setting the Stage
  3. objc_msgSend() Tour Part 3: The Fast Path
  4. objc_msgSend() Tour Part 4: Method Lookup & Some Odds and Ends

Objective-C is, ultimately, a simple set of extensions to C that provide an object oriented coding and runtime model. Objective-C fully embraces C and leverages the C calling ABI throughout. Every method call is really just a C function call with objc_msgSend() acting as the preamble that figures out exactly which C function — which method — to call!

Thus, it is helpful to understand how objc_msgSend() is called and how that relates to C. That is, how does the compiler translate [someObject doSomething: 0x2a] into a call.

What follows is a bit of code that makes a [totally bogus] simple method call followed by the assembly generated.

Code:
@interface NSObject(foo)
- (id) doSomething: (NSUInteger) index;
@end
...
    NSObject *b;
    NSArray *a;
    b = [a doSomething: 0x2a]; // line 11
Assembly:
    .loc 1 11 0
    movq	-16(%rbp), %rdi
    movq	L_OBJC_SELECTOR_REFERENCES_0(%rip), %rsi
    movl	$42, %edx
    call	_objc_msgSend
    movq	%rax, -8(%rbp)

Read the rest of this entry »

objc_msgSend() Tour Part 1: The Road Map

Friday, December 18th, 2009

What follows (across this and 3 more posts, maybe more) is a rather detailed tour of objc_msgSend() as implemented in Mac OS X 10.6.2. Rather detailed in that every instruction will be explained. Even though it is relatively few instructions, there is a considerable amount of background information that is helpful to understanding the objc_msgSend() instruction stream.

The motivation behind these posts is entirely selfish. I find the best way for me to learn something is to know it well enough to be able to explain any detail to a room full of folks in full-blown student mode.

Table of Contents

  1. objc_msgSend() Tour Part 1: The Road Map
  2. objc_msgSend() Tour Part 2: Setting the Stage
  3. objc_msgSend() Tour Part 3: The Fast Path
  4. objc_msgSend() Tour Part 4: Method Lookup & Some Odds and Ends

Read the rest of this entry »

Uncharted 2; Brilliant, Marred by Intermittent Lockup/Freezes

Sunday, November 29th, 2009

I have recently been playing through Uncharted 2: Among Thieves
after having played through the utterly brilliant Uncharted: Drake’s Fortune
.

Absolutely genius game. Personally, I have always hated tracked games; games that have a single story line that you follow along, with little to no bifurcation. Yet, Uncharted 1/2 both do such a good job of telling a compelling story that I’m having a total blast. The voice acting and character animation are top notch.

It is as if you are playing along an interactive movie. Where you do get to make all the decisions is in how you approach any given battle; …go stealth or go in with guns a-blazing? …AK-47 with hundreds of round, a sniper rifle that’ll one-shot-kill, but requires precise aim, or a shotgun that requires close range & is devastating? …sneak around and take out the gunner’s nest from behind or try and lob a grenade?

The one problem though, is that the game freezes about once every hour to hour and a half of play. It may be a thermal issue (though I’m playing in a relatively chill room and the PS3 has excellent ventilation), but the symptoms are slightly odd. The music keeps playing, but all graphics and controls are dead. Upon restart, you find yourself just beyond where the freeze occurred, as if the game detected the freeze and moved you to just beyond the point where it happened. If true, this is welcome, but it sometimes means that you are in a tight spot with no appropriate weapons.

And I’m not the only one. Looking at this google search, I see hundreds of reports of the same behavior.

Some see the freeze occur more often than others (and I suspect some are thermal issues, from the descriptions). The problems aren’t limited to any particular model of PS3, either (I’m on a 120GB Slim, being the cheap bastard that I am).

Others have reported no problems at all.

I wish there were some means of reporting bugs and/or tracking issues like these.

While annoying, this isn’t a catastrophic bug (at least not for me — it doesn’t happen that often) to the point of making me regret the purchase. Total a worthy and awesome game to play through!