08 Apr 2006 09:42

Migrated to Typo

If you're reading this, you're looking at the old blosxom blog which I keep alive to serve requests starting with http://hans.fugal.net/yodl/blosxom.cgi. That url has been deprecated for quite some time, but I see references to it on Google all the time, so I'm leaving it up. The new blog is based on Typo and can be found at http://hans.fugal.net/blog just as before.

If your bookmark or feed link has "yodl" anywhere in it, it's time to fix that.

31 Mar 2006 09:50

Building QCad with GCC 4

QCad is a really nifty open-source 2D CAD program for POSIX systems. They don't distribute free binaries, though, so you have to build it yourself.

There's two catches when building. First is trying to figure out where to start. It looks to me like this is the starting point:

cd scripts
./build_qcad.sh notrans

The second catch is if you get an error about ISO C++ and 'long long'. This actually applies to Qt in general, but I know that my Qt build environment is fine so I was a little confused. Turns out that the -pedantic compiler flag is what brings this error to the surface. So this patch will fix your QCad build:

--- qcad-2.0.5.0-1-community.src/mkspecs/defs.pro.orig  2006-03-31 09:12:28.000000000 -0700
+++ qcad-2.0.5.0-1-community.src/mkspecs/defs.pro       2006-03-31 09:07:55.000000000 -0700
@@ -1,6 +1,6 @@
# $Id: defs.pro 606 2004-12-25 03:08:40Z andrew $
-QMAKE_CXXFLAGS_DEBUG += -pedantic
-QMAKE_CXXFLAGS += -pedantic
+#QMAKE_CXXFLAGS_DEBUG += -pedantic
+#QMAKE_CXXFLAGS += -pedantic

win32 {
QMAKE_CFLAGS_THREAD -= -mthreads

What do I need QCad for? I'm designing two Really Neat™ DIY projects: a keyboard stand and a compact against-the-wall under-the-keyboard music stand. If that piqued your interest, stay tuned. If it didn't, well I'm sorry for you.

29 Mar 2006 10:18

Prepend the Area Code with Asterisk

If you want to prefix the area code for 7-digit numbers with Asterisk, it usually looks like something like this:

ext => _NXXXXXX,1,goto(505${EXTEN},1)

But if you need to server all area codes dynamically, you can do something like this:

ext => _NXXXXXX,1,goto(${CALLERID(number):0:3}${EXTEN},1)

This assumes caller id is set, and that your callers are using standard PSTN-like DIDs.

17 Mar 2006 15:55

No-knead Sourdough Bread

Over at r.f.s people have been experimenting with making bread with minimal kneading. This is right up my alley, I thought, so I gave it a few tries. It works astonishingly well.

The basic idea is that gluten development is a hydration process. When you knead a dough, you are working in the water and possibly creating little air bubbles. If you leave a ball of dough long enough, the water will work itself in. I know you don't believe me, but it's the truth. In my experience the loaves I make are plenty fluffy - more fluffy than when I knead - so I don't think the air bubbles part is an issue. You be the judge.

So the goal is to let water do the hard work over time. With normal bread, this poses a challenge in that you can't leave the yeasted dough a few more hours without ruining things. With normal bread, people do things with part of the flour and water beforehand and then mix in the rest and the yeast later, etc. etc. I'm no expert on what they do, and frankly it's too complicated. We don't have that problem because sourdough is naturally slower and gives us sufficient time.

Here's what I do. Let's say I want to bake on Saturday morning, and I plan on getting 6-8 hours of sleep. 6-8 hours is a nice rise time for chilled sourdough so I prep the starter so it's nice and active when I get home from work, then I mix up the dough and put it in the fridge. I take it out of the fridge after a few hours, just before bed, and form it into a loaf. I place it under a plastic container (I call it the greenhouse, because that's basically what it does: keep in moisture and heat) and go to bed. In the morning, unless something has gone drastically wrong, it's ready to pop in the oven and bake.

So let's review:

  • mix
  • rest
  • bake

And now some more ramblings about the boring details. You do need to mix it to get the water distributed, and maybe there's some air bubble action going on there too. But you don't have to use your hard-to-clean mixer or get your hands dirty. Mix all the ingredients, including salt.

If you want to deflate or knead or stretch and fold during the rest phase, by all means have at it. Remember that even with sourdough you can only rest so long before the yeast eats all its food. Chilling retards this.

