29th April 2008, 01:43 pm
Another dear lazyweb post.
Yesterday night I hacked up a silly little tool for use at work. Nothing spectacular but I thought I’d try this Literate Haskell thing. I decided to go the LaTeX route and created a .lhs file. To my amazement rubber has a module for handling Literate Haskell, unfortunately it passes everything ending in .lhs through lhs2Tex. I didn’t really want to use lhs2Tex but I haven’t been able to find any way of changing rubber’s behaviour through its command line arguments. What I’d like is a way to disable a module for a single invocation. So, dear lazyweb, is there a way to do this from the command line?
So far I’ve worked around this by creating a symbolic link named MyTool.tex that points to the Haskell source, then I run rubber on the link. Not to much of a hazzle, but it’d be nicer to pass an argument to rubber.
22nd April 2008, 08:16 pm
I just went through the exercise of setting up MediaWiki on a Debian Etch box, but instead of serving it using the common choice of Apache I wanted to use lighttpd. It seems the combination MediaWiki and Apache is well supported on Debian. There was even an install-time question whether I wanted the configuration files set up for me. Well, it’s boring to follow the common path, right?
It seems the combination MediaWiki and Apache is well supported on Debian. Luckily that doesn’t mean it’s difficult to serve it with lighttpd. Here’s how I configured things, and luckily it all seems to work just fine
Installation
First off, I installed mediawiki1.7, lighttpd, php5-cgi, and mysql-server. I made sure that aptitude only pulled in required packages and then I started un-choosing all Apache-related packages. By the time you get to installing MySQL you’ll be asked for a root password, that is if your debconf is set to ask medium-level questions.
Setting up MediaWiki
The Debian package for MediaWiki creates a site in /var/lib/mediawiki1.7 consisting mostly of symbolic links to the actual location of its files. I kept lighttpd’s default document root of /var/www and linked the two by creating a symbolic link /var/www/mw pointing to the MediaWiki site (/var/lib/mediawiki1.7).
Configuration of lighttpd
First enable FastCGI by linking /etc/lighttpd/conf-available/10-fastgi.conf into /etc/lighttpd/conf-enabled/. Then go in and change the bin-path to point to /usr/bin/php5-cgi. To prepare for the MediaWiki configuration, enable mod_rewrite in /etc/lighttpd/lighttpd.conf and finally create the file /etc/lighttpd/conf-enabled/20-mediawiki.conf with the following contents:
url.rewrite-once = (
"^/$" => "/mw/index.php",
"^/wiki/([^?]*)(?:\?(.*))?” => “/mw/index.php?title=$1&$2″
)
Now it’s time to restart lighttpd.
Configuration of MediaWiki
Point a browser to http://your.server/mw/config/index.php to configure the site settings. When that’s done copy the file /var/lib/mediawiki1.7/config/LocalSettings.php one layer up.
That should be it! Enjoy!
21st April 2008, 07:38 pm
I’m writing this mostly so that I’ll remember myself
If pbuilder --create fails when building a base image for Sid then it’s worth trying to build a base image for the stable release and then upgrade to Sid afterwards. The very manual way is pbuild --login --save-after-login.
21st April 2008, 08:54 am
As promised I’ve now created Debian packages for omnicodec. Since dataenc is a pre-requisite for building from source there are packages for it as well.
I’ve uploaded the source to Debian Mentors here and here. As usual pre-built binaries are available from my own APT repo.
9th April 2008, 06:00 pm
Dear lazyweb, I’ve been racking my brain trying to get information out of the following C struct in a nice way when using ctypes:
struct Foo
{
unsigned int length;
char name[];
};
I wrote a little C function to get instance of the struct easily into python:
struct Foo *
put_name(char *name)
{
struct Foo *foo = malloc(sizeof(struct Foo) + strlen(name));
foo->length = strlen(name);
memcpy(foo->name, name, foo->length);
return(foo);
}
Now, how do I actually get the full contents of Foo.name in python? The only way I could think of that actually works is to create a dummy-struct type in order to get the length out and then use it to dynamically create a new sub-class of ctypes.Structure, then create an instance based on the address of what was returned. I think the following shows it pretty clearly:
class FOO(Structure):
_fields_ = [('length', c_uint), ('name', c_char * 0)]
liblib = cdll.LoadLibrary(’./_build/liblib.so’)
c_put_name = liblib.put_name
c_put_name.argtypes = [c_char_p]
c_put_name.restype = POINTER(FOO)
def put_name(str):
f = c_put_name(str)
K = type(’FOO%s’ % f.contents.length, (Structure,),
{’_fields_’ : [('length', c_uint), ('name', c_char * f.contents.length)]})
return K.from_address(addressof(f.contents))
I still think there ought to be some other way that ‘feels’ nicer. I mean the use of “short arrays” (declared as here with [], or zero size as supported by GCC, or the more portable array of size one) seems to be common enough to warrant some support from ctypes, right?
Any suggestions for improvements?