Quantcast

A ramp for Mom!



A ramp for Mom!, originally uploaded by tiki.robot.

-raj

How to run lighttpd under upstart

Upstart is Ubuntu’s init.d replacement. It greatly simplifies writing init.d scripts and has a great respawn feature similar to daemontool’s supervise or monit. And it comes with Ubuntu by default.

For some reason, almost no one uses upstart. Even Ubuntu’s services use traditional /etc/init.d scripts instead of upstart scripts. I think this might be due to upstart’s non-existent documentation. There is no man page for upstart, and multiple people I know who have read the online docs somehow missed the three important commands that control upstart jobs: /sbin/start, /sbin/stop, and /sbin/status!

Here is how it works: put an upstart script in /etc/event.d. Let’s call it /etc/event.d/foo. This script is now immediately available under upstart. Just type sudo start foo. That’s it.

I converted Ubuntu’s /etc/init.d/lighttpd script to a much shorter upstart script. The big advantage of this is upstart will restart lighttpd if it dies for some reason. This is what the upstart script looks like:

#this is an upstart script that  starts lighttpd
 
start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5
 
stop on runlevel 0
stop on runlevel 1
stop on runlevel 6
 
respawn
exec sudo -u www-data lighttpd -D -f /etc/lighttpd/lighttpd-infobase.conf

That’s it! Save this script as /etc/event.d/OL-lighttpd, and then type sudo start OL-lighttpd. You can kill off the lighttpd process and it will get restarted.

If you want to configure your lighttpd to write out a pid file, you can use pre-start and post-stop script to prepare and clean up the pid file:

#this is an upstart script that  starts lighttpd
 
start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5
 
stop on runlevel 0
stop on runlevel 1
stop on runlevel 6
 
 
pre-start script
    #make sure there is a place to write the pid file (optional):
    mkdir -p /var/run/lighttpd > /dev/null 2> /dev/null
    chown www-data:www-data /var/run/lighttpd
    chmod 0750 /var/run/lighttpd
end script
 
respawn
exec sudo -u www-data lighttpd -D -f /etc/lighttpd/lighttpd-infobase.conf
 
post-stop script
    #remove pid file (optional)
    #add server.pid-file = "/var/run/lighttpd/lighttpd.pid" to lighttpd.conf file to have it generate the pid file
    rm -f /var/run/lighttpd/lighttpd.pid
end script

If you want to stop lighttpd, just type sudo stop OL-lighttpd. You can also type sudo initctl list for a list of all jobs under upstart.

How to get your Mac to output 24p to a Samsung LN46a650

I hooked up my first-generation MacBook Pro to my Samsung LCD TV with a DVI->HDMI cable. The mac was able to output 1920×1080p at 60Hz to the TV. There was noticeable judder when trying to view 24fps content. I searched the net and no one seems to have gotten their mac to output 24p to their Samsung TV.

OK, here is how to get your mac to output 24p to your Samsung series 6 (or higher) TV:

  1. Connect your mac to your tv with a DVI->HDMI cable
  2. Install SwitchResX, which will let you customize display settings on your mac.
  3. Launch SwitchResX and create a custom resolution, using the settings below.
  4. Reboot your mac.
  5. Launch SwitchResX again and confirm that the new 1080p24 setting is available.
  6. Activate it and rejoice!

Here are the setting I used, which might still need a bit of tweeking. I’m still trying to get the vertical refresh to be exactly 23.976Hz. I cribbed from these settings that are known to work for a sony bravia. The judder seems gone, but I still see some occasional choppy playback, I think due to dropped frames during h.264 decode. I’ll investigate further.

macbook24psettings

I’m mostly happy with my new TV (in true redneck fashion, I traded my pickup truck for it). I originally got a Series 5, but It could only do 1080p60, and I really wanted 1080p24, so I had to upgrade to the Series 6. Unfortunately, the Series 6 arrived with a dead pixel. I don’t know what to do about that..

How To Replace The Gas Coils In A Clothes Dryer

