Wednesday, May 31, 2006
Monday, May 29, 2006
Axon in C++
I've been creating my own (not-so-)MiniAxon in C++, focusing on efficiency unless it would overcomplicate the API. A Kamaelia implementation in C++ must provide much that the Python developer takes for granted. For example, Duff's device serves as a potent and yet intrinsically sinful implementation of generators:
#include <iostream>
static int generatorstate = 0, x = 1;
int generator()
{
switch (generatorstate)
{
case 0:
std::cout << "Hello World\n";
generatorstate = 1; return 1;
case 1:
for (;;)
{
std::cout << x << "\n";
x = x + 1;
generatorstate = 2; return 1;
case 2:
std::cout << x << "\n";
x = x * x;
generatorstate = 3; return 1;
case 3:
;
}
}
}
int main()
{
generator();
std::cout << "Run 1 time\n";
generator();
std::cout << "Run 2 times\n";
generator();
generator();
generator();
std::cout << "Run 5 times\n";
generator();
generator();
generator();
generator();
generator();
std::cout << "Run 10 times\n";
}
Sunday, May 28, 2006
Character set woes
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 19621: ordinal not in range(128)What a nasty complication to an otherwise simple language!
I've made something nice to use for my streaming testing - a video of the swans at the local lake.
I'm playing around with Boost.Python, with an aim to wrapping libtorrent although I've yet to get the examples to compile!
Saturday, May 27, 2006
Apt-proxy
Labels: ubuntu
Friday, May 26, 2006
Metalink
In other news, I've added a non-witty mode to Kambot (say "stfu kambot" to toggle it) to stop it from saying stuff during meetings etc. on #kamaelia.
Thursday, May 25, 2006
And so it begins...
I'm currently experimenting with using SWIG to wrap C++ modules for Python.
Monday, May 22, 2006
HTTP Benchmarking
Benchmarking my HTTP server revealed some issues - I was not closing components after their TCP connection closed. Initially I was getting throughput of about 5 hits/sec. After some tweaks, such as only yielding when left with nothing to do, I managed to get 100 hits/sec for highly dynamic pages or 800 hits/sec for small static pages when using persistent connections. This is fairly good, although an simple, efficient webserver written in C could probably handle several thousand hits/sec. I've been using siege to do the load testing/benchmarking.
I found a bug in the Kamaelia TCP components - they raised an exception when the remote host disconnected unexpectedly, taking down the entire HTTP server in the process. :D
I've made a handy little Python script to convert tabbed code to spaced code.
#!/usr/bin/env python
import sys, string
def tabsToSpaces(path):
myfile = open(path, "rb")
contents = myfile.read()
myfile.close()
lines = string.split(contents, "\n")
contents = []
for line in lines:
tabs = 0
replacement = ""
while line[tabs:tabs+1] == "\t":
tabs += 1
replacement += " "
contents.append(replacement + line[tabs:])
contents = string.join(contents, "\n")
myfile = open(path, "wb")
myfile.write(contents)
myfile.close()
if __name__ == "__main__":
if len(sys.argv) != 2:
print "Usage: tabsToSpaces.py"
else:
tabsToSpaces(sys.argv[1])
Saturday, May 20, 2006
Dapper Drake - First Impressions
I've upgraded to Ubuntu 6.06 (Dapper Drake) beta and I have to say I'm fairly impressed on the whole. The upgrade procedure from 5.10 was very simple - modify your apt sources.list to say 'dapper' where it previously said 'breezy', then run apt-get update and apt-get dist-upgrade. It's a lot less troublesome to get setup than Fedora Core 5 was, although I'm only using the x86 version of Ubuntu rather than AMD64 as I did with Fedora.
I was having a minor problem with colour (#fcfcfc would appear considerably darker than #f0f0f0) but the new nVidia drivers (available through apt in Dapper) fixed it. I also had problems on an older Pentium II machine - everything after grub and before the login screen is garbled most likely due to buggy ATi drivers (it's a All-in-Wonder based on the Radeon 7200). I'm considering going back to Breezy on that PC.
sudo dpkg-reconfigure gnome-applets fixed the CPU applet (after the upgrade it was no longer SUID so you couldn't pick a frequency. The gnome-art package is great for customising the appearance of Gnome.
It also has Firefox 1.5, gstreamer-0.10 and a working mplayer package and Eclipse C++ support which were some of the main things I wanted, seeing as I had them on Fedora Core 5 before.
In summary, Dapper is better than any Linux distro I've seen before, but only by a little. Its default colour scheme (brown and orange) is hideous but the other colour schemes don't look as modern. Legacy ATi support needs work - I've seen similar problems reported on the Ubuntu bug tracker. The games, as with most Linuxes, are pathetic. They are of no comparison to the majority of commercial games. That said, if I wanted my PC primarily for gaming, I'd be using Windows XP Home Edition...Friday, May 19, 2006
All up and working again
My new graphics card (an Asus nVidia 6200 AGP) arrived and my computer is working fine again thanks to it. It's also passively cooled - there has been a noticeable drop in the PC's noise level. Though it's not as powerful as my broken 6600GT was, it was a good buy at £35.
For your information, the faulty component was an XFX product - I will be avoiding them at all costs in the future.
HTTPServer is coming along. I've added better support for complex URLs.
I've also tied it to the IRC logger successfully.