For those of you who like recipes:

No-knead Sourdough Bread (small loaf)

  - 200 g    active 100% hydration starter
  - 125 ml   water
  - 174 g    flour
  -   1 tsp  salt
  -   1 Tbsp oil
  -   1 Tbsp honey

Mix well. Let rest for 1.5 hours at room temperature, or up to 24 hours in
the fridge. Deflate/work it mildly and halfheartedly, then form into a loaf
and rise in a humid (and preferably warm) environment until ready to bake
(use the finger test). Bake in a cold-start oven at 400 degrees for 20
minutes, then at 350 degrees until internal temperature reaches the boiling
point. (You do have a probe thermometer, don't you?) Turn off the heat and
let it bake another 5 minutes and then take it out of the oven and let it
cool thoroughly for best flavor. If you can't hold off the ravening butter
slatherers, don't blame me.

15 Mar 2006 23:46

Atom Feed

So Blosxom spits out an RSS 0.91 feed by default, which is fairly despicable. For one thing RSS 0.91 doesn't allow for attaching dates to posts. So I grabbed an atom feed template. Now if you want a decent feed you can point your feed reader at http://hans.fugal.net/blog/index.atom.

13 Mar 2006 09:57

pack and unpack broken on Tiger's Ruby

Imagine my surprise when my iBook told me that network byte order had been changed to little-endian:

irb(main):001:0> [1].pack 'n'
=> "\001\000"

Just to make sure I wasn't losing my edge, I ran the same code on my x86 box:

irb(main):001:0> [1].pack 'n'
=> "\000\001"

Array#pack (and String#unpack) are broken on OS X Tiger's shipped Ruby. After some research, it appears the reason is that they cross compiled it from x86, and when built Ruby remembers the architecture for the purposes of the NnVv formatters of pack/unpack. The purported remedy is to build your own Ruby. I reported the bug to Apple, I have a small hope that eventually they'll update it. In the meantime ruby programs using pack can either work around this or require users to install a fixed Ruby.

Update: Here's a workaround with thanks to Paul Battley:

# Test for broken pack/unpack
if [1].pack('n') == "\001\000"
  class String
    alias_method :broken_unpack, :unpack
    def unpack(spec)
      broken_unpack(spec.tr("nNvV","vVnN"))
    end
  end
  class Array
    alias_method :broken_pack, :pack
    def pack(spec)
      broken_pack(spec.tr("nNvV","vVnN"))
    end
  end
end

24 Feb 2006 13:14

Camping Logmarks

I quickly ran some unscientific bench^Wlogmarks (3 or 4 samples after stabilization at the CLI with my friend time) for camping vs. just erb/cgi vs. just markaby vs. my current blosxom blog (with 10 entries):

time ruby -rrubygems -e "require 'camping'"  # about 0.5 seconds
time ruby -rcgi -rerb -e ""                  # about 0.05 seconds
time ruby -rrubygems -e "require 'markaby'"  # about 0.2 seconds
time blosxom.cgi >/dev/null                  # just under 0.3 sec
time fugue.rb >/dev/null                     # just over 1 sec

The blosxom and fugue runs dealt with the same 10 posts and produce almost to the angle-bracket the same HTML. It looks like to me that I should think about doing my super-simple blog without the overhead of a framework, even one as small as camping, and go with straight markaby or erb for the template.

Camping does fine once it's loaded, but I don't really want 20 megabytes of virtual memory being wasted just so the 5 people out there reading my blog can get it in less than two seconds. As it is I'm trying to find ways to prune rails/apache/etc. memory usage. I think I have an idea, too.

So apparently a lot of this time is startup time, but a lot of the time this startup stuff is the same over and over. I started thinking about one master process that somehow subthreads the rails/camping sites, but that gets messy and who knows when a global variable or some other rogue will really mess things up. Not to mention environment. But wait, I don't care about memory usage when it's actually doing something - it's the perpetual waste of RAM that I'm concerned about. Why don't I have N bootstrap processes that have done the equivalent of require 'rails' or require 'camping' and are ready to load the appropriate ruby script on-demand and then die gracefully after the page is served. I get precise control over how many processes are hanging around, the wasted RAM between requests is much less per lingering process than with a full-blown fastcgi app, and you get fast service.

Well, there's at least one problem: most page loads will have a bunch of requests all at once, so maybe it would be better to have the bootstrap process load up a fastcgi process that can serve the rest of the requests and die after a few seconds of idle time.

If you have thoughts on this scheme, let me know. Yeah, I know I don't have comments, so you'll have to do it the old-fashioned way. If my subconcious doesn't churn something up in the next few days/weeks I might just whip it up.

24 Feb 2006 07:48

Camping

I whipped up my own replacement to "my blosxom" tonight using camping. It was fun and frustrating, as it always is when working with both ruby and html. It's a little slow, unfortunately, I'll have to profile where the time is. I hope I won't have to run yet another FastCGI process, I don't have the RAM for that. Hopefully some filesystem and pagination optimizations will do the trick.

Pagination was the whole point of moving away from what was already working, and a desire to escape from school and work for just a bit and do something pointless. Learning camping seemed good, because it can be even easier to whip up something small in camping than in rails.

Yeah, it's not exactly working yet. e.g. permalinks and category links don't work. I'll get to it.

Update: After sleeping on it I switched back to blosxom until I get the time to polish up the camping version.

17 Feb 2006 08:26

Openbox

Openbox 3 is a pretty nifty window manager. What I like about it is that it is simple, has a powerful but simple configuration (even if it is XML), ICCCM and EWMH compliant, and works well in Gnome.

Now that I can dual-boot my iBook without the bother of a USB wireless card, I took a few minutes to set up my desktop environment. I used to periodically spend way too much time doing this. I was always on a quest for the best window manager and desktop systems, and I mostly steered clear of Gnome and KDE. Maybe I'm getting boring, but my list of must-haves for window managers has shrunk recently (maybe I should blame OS X). As I'm no longer the primary user on falcon (my wife is), we've been running Gnome there for awhile, and I've gotten used to it for casual usage. I used it for a few months at my last job too, and with a decent window manager (I used FVWM then) it can be quite nice.

So openbox easily displaces metacity with a simple openbox --replace and saving the session. Once you find a theme that doesn't use itsy bitsy fonts it looks fine too (I like the Serenity theme, although the colors are a bit off).

Openbox has the *box feature I love dearly: the dock. gkrellm -w and WindowMaker dockapps I love dearly.

The keybindings and actions are not quite as rich as FVWM, but still quite good. On the other hand it does do MRU-style window switching (e.g. alt-tab), which is a feature mysteriously missing from FVWM.

Here is my ~/.config/openbox/rc.xml file. It matches the OS X keybindings I use most, and some others I made up which have proved quite useful in the past. Here's a preview (mentally replace cmd with meta or win, as appropriate):

  • cmd-m to minimize (cmd-h doesn't offer anything more in the Gnome desktop, which is good because vi key emulation always trumps)
  • cmd-w to close
  • cmd-q to kill (use sparingly, this isn't quite the same as cmd-q in OS X)
  • cmd-tab and s-cmd-tab (in addition to the more windows-like alt-tab and s-alt-tab)
  • cmd-[hjkl] navigates desktops
  • c-cmd-[hjkl] maximizes vertically or horizontally
  • s-cmd-[hjkl] moves the window in that direction to the nearest edge. Openbox is the first WM I've seen with this action, and I anticipate that it will be very useful.
  • cmd-t to spawn an xterm
  • cmd-(up|down) to raise/lower a window

15 Feb 2006 22:26

Airport Extreme in Linux

I am writing this blog entry from my iBook G4 with a wireless connection from Linux, with no external wireless device. That's right, you heard me correctly.

The Broadcom 43xx Linux Driver has made this possible. See this LWN article for a good starting place.

I stubbornly compile my own kernel so it wasn't as simple as installing bcm43xx-modules-2.6.15, but with module-assistant it wasn't hard either. The only trick was knowing to compile the softmac module and install its headers. Something like this should work:

apt-get install bcm43xx-source dpatch
m-a -t a-i ieee80211softmac
dpkg -i /usr/src/ieee80211softmac-headers*deb
m-a -t a-i bcm43xx
modprobe ieee80211_crypt_wep
modprobe bcm43xx
ip link set up eth1
iwconfig eth1 channel 1 essid fugal key restricted yourkeyhere
udhcpc -i eth1

It's still in the not-for-the-weak-of-heart stage, but it seems to work well to me.