IMG_5516Our Frigidaire gas dryer broke! It seemed to be working properly except it produced no heat. Replacing the gas coils for the solenoid valves fixed the problem. Here is a guide on how to replace the gas coils in your dryer:

Our Frigidaire dryer is model GLGQ332A, and is manufactured by Electrolux. The parts catalog shows where the solenoid valves are and which replacement coils to buy. Since the primary and secondary coils are sold together, I replaced them both without actually troubleshooting which part was bad. I needed parts 71 and 72 (part numbers 5303307291 and 5303307292). I got replacement kit 5303931775 (which contains both coils) from Reliable Parts in SF (on Howard and 12th) for $37. This same package is available for $10 online, but I paid extra so I could get the parts the same day.

OK. Let’s get started. First step is to UNPLUG YOUR DRYER.

Next, we are going to lift the top up. There are two clips in the front of the dryer holding the top on, and two hinges on the back. Use a putty knife to press the clips in so the top pops off. Here is how to detatch the clip on the left:

IMG_5520

This is what the clip looks like when popped off:
IMG_5522IMG_5523

Now lift the top up and look on the right side, near the timer. You should see a 9-pin molex connector, which you need to detatch. To make my life easier, I always use a sharpie to mark the connector direction. There is a zip tie holding the wires to the frame of the dryer. You are going to take the front of the dryer off, so you will have to cut this ziptie.

IMG_5537

Now we are going to take the front of the dryer off. There is a screw on each side of the dryer holding the front on, and there also a few clips. This picture shows both a screw and a clip on the left side:

IMG_5528

I think there were three clips on the left and two on the right. You can get them off by pushing up on them and pulling the front out. They are kind of a pain to get off. Since they are designed to snap under force, I think repair guys just yank the front off and then replace them with new ones.

Once all the screws and clips are out, you will be able to pull the front off. Pull the top part of the front towards you and the front will disengage from the tumbler. There are two clips on the bottom. Lift the front off of these clips:

IMG_5544

Set the front aside. You can take this opportunity to clean out any lint stuck in the lint chute, seen here in the lower left:

IMG_5542

This is what the inside of your dryer looks like:

IMG_5545

The gas valves are on the lower left:

IMG_5547

Unscrew and remove the metal cover holding the coils in place:

IMG_5549

Now lift the coils off of the solenoid shafts, unclip the connectors, and put the new ones in place:

IMG_5550

You are now ready put everything back together. Hopefully your dryer now has heat!

If you want to be more rigorous, here are some resistance measurements I made on the new coils. Supposedly you can tell which coil is bad if the resistance measurement is different, but my old, bad coils seemed to have similar resistance:

IMG_5556IMG_5557IMG_5558

Nine Steps to setting up a Wordpress blog

I just finished setting up the RanCH bLoG and am getting pretty good at setting up WordPress. Here are the steps I take after installing a new WordPress 2.7 blog:

  1. Enable Archival-style permalinks. In settings -> permalinks choose “Day and name”.
  2. Add a .htaccess file to make permalinks work. WordPress will try to do this for you when you enable permalinks, but might not be able to write to the root dir of your blog.
  3. Disable “Comment author must have a previously approved comment” in settings -> discussion, so you don’t have to keep watching over your comments.
  4. Enable the Akismet plugin, to block spam. You will have to create a free wordpress.com account to get an API key.
  5. Install the reCAPTCHA plugin, to block more spam. You will need to create a free recaptcha.net account to get an API key.
  6. Install a GPL-compatible theme.
  7. Add sidebar widgets in appearance -> widgets. I always add the Recent Comments, Categories, Tag Cloud, and Search widgets.
  8. Replace any boilerplate text in the theme. Hopefully this can be done by replacing the boilerplate area with a text widget, but you might have to update your theme’s php files.
  9. Update the blogroll with links to your friends.

Maybe one of these days I will follow my own advice and update this blog to a modern theme.

How To Filter San Francisco Tap Water

Background
Our water has gunk in it (possibly due to this construction). This gunk gets caught in our kitchen faucet’s aerator, and if we don’t clean it out, the water flow will stop completely. Here is what the gunk looks like:

a1.jpg

