Mon 27 Jun 2011

Logging idle time in Firefox

This will log idle events and back events into the Web Console in Firefox. Useful if you're trying to figure out why your idle timer isn't firing when you expect it to.

var idleObserver = {
  observe: function(subject, topic, data) {
    console.log(topic + " " + subject.idleTime);
  }
};
            
var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
                    .getService(Components.interfaces.nsIIdleService);
idleService.addIdleObserver(idleObserver, 10);

Posted at 2011-06-27 13:37:00 by Richard NewmanLink to Logging idle time …

Sun 22 Aug 2010

Two houseguests

Our new house is home to somewhat fewer deadly spiders than our last (I killed one or two widows each week during the summer). That's not to say it's spider-free: I've been keeping an eye on these two little fellows.

The first has an elaborate funnel in the decorative stonework near our mailbox. He or she is there pretty much all the time, rarely retreating. This is Agelenopsis aperta, variously known as the desert grass spider or the North American funnel-web spider. I think its venom is a mild necrotic, causing lesions, but not really harmful to adult humans.

The second has a large flat web and a funnel, in the corner by our garage door. She's very shy, usually dashing away as I return from walking the dog; last night she stayed put for several visits, so I took some pictures. Other spiders were around her web, apparently un-eaten! This is Tegeneria domestica, the barn funnel weaver, and a relative of the hobo spider. It hunts, it's aggressive, and its venom is neuro- and necrotoxic. Fortunately, it's nowhere near as bad as a brown recluse or a hobo spider, and it competes with the latter, so she can stay for now!

As you can see, I've become a lot more tolerant of spiders in recent years!

Posted at 2010-08-22 14:21:00 by Richard NewmanLink to Two houseguests

Wed 30 Jun 2010

Harry's pistol in Button Man

A great old graphic novel, which I'm sure will eventually reach the screen. But what pistol does Harry use throughout?

For the curious Googlers out there: it looks like a Smith & Wesson model 4605 with adjustable sights (though in some panels it seems to have fixed sights).

In a few places it looks more compact at the business end, which suggests that the smaller 4006 might have filled in as a model when necessary, but in general the 4605 looks like the one.

The 4606 has an eight-round magazine, which fits with the story. I'll bet Harry's as deaf as a post after emptying all that .45 brass!

Posted at 2010-06-30 22:35:00 by Richard NewmanLink to Harry's pistol in …

Sun 23 May 2010

Optimization without profiling

Seventh Generation dishwashing liquid claims that if every household in the US switched from a bottle of petroleum-based 25oz dishwashing liquid to their product, we'd save 81,000 barrels of oil each year.

The United States consumes approximately 21 million barrels of oil per day.

Put another way: if Seventh Generation were to achieve 100% market penetration, they would reduce US oil consumption by 0.001%.

By contrast, half-time teleworking would save 453 million barrels per year. (I don't know the answer to the question ‘half of what?’ — this is just for the sake of illustration.)

That's a much more significant sum — nearly 6% of the US's total oil consumption goes on schlepping a bunch of people to and from work.

I'd go so far as to guess that any oil savings from their products fail to offset even Seventh Generation's business operations: commuting workers, product transport, heating and lighting, and manufacturing. Hell, if you have to drive to a different store to buy the damn thing you've had a net negative effect on oil consumption!

Either Seventh Generation is being deliberately disingenuous in their marketing, or they haven't done the calculations to discover the real impact. I'm betting on both. Still, this is an interesting case study in how bad humans are at picking their battles, and how vulnerable consumers are to irrational arguments: nobody rational would ever think that developing and marketing a non-petroleum dishwashing liquid (in a plastic bottle!) was worthwhile.

Posted at 2010-05-23 10:32:00 by Richard NewmanLink to Optimization witho…

Thu 13 May 2010

Software with Heart

Reading this blog post reminded me of something.

About 5 years ago (5 years!) I bought a Samsung D500. Although I ended up returning it, I still remember the very satisfying slide action, and the pleasant tones of the keypad. (Hey, remember when phones had numeric keypads?)

I'm not sure which is more significant: that I still think fondly of a small chunk of plastic, just because it was a really enjoyable phone to use, or the fact that I returned it because it didn't do enough.

Posted at 2010-05-13 17:49:00 by Richard NewmanLink to Software with Hear…

Thu 11 Mar 2010

Strip class files from a Java jar

I occasionally hit an issue whereby a Clojure library is built with an earlier version of Clojure, and its included class files cause an error such as

Caused by: java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (compojure.clj:9)

The easiest immediate fix is to strip class file from the jar. Awful hacky shell scripting to the rescue! This did the trick. It ain't pretty, but hey.

mkdir $1-tmp
mv $1 $1-tmp
cd $1-tmp
jar xf $1
find . -name '*.class' -exec rm {} ;
jar cf $1 *
mv $1 ..
cd ..
rm -r $1-tmp

Use like this: unclassify foo.jar.

Posted at 2010-03-11 13:27:00 by Richard NewmanLink to Strip class files …

Tue 26 Jan 2010

Small flashlights

On a whim I ordered a Leatherman Monarch 200 flashlight. For $10 I thought it was worth a try.

I normally carry a 4Sevens Quark 123, or a small Preon, but I like to have lights everywhere. Comes in handy when the power goes out!

Here's how it stacks up against the Fenix E01 ($12.50) and the Lummi Wee, which cost me about £50 all told (it has tritium phials).

The E01 is slightly brighter, and the Leatherman is much bluer in color. (My “natural” LED lights are even less blue.) The Lummi Wee, as you might expect from a high-output light that uses boutique batteries, kicks out a lot more light.

However, I'm not disappointed: the Monarch is tiny, has a clicky tailcap (which is both easy to use and hard to accidentally depress: much better in my opinion than twist activation), seems pretty robust, and costs no more than a Photon. This one is going on the wife's keychain, and I might order another to stash in a bag…

Posted at 2010-01-26 17:33:26 by Richard NewmanLink to Small flashlights

Sat 23 Jan 2010

Damn you, Mail

Mail.app is so classy. This is in my console log.

2010-01-23 Jan 23 19:55:40  Mail[1749] 
An instance 0x1cfa80f0 of class IMAPConnection is
being deallocated while key value observers are 
still registered with it. Observation info is 
being leaked, and may even become mistakenly 
attached to some other object. Set a breakpoint 
on NSKVODeallocateBreak to stop here in the 
debugger. Here's the current observation info:
<NSKeyValueObservationInfo 0x39ea320> (
<NSKeyValueObservance 0x4e328d0: Observer: 
0x16a80a60, Key path: isDisconnected, Options:
<New: NO, Old: NO, Prior: NO> Context: 0x0,
Property: 0x1b0c0040>
)

Posted at 2010-01-23 20:58:00 by Richard NewmanLink to Damn you, Mail