The Free Software Foundation is having a year end fund drive. Go join today. Can you think of a better way to spend $10 per month? Tell them member 7097 sent you.
Join the FSF Today
December 5th, 2008Ruby’s not Ready
November 11th, 2008Was looking for a specific essay about some of the issues with Ruby to point my boss to and stumbled across this instead, still haven’t quite finished reading it yet but good stuff. Increases my desire to further my Python skillz.
Quick & Easy Temperature Logging with the Arduino
November 2nd, 2008Basic Voltage Divider with a Thermistor:

Typical voltage divider, matched would have made better sense but the thermistor was a random one salvaged from consumer electronics so I didn’t know the value in advance.
Would work just fine like this with TP1 connected to an Arduino analog input and Vcc and GND connected. Energy savings for the win though, connected the top of the divider (Vcc) to a digital pin on the Arduino. Set the pin HIGH when you want to take a reading, LOW the rest of the time. Now the divider is not consuming power when a reading isn’t being taken.
Arduino Code
int pinDivEn = 4;
int pinDivRead = 1;
int pinLED = 13;
void {
Serial.begin(9600);
pinMode(pinLED, OUTPUT);
pinMode(pinDivEn, OUTPUT);
Serial.println("READY");
}
void {
if > 0) {
digitalWrite(pinDivEn, HIGH);
digitalWrite(pinLED, HIGH);
delay(100);
while > 0)
int serByte = Serial.read();
Serial.println(analogRead(pinDivRead));
digitalWrite(pinDivEn, LOW);
digitalWrite(pinLED, LOW);
}
}
pinDivEn is the divider enable pin (Vcc), pinDivRead is the analog input connected to TP1 in the divider, pinLED is is a digital pin with an LED that is lit while a reading is taken.
Once the Arduino boots it sends READY on the serial port at 9600 bps. It then waits for any data to be available on the serial port, when bytes are available, the voltage divider is enabled, the LED is lit, the bytes on the serial port are consumed, the value of TP1 is read and then written to the serial port, the divider enable pin is brought back low and the led is extinguished.
Perl Code
use strict;
use warnings;
use IO::Handle;
use Device::SerialPort;
my $dev = tie (*FH, 'Device::SerialPort', "/dev/tty.usbserial-A4001JwW")
|| die "Can't tie: $!";
$dev->baudrate(9600);
$dev->databits(8);
$dev->parity("none");
$dev->stopbits(1);
open (my $log, '>>', 'ohms.log') || die "can't open: $!";
$log->autoflush(1);
while (1) {
my $val = <FH>;
last if $val;
}
print FH "1\n";
while (1) {
my $val = <FH>;
next unless $val;
chomp $val;
my $vR2 = $val / 1023 * 5;
my $vR1 = 5 - $vR2;
my $i = $vR1 / 1_000 * 1_000;
my $R2 = $vR2 / $i;
print $log time . ' ' . $R2 . "\n";
# printf("V_R2=%.2fV, i=%.2fmA R2=%.2fKΩ\n", $vR2, $i, $R2);
sleep 10;
print FH "1\n";
}
Opens the serial port, waits for something (the Arduino sending ‘READY’ but it pays no attention to what) on the serial port then every 10 seconds sends a 1\n to the Arduino prompting it to send a value. The result of analogRead is an integer from 0 – 1023 so this is converted to a voltage. The current through the divider is found allowing the resistance of the thermistor to be solved for. The resistance and time are written to a space separated log file. If the thermistor wasn’t unknown it would make more sense to solve for the actual temp using the Steinhart–Hart equation or similar and logging that rather than the resistance.
Sample log file entries
1224349439 10.3666666666667
1224349449 10.3666666666667
1224349459 10.3666666666667
1224349469 10.4943820224719
1224349479 10.3666666666667
1224349489 10.2417582417582
A few lines in a text file gets us a graph from the log file by way of GnuPlot:
set term png transparent nocrop enhanced font "./arial.ttf" 9 size 800, 600
set xdata time
set timefmt "%s"
set format x "%m/%d %H:%M"
set xtics rotate by -45
set title "Thermistor Value"
set xlabel "Date/Time"
set ylabel "Resistance (kOhms)"
set grid
set output "ohms.png"
plot \
"ohms.log" using 1:2 title "10 sec interval readings" linecolor 2, \
"ohms.log" using 1:2 title "Bezier fit curve" smooth bezier linecolor 4 lw 2, \
10 title "77 F" lw 2 linecolor 1