So we decided it was time to install a water filter. The easiest way to filter drinking water is to use a Britta and Pur pitcher, but these don’t work for me. I use them for a bit, and then get tired of changing the expensive replacement filters every month.

The water filter industry has a standard size for under-sink adsorption filters: 9 3/4″. These filters are similar to but much larger than the standard Britta pitcher-style filter, and they only need to be changed every 4-12 months (depending on filter type). You can buy 9 3/4″ filters from several different manufacturers, which helps keep the prices down.

Choosing a Filter

Deciding what kind of filter you need should be easy. In theory, you can call your water utility (or check their website), find out what contaminants are in your water, and then check which filters are certified by the NSF to filter out those contaminants.

I did a bunch of research and found that SF tap water is generally safe to drink. It is disinfected with Chloramine and contains trace amounts of parasites, copper, and lead. The SF PUC monitors Cryptosporidium and Giardia levels every two weeks, and their 2006 Water Quality Report (published 6/07 PDF) shows that all measurable contaminants are below maximum contaminant levels.

Even after finding that SF water is safe for us to drink, I decided to get an activated carbon filter in addition to a sediment filter, because I’m worried that chemicals might enter into the water main during construction, just as visible sediment enters into the water main. Also, I decided that activated carbon was really cool (one gram has a surface area of 500 m² – 1500 m²)!

Choosing a 9 3/4″ Filter Housing

My first thought was to get an OmniFilter OT32 for $140. This unit has a double housing that can fit 2 9 3/4″ filters, and it comes with a string-wound sediment filter and an NSF-certified 0.5-micron enhanced carbon block filter.

After some digging, I found I get a cheaper 2-filter housing from Pentek Filtration. I bought a BFS-201 housing (PDF) from FiltersFast for $57. It’s seems well-built and looks like this:
IMG_3837

Installing the Filter Housing

The recommended way of using under-sink filters is to install a second, low-flow-rate faucet to get the maximum effect from your filter. I didn’t want to do this, because I didn’t want to drill a new hole through our granite countertop, so I investigated splicing the filter into our cold water line.

If we only wanted to filter sediment, we could easily add the filter to cold water line, because sediment filters can handle 10 gallons per minute, and our faucet only had a 2gpm flow rate.

Unfortunately, activated carbon filters only work at reduced flow rates. If you only want to filter for what the NSF calls “Aesthetic Effects” (Standard 42), then you can buy a carbon filter that works at 2gpm. But if you want to filter for things like lead, mercury, VOCs, asbestos, MTBEs, Cryptosporidium, and Giardia (what the NSF calls “Health Effects”, or Standard 53), then you have to reduce to the flow rate to 0.5-0.6 gpm.

We decided that it was OK to reduce the flow rate of the cold water at the faucet, since we will still have the full hot water flow rate for washing, and the dishwasher cold supply is already split off. This means we don’t need to drill for a new faucet.

The Pentek filter housing has two 3/8″ female NPT water connections. Our cold water line has a 1/2″ IP straight thread on the faucet side and a 3/8″ compression fitting on the other. To splice the housing into the cold water line, we need to add two 3/8″ NPT to 3/8″ compression adapters to the filter housing, using teflon tape to ensure a good seal:

Choosing a Sediment Filter
Now comes the fun part! We get to choose some filters. Since these are a standard size, we can choose from a bunch of brands, and mix-and-match. Sediment filters are very inexpensive. They are usually made of wound string, last for 10-15,000 gallons, and cost under five bucks. I got the Pentek CW-MF from FiltersFast for $3.30. Looking at the spec sheet, I should have gotten the WP-5 for $5.60, since it has a 5 micron rating instead of a 30 micron rating. It might not matter, since the water will be flowing through a carbon filter anyway. This filter is mostly to lengthen the life of the carbon filter.

Choosing an Activated Carbon Filter
The OmniFilter CB3 seems pretty good. It costs $36 dollars and has NSF Standard 42 and Standard 53 ratings to reduce Asbestos, Atrazine, Cyst, Lead, Lindane, Mercury, and VOCs, as well as Chloramine and Chlorine.

