I have a Nokia 6682 phone and it's great, not just because it can run Python, but all of a sudden the battery seems to last not very long at all. So I need a new battery, a BL-5C, and that battery is available on-line for 5 dollars but is that because they are past their shelf-life? Never mind that the particular was recalled for a slight problem with catching fire.
Who can say?
"When I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck."
-- Alex Martelli
Thursday, January 17, 2008
Monday, December 17, 2007
The OLPC is here
I haven't been keeping with news so I was surprised and happy to find my new(est) toy on the doorstep tonight - an OLPC XO. I have been trying to put it down for several hours now so that I can take care of, well, anything else but it's fascinating. Performance wise it is not snappy but I can get on the network, download things, type in the word processor (abiword, I think) and generally fiddle around. I want to download some new apps just to see and then I am going to try and leave it alone for a while. At least overnight..
Has anyone else in Dallas (or elsewhere) received theirs?
Has anyone else in Dallas (or elsewhere) received theirs?
Sunday, December 9, 2007
Starting a wireless interface properly
I added WPA-PSK to my router recently (the wireless connection has been open up to now) and that immediately caused problems because my Linux laptop (running FC6) didn't want to play nice. My shiny new MacBook had no problems (no surprise there).
After some rummaging around, I found that I needed to start wpa_supplicant so I tried that using the init script but had no success. After some more poking, I edited
#!/bin/bash
. /etc/init.d/functions
cd /etc/sysconfig/network-scripts
. ./network-functions
. /etc/init.d/functions
cd /etc/sysconfig/network-scripts
. ./network-functions
CONFIG=`echo ${1} | cut -d- -f2`
need_config ${CONFIG}
source_config
if [ "${TYPE}" = "Wireless" ]
then
/etc/init.d/wpa_supplicant restart
fi
Presto! My wireless interface now comes up just like it should!
Now I have to figure how to setup wpa-supplicant for when I am away from my home network..
After some rummaging around, I found that I needed to start wpa_supplicant so I tried that using the init script but had no success. After some more poking, I edited
- /etc/wpa_supplicant/wpa_supplicant.conf (to set the passphrase generated by wpa_passphrase)
- /etc/sysconfig/wpa_supplicant (to change the default driver from ndiswrapper to wext
#!/bin/bash
. /etc/init.d/functions
cd /etc/sysconfig/network-scripts
. ./network-functions
. /etc/init.d/functions
cd /etc/sysconfig/network-scripts
. ./network-functions
CONFIG=`echo ${1} | cut -d- -f2`
need_config ${CONFIG}
source_config
if [ "${TYPE}" = "Wireless" ]
then
/etc/init.d/wpa_supplicant restart
fi
Presto! My wireless interface now comes up just like it should!
Now I have to figure how to setup wpa-supplicant for when I am away from my home network..
Tuesday, October 2, 2007
Simple System Monitoring with Munin
I have a machine that I compile code on and it is very slow, taking 3 hours and more to build. Using top, vmstat and iostat was fine for a quick examination but I wanted something simpler to set up and with good output. I have used Nagios before and found it to be great for serious monitoring but it requires some level of effort in setting up that I wasn't ready for here so I tried a more lightweight solution, Munin.
Munin installs as either a server or a node in about 30 seconds (from rpm) or a few minutes from source. Configuration is simple and straightforward, documentation is adequate and results are just what I needed. Plugins are written in Perl and graphs are drawn by rrdtool (like nagios and cactus).
My linux machine was set up as both server and node in about 3 mins but the Solaris box was a little more tricky. After fixing a server config file foobar and node config file foobar, all was well.
Worth a look..
Munin installs as either a server or a node in about 30 seconds (from rpm) or a few minutes from source. Configuration is simple and straightforward, documentation is adequate and results are just what I needed. Plugins are written in Perl and graphs are drawn by rrdtool (like nagios and cactus).
My linux machine was set up as both server and node in about 3 mins but the Solaris box was a little more tricky. After fixing a server config file foobar and node config file foobar, all was well.
Worth a look..
Saturday, September 29, 2007
PlotKit and MochiKit
I needed to draw some graphs on a web page dynamically from data from a command line application so I took a look at Plotkit which, apart from having some very nice looking output, has quick methods to draw a graph from the contents of a HTML table on a page (DatasetFromTable - perfect for what I want) or the EasyPlot method that draws a chart in one line of code (or two if you count the HTML).
Poking around in there, I took another look at Mochikit which is a requirement for Plotkit. Mochikit's motto is making "javascript suck less" which it succeeds at very well. It provides the $() found in prototype and has a simple, clean set of libraries for such things as DOM handling, event handling and asynchronous event handling. It also has the javascript equivalent of Python's itertools and a logging module that can send messages to the console in Firebug.
Firebug is a Firefox extension that with the ability to inspect CSS, HTML and Javascript and a visual debugger makes web development simpler than ever.
Poking around in there, I took another look at Mochikit which is a requirement for Plotkit. Mochikit's motto is making "javascript suck less" which it succeeds at very well. It provides the $() found in prototype and has a simple, clean set of libraries for such things as DOM handling, event handling and asynchronous event handling. It also has the javascript equivalent of Python's itertools and a logging module that can send messages to the console in Firebug.
Firebug is a Firefox extension that with the ability to inspect CSS, HTML and Javascript and a visual debugger makes web development simpler than ever.
Monday, August 20, 2007
Tips and Tricks: strings and formats
What if you want to output string data in a formatted fashion? You could use a format string in the same way that you would if writing PHP, C, Perl etc.. where %s is replaced by a string, %f is a float etc then you could end up with something like:
which would print the contents right-justified in a 10 character field. What if you wanted left-justified?
Well, then you would replace %10s with %-10s. Obvious, huh?
You could take advantage of some of the useful methods that Python strings own such as:
Of course, this is only useful if you are writing to a plain text file or a terminal. What if you are writing an HTML output? You could use named parameters like this..
Notice the parameters are the wrong way round in the format specifier compared to the parameter list?
This can make constructing long format strings simpler. You can take this a step further by providing a dictionary instead of a list of parameters, like this
print "%10s is a filename"%stringvar
which would print the contents right-justified in a 10 character field. What if you wanted left-justified?
Well, then you would replace %10s with %-10s. Obvious, huh?
You could take advantage of some of the useful methods that Python strings own such as:
- rjust - presents a number or string right-justified in a field of specified width (there is an ljust as well)
- centre - presents the number or string centered in a filed of the specified field width
- zfill - to present a number or string of a specified width padded out with zeroes as needed
print "%s is a filename"%stringvar.rjust(10)
Of course, this is only useful if you are writing to a plain text file or a terminal. What if you are writing an HTML output? You could use named parameters like this..
print "%(noddy)s is a filename of %(max_len)d characters"%(max_len, noddy)
Notice the parameters are the wrong way round in the format specifier compared to the parameter list?
This can make constructing long format strings simpler. You can take this a step further by providing a dictionary instead of a list of parameters, like this
my_dict ={ 'name':'/var/log/message', 'code':1}
print "Examining %(name)s returned code %(code)i" %my_dict
Pyglet
Pyglet is a cross-platform windowing and multimedia library for Python.. uses OpenGL and has a clean API.
I'll take a look and write it up.
I'll take a look and write it up.
Saturday, July 28, 2007
Rectangle classes in python
This will be useful for mapping applications.. assuming it works well. I keep hoping to find time to build something with Google maps and Python people data. Maybe this will help.
Sunday, July 15, 2007
If it looks like a Duck, it may be a Parrot..
Last Saturday (July 15), the DFW Pythoneers gathered together to hear wise words from Patrick Michaud. "Lo", he said, "it is not an ex-parrot (though it may be pining for the fjords.." and we listened in solemnity.
PM gave us another great talk and explained why Perl 6 is important/interesting/intriguing to Python people and how we can get pizza paid for by the Perl foundation while looking at Python.
Parrot is the VM for the upcoming Perl6. It also happens to be capable of 'running' Python (and a bunch of other languages, some of which you will wish you had never heard of if I told you about them so I won't. You're welcome) and Patrick gave us a run-down on how the Python sourcefile in all of its beauty gets transformed into bytecode for Parrot. It's less than simple so you can go ook it up yourself at parrotcode.org.
After the meeting, I checked out the latest Parrot code and tried the test suite. Yay, it worked (good start) and then I tried the command line prompt for the Python part of Parrot, pynie. It also worked but things got a little bumpy after that:
PM gave us another great talk and explained why Perl 6 is important/interesting/intriguing to Python people and how we can get pizza paid for by the Perl foundation while looking at Python.
Parrot is the VM for the upcoming Perl6. It also happens to be capable of 'running' Python (and a bunch of other languages, some of which you will wish you had never heard of if I told you about them so I won't. You're welcome) and Patrick gave us a run-down on how the Python sourcefile in all of its beauty gets transformed into bytecode for Parrot. It's less than simple so you can go ook it up yourself at parrotcode.org.
After the meeting, I checked out the latest Parrot code and tried the test suite. Yay, it worked (good start) and then I tried the command line prompt for the Python part of Parrot, pynie. It also worked but things got a little bumpy after that:
- longs appear to be broken but aren't
- floats are broken, along with imaginary numbers
- list, arrays and dictionaries are less than working
Subscribe to:
Posts (Atom)