archive_

Using pygame to develop with context free

Using pygame to develop with context free

A problem I have had while playing round with Context Free, is that every time I change the cfdg file, I have to rerun cfdg and then display the resulting image. This got me thinking that there must be a good way to monitor the file and every time it changes just re-run and display the image. My mind wondered back to a pycon UK when I saw a guy using pygame to display his slides. The reason being that as pygame is essentially a framework for displaying images and handling events without the tedious bits around the edges, he could very easily create a slide show that could run on anything without an extra program required. Putting this to work against my problem I could just create a python app that would monitor the file and every time the file changed, rerun cfdg and display the image in pygame. It turns out that this is ridiculously easy: 1) Initialise a pygame window 2) Start a thread to monitor the file. The thread just runs the cfdg with popen and displays the image created to the pygame window. I found it better to just run every second that way I could see the different images created by the random branching in context free. 3) Keep going till a keystoke kills the process. So here it is (python 2.5):

Emacs - Copying a whole line without killing it

Emacs - Copying a whole line without killing it

For some reason I always find myself trying to copy a whole line and then pasting back somewhere else. I have never found a good way in Emacs to do this except for < home> C-k C-y until today, when I wrote this little function to do it for me and bound it to M-k because I never use kill-sentence anyway. (the excessive commenting is for people learning Lisp like me)

Context Free Art

Context Free Art

A few months ago I stumbled upon Context Free Art. It is basically a way of drawing images by using a context free grammar. The images on the site were pretty nifty, but after unsuccessfully compiling the source I gave up forlorn that I would never be able to use a context free grammar to create images. Only to check back on the site every once and a while to see what new images others had created. Today I found myself with nothing better to do so I was going to give compiling the program another try. While seeing if I had the required libraries I had the brain wave to search every field in the FreeBSD ports website for “context”. Bingo! A quick portinstall cfdg and I had it on my laptop. So now I am free to context free myself into odd fractal patterns. The moral of the story is that FreeBSD ports is a truly amazing tool.

Star tracker v0.2 release

Star tracker v0.2 release

Wow, StarTracker v0.2 is now live. With new Nomination usability fixes. Now you don’t need to guess the username, and the “star” is easier to pick.

Using openssl to test https sites

Using openssl to test https sites

Here is a little gem I found in Absolute FreeBSD - Chapter 9 that lets you test the certificate used by a web server to start a https connection. Basically what happens is that openssl opens a SSL connection to the web site, prints all the details of the connection and then you can enter a HTTP request as if you were connected via telnet to port 80. Reading the output gives you a good idea of what is wrong or right with your cert. Seeing I had to use it twice today to check our certificates I would say it is really useful. Here is an example of use:

Absolute FreeBSD 2nd edition

Absolute FreeBSD 2nd edition

In a vain attempt to learn more about FreeBSD I bought Absolute FreeBSD 2nd edition. I am already up to the 5th Chapter and finding it a good read. It reads well as the author has a very conversational tone, while giving you more than enough information on the topic at hand. He drops in jokes and honest truths, as if you were talking to him in a bar. I imagine that it would be a bit lacking if you were a hard core Unix admin, but then I guess you wouldn’t be reading the book. Chapters read so far: Chapter 1 - Getting More Help A very solid discussion into how to find information on the FreeBSD system in front of you. My favorite part is the section that describes how to write an email to the BSD user groups when you need support. I wish I could get anyone that sends me a support request to read this section before they do. If only so they can understand why they get so many polite emails back asking for more detail than “its broken”. Chapter 2 - Installing BSD I skimmed this chapter as I already have FreeBSD installed, but will most likely go back and read it when I need to reinstall (due to human error) Chapter 3 - Start Me Up! The Boot Process This chapter was enlightening, I now have more insight into what the messages at boot time mean, and more importantly I found out that I could change the loader logo to a colour beastie. By adding the following to /boot/loader.conf:

Changing the length of comments for C mode

Changing the length of comments for C mode

For a long time I was irked by Emacs’ habit off auto wrapping my comments especially when I was adding them to the end of lines in csharp-mode. Finally I have worked out what the problem was, after many hours of searching. As it turns out comments in c mode have been set to auto fill, and all I had to do was adjust my fill-column property to something large, (at the moment 200) and then it will only wrap the comment when the column length gets to 200. Genius. Given that I don’t really use auto-fill for anything else it was a simple matter of:

Book Reviews

Book Reviews

I have finished both new python books, but I forgot how hard it is to write book reviews. Will try to post on them when I have re-read and taken notes!

A very cool idea

A very cool idea

My python blog stream picked up http://www.snakebite.org/ today. It is a farm of computers with lots of different OSs on it so that Python can be constantly built and made to build on them. It is an amazing idea. I have always wondered how a sparse organisation, like a open source project, have the resources to build on so many platforms. It turns out they just rely on their members to have the OSs laying around to build on. Now Python doesn’t have that problem. Big Win.