I found Pentek CBR2-10R, which is basically the same thing as the OmniFilter CB3, but it lacks the NSF Standard 53 rating. However, it costs only $17 at FiltersFast, and I decided it was good enough for me. It also has a built-in 0.6gpm flow restrictor, which makes sure you get the full effect of the filter.

After installing everything, this is how it looks:
IMG_3870

The water definitely tastes different; it has a slightly-metallic aftertaste, similar to distilled water. I’m interested to see how much stuff the sediment filter catches after 3 months.

Costs
This is my bill from FiltersFast:

Filter Housing BFS0-201 $56.99
Carbon Filter CBR2-10R $16.95
Sediment Filter CW-MF $3.30
Filter wrench SW-1a $2.70
Shipping $1.99
retailmenot.com coupon -$5.00
Total $76.93

I also had to buy two 3/8″ compression to 3/8″ MPT adapaters for $4.79 and a couple hoses from Cole Hardware, bringing the total up to a hundred bucks.

How to tunnel VPN over SSH

Today I had to use VNC to debug a remote machine, but firewalls were blocking VNC ports.

After I failed to get my VNC client (Chicken of the VNC) to use a SOCKS proxy, I was able to use SSH port forwarding to get it working. On your local machine type:

ssh user@remotehost -L 5900/localhost/5900

This forwards port 5900 on localhost to port 5900 on the remotehost. Then in Chicken of the VNC, open a new connection to localhost. That’s it! EEZ!

It turned out that Xorg was eating all available memory and invoking the oom killer. Sigh.

I guess I could have figured this out without VNC, but I couldn’t reproduce the bug locally, so I watched as a remote user was working on the machine.

How To Configure Your Laptop for Wireless Backups Using Time Machine

The greatest thing about Leopard is that you can configure your Mac laptop to backup wirelessly and transparently using Time Machine. You can wander around the world editing files, and your laptop will automatically back them up when you come home and connect to your wireless router, without you having to do anything.

You will need a second Mac or Linux box to host the remote backup. This takes five to ten minutes to set up and configure.

First, configure your remote backup machine. These instructions assume that you are using a Mac for this.

  • Configure your remote backup machine with a static IP address
    • Your backup machine must be connected to the same wireless router that your laptop will connect to when you are home
    • My wireless router is set to assign IP addresses starting with 192.168.1.100, so I assigned my remote mac to use 192.168.1.23
    • To assign an IP address manually while still using DHCP to get other network settings from your wireless router, go to System Preferences -> Network -> Airport -> Advanced -> TCP/IP and choose “Using DHCP with manual address”
  • Configure AFP File Sharing under System Preferences -> Sharing
    • Select the “File Sharing” checkbox. You should see a message that says “Others can access your computer at afp://192.168.1.23″, or something similar.
    • Click the “+” button under “Shared Folders:”, and add the hard drive you want to store the backups to the list
    • Click the “+” button under “Users:”. Create a user called “backup”. Give this user Read & Write permissions to the backup hard drive

Now, configure your laptop
  • Mount the remote backup hard drive
    • In the Finder, choose “Connect to Server…” under the Go menu
    • Type afp://192.168.1.23 in for the server address
    • When asked, log in using user “backup” and type in the password. Be sure to click “Remember password in my Keychain”
  • Now, Configure Time Machine
    • Choose System Preferences -> Time Machine
    • Click “Choose Backup Disk”
    • Choose the remote backup disk that you mounted using AFP

That’s it! The first time Time Machine backs up, it will be really slow. Just let it run overnight. All the following hourly backups will be very fast.

If you use your laptop in the standard, Apple-approved manner, then you can configure Time Machine to only backup your Users directory, which will save space and time. Let me know if you need more help!

How To Quickly Find the Size of an Image

To find the size of an image, I usually use ImageMagick’s identify command. Unfortuantely, identify is horribly slow, especially for JPEG 2000 images (thanks to a very slow libjasper).

So instead of using identify:
identify -format "%wx%h" image.jp2

Use exiftool instead:
exiftool -s -s -s -ImageSize image.jp2