multi-multi-multi function office machines
August 28th, 2008Currently in a waiting room and CNN is on. There was just a commercial for a Sharp deep freezer sized copier/scanner/printer/sink. The business person googled for a restaurant to take a client to on the built in touch screen then presses a button to print a full-color map to the restaurant. What business person would go to the copy building (a room is not big enough) to google a restaurant?
Sorry check back later for pics, Steve Jobs says I don’t need copy & paste as I’m sending this from the wordpress app on my iPhone.
Update:

One note of clearification, as crazy as the feature set on these machines is, I still wouldn’t mind having one to use whenever I wanted, imagine what you could do with it! The commercial I saw is available in flash form at
http://www.sharpusa.com/files/workwithoutlimits.swf.
No upstart Docs + asshole Canonical Employees = Fail
August 18th, 2008I was in need of a means to disable upstart scripts in /etc/event.d via some means other than getting rid of the file. Since upstart has no documentation to speak of, I asked my buddy Google.
Google pointed me to the year old bug 94065 in launchpad. I added a quick ‘me too’ and subscribed to updates on the bug. This was back in March. Fast forward to last week and this arrives:
** Changed in: upstart
Target: 0.5 => None
--
Add non-destructive means to disable a job
https://bugs.launchpad.net/bugs/94065
You received this bug notification because you are a direct subscriber
of the bug.
There is no mention of this change in bug meta-data on the launchpad site, or maybe I’m just not finding it since I lack the doctorate in navigating launchpad necessary to be able to use the site. This prompted an update from the original reporter on the bug asking for more information:
is there a disable method yet? i reported this initially over a year ago. (there may be, but since there’s no upstart manpage on hardy, it’s hard to know. :-)
Now for the asshole fail:
Scott James Remnant wrote on 2008-08-14: (permalink)
Does this bug report say that there is a disable method? Is it marked Fix Released?
No.
I’m not sure what Scott James Remnant <scott@canonical.com>’s roll at Canonical is but perhaps it should be modified to remove any tasks that involve interaction with the public?
The Definitive qmail Patch
August 11th, 2008I have spent quite some time working on the definitive qmail patch. So as not to keep all this goodness to my self I have decided to make this patch available to all:
$20 Garage Sale Find
August 2nd, 2008i haz iphone 3g
July 25th, 2008Polite Spam
July 15th, 2008From: "claude je" <redacted> To: <billing@linode.com> Subject: You are about to get fired You are about to get fired http://[redacted]/view.exe
It is quite polite of the sender of this piece of mail to warn the recipient that they are about to get fired for infecting office machines (supposing they click the link from a suitable browser, that is).
screen copy mode can be used to copy/paste
July 10th, 2008I’m aware of many people that use GNU Screen’s copy mode to scroll back through terminal history but don’t actually use copy mode for copying text for later pasting. I was one of those people myself for some time. Screen supports some pretty nifty copy/paste tricks but a few basic key strokes will get you started.
Entering Copy Mode and Scrolling
By default, enter copy mode with
then
. You can use vi like commands to navigate through the scollback buffer. The arrows and
should work as well. A few useful commands some may be unfamiliar with:
-
M
- jumps to the middle visible line
-
NN%
- jumps to the specified percentage in the buffer (0 – start, 100 – end
-
g
- jumps to the beginning of the buffer
-
G
- jumps to the end of the buffer
These keys are even useful when you aren’t using copy mode to copy/paste text.
Copying Text
Once the cursor is at the beginning location, press
to set your first mark. Next navigate to the ending position and hit it again. The second
will set your end mark and exit copy mode. One neat and often useful feature is selecting a rectangle on the screen rather than full lines. Use
and
to set the left and right column margins to the cursor’s current location.
Pasting
Pasting is easy, just hit
to activate screen then
to paste.
There’s More!
There are loads more options such as multiple copy buffers, the ability to append marked text to the buffer rather than replacing it, etc. Check out the man page for more screen goodness.


