Quantcast

If I Was A Robot…

ifiwasarobot

This is a cute illustration by Alex Noriega. I don’t know if TikiRobot and this robot would be compatible as friends, since TikiRobot is likely to be making mai-tais or tossing frisbees to dogs instead of eating people…but maybe he wouldn’t mind break-dancing.

Bocce!



Bocce!, originally uploaded by tiki.robot.

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..

at the pratt institute



at the pratt institute, originally uploaded by tiki.robot.

with tymm

Yummy Sunday pre-Phil’s diversion

Barcelona Tram Ride in 1908

I’m sure all of you have seen the amazing Trip Down Market Street, shot on a cable car in 1905. And you’ve probably seen the same route shot in 1906 after the earthquake (skip to middle).

But have you seen this footage shot from a Barcelona street car in 1908?

via reddit

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

Caraka Samhita



Caraka Samhita, originally uploaded by tiki.robot.

look what finally arrived!! -shag

Kiva Donation!

We got a $92 check for having the Amazon widget in our sidebar and used it to fund four Kiva microloans. We helped fund loans to a fish seller and a jewelry artist in Nicaragua, and two farmers in Tajikistan.

kiva1

Also check out this great video that tracks the lifetime of a Kiva loan and Banker to the Poor.

Every time we get a check for having the amazon sidebar on our blog, we round it up to $100 and donate it to a worthy cause. Where should we donate next?

TCM book sale at Eastwind Books

Stopped in at Eastwind Books at Columbus & Stockton in SF the other day, and discovered to my delight an unannounced 30% off sale on all books in the store.  Normally a random bookstore sale would not be blog-worthy, but Eastwind is not merely a random bookstore.  They are like the Kinokuniya of Chinese bookstores, and have one of the best selections of Traditional Chinese Medicine texts of any retail bookstore in the U.S, along with a selection of Chinese philosophy, literature, and language texts.

Some gems that were still on the shelves as I was leaving were Bensky’s Formulas and Strategies, Chen’s Chinese Medical Herbology & Pharmacology, and the English version of the Commission E Monographs.  With the sale taken into account, all three were priced significantly below BookFinder prices…

Smile



Smile, originally uploaded by tiki.robot.

talk freak

Market & Franklin



Market & Franklin, originally uploaded by tiki.robot.

hot dog



hot dog, originally uploaded by fartparty.org.

weird things pass through my flickr feed…

Raj and Zara



Raj and Zara, originally uploaded by tiki.robot.

From Jess’ new phone!

Fixing MTRRs on Linux

Some x86 computers have a buggy BIOS that can cause poor Linux graphics performance.  The problem is caused by the BIOS’s boot-time configuration of the Memory Type Range Registers (MTRR).  On modern systems, the graphics aperture should be configured as write-combining memory.  But buggy BIOSes will configure it as plain “uncacheable” memory.  The performance cost of the bug can be large: as an example, a ThinkPad T61 with Intel x3100 GMA  and T9300 CPU initially rendered ~120 fps in glxgears; this increased to ~580 fps with a fixed configuration.

You can determine whether your system has the bug by examining your X server log (likely in /var/log/Xorg.0.log) and looking for a line similar to:

(WW) intel(0): Failed to set up write-combining range (0xe0000000,0x10000000)

The Fix

The good news is that the MTRR can be fixed from the Linux command line via ‘cat’ and ‘echo’ and the /proc/mtrr file.  The bad news is that figuring out the right configuration is difficult and often involves some trial and error.  The process often involves converting cached memory to uncached memory, so it is best done in single-user mode, without X running.  The machine should be doing nothing else, otherwise the system is likely to slow to the the point of unusability.

Try the Easier Fix First

Someone may have already fixed the problem for your machine.  If they’ve posted it to the Internet, try their script first.  One sample is below, along with a  few links for other machines.  These may not work, since BIOS MTRR configurations can vary depending on the amount of memory in the system,  devices present, and BIOS revision.

Then Try Figuring It Out

Needed are Linux expertise, an understanding of hexadecimal arithmetic, and an understanding of the basics of how computers map memory. General steps:

  1. Use the error message from the Xorg log file (probably /var/log/Xorg.0.log) to determine the start address and size of the graphics aperture.  Example:
    (WW) intel(0): Failed to set up write-combining range (0xe0000000,0x10000000)
  2. Reorganize the MTRR settings (via /proc/mtrr) to mark the video chip’s memory as write-combining.  This generally involves:
    1. removing any MTRRs that overlap with the graphics region,
    2. adding a MTRR for the write-combining area, and
    3. breaking the removed MTRR into MTRRs that do not overlap the graphics aperture area.
  3. Create a script to replicate the MTRR settings (sample below) and run it during boot, e.g., from /etc/rc.local.

The details are beyond the scope of this post, but here are some resources that may help.

MTRR Fix For A Sample Configuration

Here are the details of an MTRR fix for a Lenovo ThinkPad T61 (8897CTO) laptop with 4GB RAM and a 64-bit kernel.  Here’s the default BIOS MTRR configuration (cat /proc/mtrr):

reg00: base=0xc0000000 (3076MB), size=1024MB: uncachable, count=1
reg01: base=0x13c000000 (5056MB), size=  64MB: uncachable, count=1
reg02: base=0x00000000 (   0MB), size=4096MB: write-back, count=1
reg03: base=0x100000000 (4096MB), size=1024MB: write-back, count=1
reg04: base=0xbf700000 (3063MB), size=   1MB: uncachable, count=1
reg05: base=0xbf800000 (3064MB), size=   8MB: uncachable, count=1

The problem is that the graphics card memory (which according to the Xorg log is at 0xe0000000) lies within the reg00 uncacheable region, but should be marked as “write-combining.”  After running this script:

#!/bin/sh
echo "disable=5" > /proc/mtrr
echo "disable=4" > /proc/mtrr
echo "disable=3" > /proc/mtrr
echo "disable=2" > /proc/mtrr
echo "base=0x0 size=0x80000000 type=write-back" > /proc/mtrr
echo "base=0x80000000 size=0x40000000 type=write-back" > /proc/mtrr
echo "base=0xe0000000 size=0x10000000 type=write-combining" > /proc/mtrr
echo "base=0x100000000 size=0x40000000 type=write-back" > /proc/mtrr
echo "base=0xbf700000 size=0x100000 type=uncachable" > /proc/mtrr
echo "base=0xbf800000 size=0x800000 type=uncachable" > /proc/mtrr
echo "disable=0" > /proc/mtrr
echo "base=0xc0000000 size=0x20000000 type=uncachable" > /proc/mtrr

… the MTRR configuration changes to:

reg00: base=0xc0000000 (3072MB), size= 512MB: uncachable, count=1
reg01: base=0x13c000000 (5056MB), size=  64MB: uncachable, count=1
reg02: base=0x00000000 (   0MB), size=2048MB: write-back, count=1
reg03: base=0x80000000 (2048MB), size=1024MB: write-back, count=1
reg04: base=0xe0000000 (3584MB), size= 256MB: write-combining, count=2
reg05: base=0x100000000 (4096MB), size=1024MB: write-back, count=1
reg06: base=0xbf700000 (3063MB), size=   1MB: uncachable, count=1
reg07: base=0xbf800000 (3064MB), size=   8MB: uncachable, count=1

and glxgears frame rates are much higher.

More Information

Here are some samples that others have provided for other configurations:

A technical discussion of write-combining: http://download.intel.com/design/PentiumII/applnots/24442201.pdf

Linux /proc/mtrr documentation: http://www.mjmwired.net/kernel/Documentation/mtrr.txt