Posts

OLPC Update

Image
The $100 laptop OLPC CM1 (Children's Machine 1) 2B1 laptop project has some news. For one, it has a new name: 2B1 . The 2B1 promises to have a built in WiFi mesh network - i.e. you turn it on and it connects and extends any nearby networks. It has a high resolution (1200x900 pixel at 200 DPI ) screen that is usable in sunlight (unlike a normal laptop). They've got it working with less than 2 watts of power (very impressive). It looks like they are going with Fedora Linux (I was kinda hoping for Ubuntu Linux). What's very interesting is that a 640x480 video camera will also be standard. It sports both a built in microphone and built in speakers plus separate jacks for both earphones and an external microphone. The microphone jack also doubles as an analog input for science experiments (which is wonderful idea). It would be cool if they could double the headphone jack as 5 V output as well. I'm glad so see that this project has exceeded their original plans, it looks...

Putting programs where you like in Linux

These days, to save a little money and the environment I turn off my computer at night and in the afternoon when I'm at work. With Gnome and Ubuntu you can tell it to start up programs on start up, but the windows don't appear in the right workspace. A little bit of searching and I found what I needed: devilspie This oddly named 1 program runs scripts which you write and put in your ~/.devilspie folder and (and need to name with a .ds extension). Having this program run at startup will watch windows and when they appear will put them where you asked them to be, on the workspace you ask it to be on. The tricks I've learned is that to find out the position of a window run xwininfo and then click on the window you want to find out about. Listed in the output is -geometry in the format that devilspie likes. Another useful trick it to create a file called, say, debug.ds with the sole contents (debug) . This way if you run devilspie from the command line you'll get ...

Another useful python script

Today I was helping a colleague debug a program and I found myself doing the same thing over and over. I would download the log from the server, zip the file and then e-mail the zipped file to him. The second time doing this I decided this is too much work so I wrote a little python program to do all the steps. Here's how it's run: sendFile.py --mailto "Bob Jones" --comment "Here's the log you wanted" testserver:/aplic/jboss/server/default/log/server.log It gets the file via scp (10 lines), zips it up (another 10 lines), mails it (11 lines using a helper class). and then cleans up the temporary files (3 lines). Here's the code minus the stuff for talking to outlook (via win32com ). #!/usr/bin/env python from subprocess import call import os import zipfile import OutlookMail class SendFile: def __init__(self, dbInfo): self.tempfilename = None self.zippedfile = None def getFile(self, filename): fname = os....

Shangri-La Diet Chart

Image
Here's the complete code, you need pylab (i.e. matplotlib) to draw the graph. # -*- coding: iso-8859-1 -*- from pylab import * from datetime import date import os import csv # Shangri-La diet at http://www.sethroberts.net/ numDays = 50 # How many days ahead should we make the chart? slope = 0.7/7.0 # 1 kilo a week = 1/7kg per day kg2lbs = 2.2046226218487757 # From frink calculator http://futureboy.homeip.net/frinkdocs/ vals = [] for datestr, weight in csv.reader(open("myweight.csv")): year, mon, day = datestr.split('-') vals.append((date(int(year), int(mon), int(day)), float(weight))) startDate, startWeight = vals[0] # Get starting info days = [ (x[0] - startDate).days for x in vals ] weights = [ x[1] for x in vals ] ideal_x = arange(0, numDays) ideal_y = [ startWeight - (x * slope) for x in ideal_x ] (ar, br) = polyfit(days, weights, 1) print "Least squares slope of %.2f kg/week or %.2f lbs/week" % (ar * 7, (ar * kg2lbs) * 7) least_squares = p...

Simple compile on a remote machine

Normally, I try and compile and run programs locally and then upload a working, tested version to the final machine for more testing. This time, however, it was too difficult to compile and run it locally, and I needed to run and test on one of the HP servers. I set up my ssh account so that I could copy file without a password as shown here . But it was still more work than I wanted to do. Edit - Save - Switch local command line and copy - switch remote server make - run, repeat. So I wrote a little python program to upload only files I recently updated and to compile and run on the server. It's all setup in SciTE so that F5 does it all and the output goes in the errorlist window. I can even press the F4 key and go directly to the first error, if any. #!/usr/bin/env python # -*- coding: iso-8859-1 -*- from subprocess import Popen, PIPE, STDOUT, call import os, re host = 'kangaru' todir = '/mnt/bmp/files/fontes/agglutldp' okFiles = [re.compile(x) for x in (...

My linux prompt

Just a note to myself. This is what I'm putting in my .bashrc file for the prompt PS1='-- cd \w --\n[\u@\H] $ ' export PS1 Looks like this: -- cd /home/scott -- [scott@sysbh17] $ _ I put the cd in there so I can copy and paste to older directories even easier. I also like to put my prompt on two lines with the path first so that I don't get punished for long paths. Links: The Bash Prompt HOWTO has more information And Giles Orr has more samples .

Shangri-La Diet Update

Image
The diet is still working for me. A trick I found was to 'dilute' the oil with some water (like a vinaigrette), making it a little more palatable to drink. I'm eating less and eating a lot better, which I'm really happy about. Even if the diet isn't working at least I'm eating better! I was hoping to loose about 1 kg (2.2 lbs) a week but I'm loosing more like 0.7 kg (1.5 lbs) a week instead. I've added a least squares fit to the chart as you can see above. Tomorrow I start exercising as well, which I haven't been doing hardly at all.