Thursday, March 8, 2012

Disable Mac Mail.app inline attachments via micahgilman.com

Just what I needed.
Helps improve compatibility with less leet email clients. I also find it less annoying.

http://micahgilman.com/play/disable-mac-mailapp-inline-image-attachments/

Monday, March 5, 2012

Space Saving Standing Desk

Standing desks (or stand-up desks) are all the rage these days with nerds and geeks. This has quickly become a thing. It seems everyone is doing it, even a few guys in the cubes at work.

Some hardcore Mac hackers are even building their own treadmill desks!
This wave piqued my interest momentarily -- then I remembered I liked the fact that I have a job where I can sit.

So how did a squatter end up doing this project? Necessity. You see, last year we welcomed our first born :) Little Sofie is, well, little. But, she requires a whole lot of space. Crib, closet, toys, etc. We had a tiny second bedroom that was pulling double duty as a guest room and office. To woo guests for longer stays, (read: helpful grandmas), I decided to take my desk apart and put in a larger and more comfortable guest bed. This was a good decision. I sold my desktop computers and bought the fastest MacBook Air Apple would sell me. "I don't need a desk", I told my worried wife.

After a couple of months, I really started to miss my desk. Sitting on the couch I'd easily get distracted and couldn't work on projects effectively. I hit IKEA in search of a solution. The small desks weren't small enough, but I came across a wall-mounted standing desk. At once I remembered the standing thing that the cool geeks (?) were doing.

I was lucky and a couple more synapses fired. "I can make my own!" We already had a little pine bookshelf set up on an awkwardly-angled wall. I cleared off the top shelf and was glad to see my laptop screen was at a great height. The problem was the keyboard. It was impossible to touch-type comfortably. The first shelf was too low for a separate keyboard, so I rearranged the books and precariously laid a full-size keyboard and mouse pad across the top. This worked well enough until I could come up with a permanent solution.

I needed a slide-out keyboard tray at the right height that I could tuck away when not in use. Everything I came across was either ugly, flimsy, or both. Even more troublesome was the fact that they were all designed to be mounted under a desk -- I needed side mounting. Time to get a bit more creative. The nicer keyboard trays had ball-bearing sliders. A-ha!!

tl;dr (What you'll need)

Materials
- Bookshelf that is deep enough to accommodate your computer setup of choice. It should also be tall enough so that you aren't straining your neck when standing. You have wiggle room here as there are plenty of great looking laptop stands.

- Heavy duty, side mount, ball-bearing drawer slides. Don't cheap out here. This is the key to a solid and smooth operating keyboard and mouse tray. I found some awesome 100 lb rated Gliderite side mount slides on eBay. Collapsed they are only 10" long, but telescope to 20.5". They are only 1/2" thick, so you'll be able to maximize the size of the tray.

- Wood board to use as desktop and mouse tray.

Tools
- Drill
- Level. I used the awesome iHandyLevel
- 4 Large wood clamps with strong springs.
- Small wood screws if your drawer slides don't come with hardware -- mind did.

Process
- Make sure you cut only enough material so that your board + 2 drawer slides fit snugly inside the bookcase. Measure three times, 'cause only real builders can get away with measuring twice.

- Determine the height you want for the tray. I wanted something comfortable that still allowed books to fit underneath. Use your four large clamps on the sides of the bookshelf to rest the tray and dial in the height.

- Once you have the height dialed in, make sure everything is nice and level. Having strong springs on the clamps makes it easy to make tiny adjustments and not worry about them getting knocked loose.

- Remove the slides from the outer guides and use a marker to line up the holes on the bookcase. Do the same with the slides on your tray. I drilled tiny pilot holes to make sure the tray didn't crack.

- Screw in the hardware, and insert the tray + slides into the mounted channels.

- If you are really into looks, you'll want to sand and stain the tray, I just sanded the edge to make it comfy for my wrists.

Total time: ~3 hours.
Cost: 15 dollars for the high-end slides, another 15 for the pine board. I already owned the rest.

Standing Desk: Leveling drawer slidesStanding Desk: Tools usedHideaway keyboard and mouse tray closeupStanding Desk: RetractedStanding Desk: Tray Extended


Standing Desk on Flickr.

Saturday, August 13, 2011

VirtualBox: Mac OS X 10.5.8 Guest on Mac host with Core i7 processor

The Leopard 10.5.0 Retail DVD booted and installed perfectly using VirtualBox 4.0.12 on my MacBook Air. After applying the 10.5.8 combo updater, unfortunately, the VM would kernel panic while booting. The culprit was the AppleIntelCPUPowerManagement.kext. The 10.5.8 kext doesn't seem compatible with Core iX processors.

The solution is pretty simple, and clears up another well-known problem as well: 100% usage of one core at all times:

1) Boot the VM using the 10.5 Retail DVD and launch Terminal
2) Delete the offending kext:
rm -rf /System/Library/Extensions/AppleIntelCPUPowerManagement.kext
3) Reboot and enjoy!

The post that tipped me off to this solution also suggested installing a dummy kext, however I could not locate a 10.5.8 compatible NullCPUPowerManagement.kext. I skipped that and have not noticed any ill effects.

Wednesday, August 3, 2011

Detecting Plugin Functions and Properties in JavaScript

Peter Michaux's feature detection article really saved my bacon.

I recently had to debug some IE 7 ++ bugs in our JavaScript API. I found some crusty functions that were supposed to determine if a function or property exists on a loaded plugin object (ActiveX in IE, NPAPI otherwise). The functions were returning a false negative in IE 7 or newer unless users turned on compatibility mode.

Since we already had Prototype as a requirement, I figured I'd use their isFunction. The logic worked fine on browsers other than IE :(

Logically, all the well-known JavaScript frameworks' implementations of isFunction are highly optimized and may not work as expected with bipolar JavaScript host objects (e.g. plugins, window, document, alert), at least on IE.

Michaux's approach was clean and worked consistently for our needs across all our supported browsers. Note: I never saw the "else" code path exercised, but left it in.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* Check to see if a property (function or field) is defined for the given object.
 * This function is reliable for native and host objects.
 * @param object {Object} - the object to test.
 * @param propertyName {String} - name of the property to test.
 * @type Boolean
 * @return true - if property is defined,  False otherwise.
 */
 _propertyExists: function( object, property ) {
        //tweaked version of Michaux's detection function:
        //http://peter.michaux.ca/articles/feature-detection-state-of-the-art-browser-scripting
        var isProperty = false;
        var theType = typeof object[property];
        if( theType != 'undefined' ) {
            isProperty = true;
        }
        else {
            try {
                // This test would error for ActiveX but
                // those test will have returned above 
                // because typeof result will have been 
                // 'unknown'.
                if( object[property] ) {
                    isProperty = true;
                }
            }
            catch (e) {}
        }
        return isProperty;
 },