exiftool is 62.5 times faster(!!!) than identify for finding image size on my dual 2.0Ghz Athlon.

How to put a Miele Dishwasher into Service Mode

Our newly-purchased Miele dishwasher was DOA. We had to call the service department, who sent out someone to repair it the same day. When we called, they had us put the dishwasher into service mode, which will tell you which error (“technical fault”) is causing your dishwasher to fail.

These instructions are for a G2140* model Miele Dishwasher

  • turn off dishwasher
  • hold start
  • turn on dishwasher with start button still pressed
  • release start button
  • press start button 3 times, quickly, holding it in the last time, until the Start/Stop light flashes (no other lights should be flashing)
  • Start/Stop should flash for four seconds
  • press program button.
  • This should cause the rinse LED to flash in a series of long and short blinks. Count the long blinks. Those are the tens digit of the fault. The short blink are the ones digit. For example, ours flashed one long blink and four short blinks, which meant we had a F14 fault.
  • You’ll have to figure out what the faults mean. We only know that F14 means “Water intake fault with heater or circulation pump”, or something like that. Our circulation pump was clogged.
  • Now, to delete the fault, press and hold the start/stop button for five seconds.

Miele: Absolutely the best customer service I’ve ever had in my life.

We finally got a dishwasher! It took some time and work to get it installed, but fortunately we had a lot of help! A couple weeks ago Ken helped remove the old cabinet and Steve wired a new electric outlet. This weekend Paul helped do all the plumbing and install the new cabinet + dishwasher. But when we finally hooked everything up Sunday evening and tried to test it out, the dishwasher flashed a ‘technical fault’ error code. Blah!

Paul called Miele this morning at about 8:45. They did some tests over the phone and said they would have to send a technician out to look at it. After lunch, I got a call Miele saying that they could send someone by in and hour. At 2pm or so, a Miele technician named Glenn shows up, hooks up some debugging equipment, carefully pulls out the dishwasher, unclogs the circulation pump, puts it back together, and it works! Elapsed time from frustrated customer support call to happy customer: about 6 hours! Yay! I think I got lucky because someone had canceled their appointment so they fit me in right way, but still.. yay! So much better than dealing with AppleCare or Blue DoubleCross.

To top it off, Glenn explained a lot about how the Miele worked (I had no idea), and tweeked the software to increase the fill level and water temperature so we can run it on economy mode and still get super-clean dishes. This is like taking your computer to a Linux hacker who hooks you up with a custom distro to get more reliable network connections. Or like taking your car to a gearhead who reprograms the ECU to give you an extra 50HP. Our dishwasher now runs GlennOS. Awesome.

If you care, the clogged circulation pump (error code F14) was suspected to be caused by water drying in the the machine after testing at the factory in Germany. Apparently German water is very hard, and it hadn’t drained completely before shipping (it arrived at our house still full of water), so it left residue in the circ pump.

Here is Zara inspecting the dishwasher (the cabinet work is not done yet):
IMG_3750.JPG

Here is Paul, who did a weekend’s worth of install work, and the inside of the dishwasher:
IMG_3752.JPG

This dishwasher connects to the cold water supply, and heats the water depending on what the selected cycle requires. Connecting to the cold instead of hot water supply adds an extra 10-15 minutes to the roughly 2 hour normal cycle, but increases efficiency.

To add a second line to our cold water supply, we replaced the shut-off valve under the sink with a dual 1/2″ to 2 x 3/8″ shut-off valve made by BrassCraft:
IMG_3744.JPG

If you have 1/2″ unthreaded copper pipe coming into your house, and you need to attach a 1/2″ threaded fitting, you need one of these 5/8″ compression to 1/2″ pipe thread unions. The 5/8″ fits over the unthreaded 1/2″ copper with a compression fitting, and then you can just screw the shut-off valve onto the other side of the union. The fine folk at Cole Hardware helped us find this elusive adapter, shown here covered in teflon tape.
IMG_3739.JPG

We hope the dish robot likes its new home in our kitchen! Thanks to Ken, Steve, and Paul from helping get it installed, and thanks to Glenn for Miele for making it work!