Posts

Showing posts from 2007

Bleten. My game for the ludumdare 48h 2002

Image
This is a game made to the theme of sheep. This game is about sheep poo, and grass.

You play the part of a sheep, against a friend sitting at the same keyboard as you.

You must eat the grass on the opponents side of the screen, whilst pooing on your grass so it grows quicker. It's a resource game really. You need to make the trade of between blocking the other sheep, eating the other sheeps grass, and pooing on your grass.


My Evil sheep picture for the intro. I think the sheep is possessed by satan. Maybe. Or maybe it's just angry all it's lambs have been taken to be eaten. Not sure why it's angry really.




As you can see I didn't have time to draw any good looking sheep - so there's just stick figure sheep. Stick sheep that poo.


You can download the source for python+pygame here.
http://rene.f0o.com/~rene/stuff/bleten.tar.gz

http://rene.f0o.com/~rene/stuff/bleten.zip




Ludumdare is where people make games from scratch in 48 hours. A single person does all the a…

A Book "Beginning Game Development with Python and Pygame"

I haven't read this book about making games with python and pygame yet, but I think it seems like a good one for beginners. The free chapter is fun to read. Which is the essence of making games I think. It should be entertaining to make a game, and to read about making games.

This book looks like it covers most basics of programming a game - with python and pygame. Like it's title suggests it is for beginners, which is great.

PyGPU - hardware graphics programming using the GPU and python.

Have a look at PyGPU http://code.google.com/p/pygpu/

With it you can code the GPU using python. It translates code from python into GLSL (the opengl shading language).

It's amazing what type of algorithms you can quickly write using the GPU these days.

There are papers describing it's implementation and other information here: http://www.cs.lth.se/home/Calle_Lejdfors/pygpu/ It takes a similar approach to psyco or pypy... in a way. But is different from both of these.

Very cool.

Girl start project teaching girls programming with pygame.

I saw this on the pygame mailing list the other day about girlstart.org ...

"... Project IT Girl, a program that teaches 60 high school girls in Austin, Texas, about how they can change the world through the use of technology. This year, Project IT Girls learn basic programming through designing and developing their own unique educational games written with Python and **Pygame**! ..."


Looks like a cool project.

Ya! A Galcon T shirt.

After the Galcon T shirt design competition, Phil has decided to send me one of the winning designed shirts for helping out with testing.

You can see some of the winning designs here: Galcon t shirts.

Galcon is a multiplayer, and single player game kind of like risk, but with space ships. It's made with python + pygame by Phil Hassey.

-- Ninja out.

python 3000 breaks hello world

$ ./python
Python 3.0a1 (py3k, Sep 1 2007, 14:48:21)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello world"
File "", line 1
print "hello world"
^
SyntaxError: invalid syntax


Weird. I've been trying to learn this python programming language, but the first command in my lecture notes, the three textbooks I have, and all the online tutorials seem to be wrong.

Anyone know how to get hello world working?

Update: oh it seems that print is a function. ---> ;)

Maybe it should show this in the shell, kind of like what typing help does:

>>> help
Type help() for interactive help, or help(object) for help about object.

>>>print 'hello world'
Type print('hello world') to print a string, or print(object) to print an object.


Has any other major programming language …

PyWeek #5 theme voting on now! 84 entries so far.

84 entries so far for the pyweek game development competition. Some entries are teams, and some are solo efforts.

The themes for this pyweek game development competition are:

Twinkle
Turmoil
Ticking
Twisted
Tyger, Tyger

So join up, and vote for a theme. The Pyweek game competition starts soon.


Friday 2007/08/03 Registration open
Sunday 2007/08/26 Theme voting underway
Sunday 2007/09/02 Challenge start
Sunday 2007/09/09 Challenge end, judging begins
Sunday 2007/09/23 Judging closes, winners announced

Delight at my new-old recycled laptop

I don't like to contribute too much to all the pollution that getting new hardware contributes too. There's lots of perfectly good old hardware being given away or sold at low prices in second hand stores and online auction sites.

A couple of months ago I got a Dell latitude C610 laptop from a place down the road from me that restores and sells old laptops. With only 20 gigs of HD space, and 256 megs of ram it's not anything close to what you'd buy new. However it seems to do ok.

I also like to use older hardware for developing software - because it's like 'eating my own dogfood' in a way. If I see the performance problems that the slow computers experience - then I can fix them up. All too often I see websites that perform slowly on old machines, or don't fit important information on their small resolution screens.

My franken boxThe laptop is so nice, that I've mostly retired my old duron 850mhz desktop machine... which I've had since 1997 or…

plone 3 released

Plone 3 has been released!!!


Plone is not beta like those other toy frameworks (django, pylons, paste, turbogears). I guess there are more python web frame works out there after all than some people would like you to believe ;)


kidding, kidding... don't eat me.


Should be fun to play with... I haven't used it since the 2.x series - so I'm looking forward to seeing all the improvements. Congratulations to the plone team.

Pygame weekly mini sprint 2007/08/22

This week we found and fixed a long time problem with the SRCALPHA flag. Which is the flag used for per pixel alpha (transparent images).

In fixing that it turned up a few other issues with Surface. There were problems with error checking, and keyword arguments didn't work.

So we got the error checking working, as well as keyword arguments.


The major piece of work that went in was the PixelArray from Marcus. This will be what we use to replace surfarray. A PixelArray is like a basic numeric/numpy array, and like what you'd expect returned from a surf.tobuffer() call. With it we will be able to support Numeric, and Numpy by loading them dynamically.

I still need to write the surfarray.py which will replace the compiled surfarray. There will be a surfarray_numeric, and surfarray_numpy. So it will be backwards compatible, and you'll be able to use the array type you choose. We will include a frombuffer() method for Numeric arrays - which won't require Numeric to be …

javascript for templates - it's happening.

It seems like javascript for template languages might be the way forward.

designer friendly. lots of web designers know a little javascript or actionscript.
can run in a browser.
javascript can be sandboxed.
most web developers know a little js too. Web developers that don't know javascript will most likely at know at least a little C/php/perl/java to be able to do a lot of things with javascript.

Tenjin allows javascript templates. It also allows many other scripting languages to be used in templates... but that's not really what I'm talking about.

Fast, small(200k), opensource and widely deployed javascript/emca script interpreters exist. Tamarin is a emca JIT optimized virtual machine from flash 9, that mozilla is using in upcoming versions of firefox. There is also spidermonkey - the current firefox javascript implementation. Finally there is haxe, which is a emca script like language - that can output .js files, flash swf files, and also neko which runs as a virtual…

Don't trust database input either.

The database is just another form of input into your program which you should not trust.

You should validate the data coming from your database as much as you do validating the data going into the database.

How do you know the database has not been corrupted, or compromised? Or some script on your website is not validating data properly when it updates the database. Or an DB admin decides to edit the database directly and puts in some invalid data.

What if someone a year from now hooks up another program to the database, which doesn't use the same data validation that you do? Then your program not validating input data from the database will start to fail.

There are many ways data from the database might not be what you are expecting. Not including people putting data in there maliciously. Like if they somehow get your database password. Or if they find an SQL injection.

Executing code from the database surely sounds a bit crazy... right? People execute code when they use python…

collections in python - using less memory

Each object in python takes up far more memory than you might think. An int object for example does not take up 4 bytes.


So creating python objects for each element of a collection of data can use up far more memory than is needed.

A simple pattern for avoiding this wasted memory is to store the data in a array.array() then construct an object from the part of the data as you need it.


Using python classes to store an int.
Virtual 23992
Resident 21176

Constructing python classes to store an int dynamically.
Virtual 6572
Resident 3992


As you can see this method can save a *lot* of memory.

Here's some basic code demonstrating this technique... this isn't necessarily the API to use, but just demonstrates the memory savings. You can make a nicer to use API on top of that... or use your existing api with get magic properties.

wget http://rene.f0o.com/~rene/stuff/collection_memory.py

# using python objects...
python collection_memory.py 100000 -object & sleep 2 ; ps aux | grep python
# u…

Pygame weekly mini sprint 2007/08/15

There's been a few new things going into pygame recently.

Today two things came off the 'todo before release list'.

The first was the pygame.mask module was finished - the remaining from_surface function was implemented. It is 128x faster than the version written in python. It could still be optimized more, but I think it should be fast enough.

The second was the new sprite code from DR0ID. This has been a long time in development, and allows some pretty useful functionality for the pygame.sprite module. Like support for layers, blend modes, as well as automatic detection of what is faster - full screen update, or dirty rect update.

Now the 'todo before release list' is a lot shorter:

windows+mingw compilation instructions
remove current C based surfarray which uses Numeric. Replace it with a PixelArray C type. Then implement Numeric and Numpy support in python.
Mac OSX scrap fixes - using the new scrap api for clip board support.

Marcus has the basics of the PixelAr…

timing and unittests - graphing speed regressions/improvements

Are there any python tools which allow you to run timing tests inside of unittests, and then see a useful report?

I'd like to see a report of how long each timing test took, and also see differences between runs. When comparing two runs I'd like to see visually which is faster.

Timing information is a very important thing to time for gui applications like games, and websites. As so many machines are very different, it's useful to be able to time things as they run on different machines. A game or website can quite easily run 10-30 times slower even on machines with the same CPU. Many other factors like OS, hard drive speed, available memory, installed drivers, directx/opengl/X/frame buffer, different browser speed, different installed versions of libraries or plugins like flash. Testing all these things manually is almost impossible, testing them manually every time something changes is definitely impossible.

So I want to use this tool pygame unittests specifically, and …

Pyweek 5 - make a game in a week

pyweek registration is open. For the biannual game jam. http://www.pyweek.org/5/

Which means you can join, and put your self in a team, or join up as a solo entrant.

Spend a week(part time) finishing a game using python. Sunday 2nd September to Sunday 9th of September.

It is inspired by the ludumdare 48h comps, but people only use python, it is a week long, and there can be teams. Over 100 entrants joined in on the fun previous competitions.

Enter to have a chance to prototype your next game, or see if working in a team will work on a small project. Or just have a break, to get your creative juices going, and to feel all of the energy of 100+ people simultaneously feeding off each others creations. http://www.pyweek.org/5/

It's also a great way to learn, and have fun with python. It's possibly the best way to improve your programming skills, and game making skills there is.

Git problems... when moving.

There is a good explanation of the problems people have because of gits lack of move support. This is Linus explaining this problem he has with git.

The problem is that git gets confused when you move code from one file to another, and change it at the same time. Since it uses code similarity to find moved code - changing the code at the same time that you move it confuses it's move detection code.

So the solution is a convention of making almost no code changes when moving a file. Delete the file, and create your new file with no changes, and merge - then make your code changes in the new file.

See the problem with git and move for more details.

Of course systems which don't use move detection by code similarity completely fail when people delete a file, and create a new file(eg. bzr).

So both git, and bzr fail when you forget to follow conventions. An ultimate system would do both - detect code moves automatically, and allow you to do explicit moves.

Update: Jay Parlar comment…

Why urlencoding is a good 'format' for ajax.

urlencoding works for most languages. eg, javascript, flash, python, php. So you can use it in a limited sense to encode stuff for transport.

eg. a script could return this:
a=3&r=hello+there&end=1

Streaming is the cool thing you can do that you can't really do with json, or xml. Well you can, but it's a tad harder. Decode/encode is really quick for urlencoding, and can be slightly better than json/xml.

This is an old trick that's been used in the flash world forever, but you can do it with js too(but no one seems to). Since not many people seem to be doing it in js, I thought I'd share the technique. Json is probably a better encoding to use most of the time, but this method has it's advantages.

With the partial data you download you can try to urldecode it. If you put markers in the data, then you can check up to that point.

eg.

at data == "a=3&r=hello+th"
You can tell that a=3 is correct, but not what r equals. You also no you aren't at…

Revision tracking of functions is more important than file names.

With git, and bazaar two differences are that one tracks code moves fairly well and one tracks file moves well. One was originally written mostly by someone managing a code base, and the other is originally written by a company doing an operating system. So you can see their priorities - one has lots of code it cares more about, and the other has a lot of files it cares more about. (There are quite a few other priorities and features that each have).

I guess tracking the code itself is much more important than tracking file renames - for me. Much more useful anyway.

However *both* are important parts of revision control.

Many times during development I might cut a function/class from one file and move it into another. I can't get reports of this information in a meaningful way with bazaar (or can I?).

Also I might accidentally move a file with the command line tools, change it, then add it in again to the revision control system. This is because I forget that I need to use the r…

My issues with python ORMs

If a python ORM you know of addresses these issues, please let me know.
Python ORMs break with multiple processes.
Multiple processes are not assumed. Python ORMs all seem to use heavy local caching, which fails when the database is modified by another process. This is unfortunate as for me I like to use different tools for different jobs. Or there might be different people I work with that write tools in different processes. Or even the common case that each web request is run in a different process - or on a different machine.

It is not commonly known that just because something outside of a python app changes a database that the python app will break. Most applications that use databases do not break if the database changes from outside of the application.

Using memcache or something like it seems to be a solution to some of this problem. Also optionally allowing the ORM to not cache certain queries - or even stopping all caching. Caching using python dicts is bad anyway, becaus…

europython 2007 - batching apis as applied to webpages

hellos,

http://rene.f0o.com/~rene/stuff/europython2007/website_batching/

Here's my paper and code for combining multiple images - and other things.

europython2007 - Taking advantage of multiple CPUs for games - simply

Here's my Multiple CPU paper I am presenting tomorrow morning at europython. The pdf on the europython website is a bit old.

Hope to see you there! ... if you're not too hung over.

Abstract:

Taking advantage of multiple CPUs for games --- simply, is the topic of this paper. Using a simple interface that many are already familiar with --- Pythons 'map' function. It talks about how to avoid the Global Interpreter Lock (GIL) limitation in Pythons threading libraries. As well as how to choose which parts of a game to thread. Finally it shows how easy it can be, by converting a full pygame to make use of multiple CPUs --- and benchmarking the game.

snakes on a phone - europython 2007

This talk was about Python on Nokia s60 phones.

These are my notes...

Discusses implementation details - like what they had to change to get it working nicely. He also discussed what you can do with the phone - which turns out to be most things. Like accessing the camera, and sending/receiving sms.

It's based on python 2.2, but has had some things back ported. Like the pymalloc. He said at some point they might update the python to a newer version. The schedule is 'The future - a closer future than before.'. Then of course before that he said 'the future is now' - probably those two statements aren't related, and were taken out of context.

Including not using writable static data, and the modifying interpreter for the security model on the phone. The security model includes using capabilities, and signing executables. There are different levels of signing certificates. The basic ones are free, but others require contracts and money.

By default as python can…

europython 2007 - hello from Vilnius

Image
Hellos,

I'm sitting at my hostel in Vilnius preparing for my presentations.

I've managed to get wireless internet working from windows here, but for some reason my linux doesn't like this particular access point.

After a marathon 38ish hour journey I arrived at almost midnight, then fell asleep. I spent half the day today wandering around the old town looking at things.

I'm looking forward to when the conference starts. Should be good to meet everyone, and see what everyone is up to.

Here's some pictures from my adventures in old town today...







Rugs

Image
I have been working on a virtual lounge room for www.rugsonline.com.au - an online rug shop. The owner (David), also has a real shop a few blocks from me, and is a young guy who's got good ideas about websites.

This is a flashy website where you can select a rug, some furniture, and some paintings by a local artist. So you can kind of see how the rug might look in a room of your own. I guess kind of like an Ikea catalogue where you can change the items in the photo.

You can also change the colour of the walls, the shadows of the room, and the type of floor under the rug.


The front part was made with flash - with a lot of action script.

One of the hard parts was doing a 3D transform of the photo of the rug. So it sat in the room with the correct perspective. All of the photos were taken over head, so the transform needed to be done to make the rugs look ok in the scene. Since all of the photos were already taken, retaking the photos from a different angle wasn't practical.

I…

php 5.x is four years old. php 4 is still used. Pygame with py3k?

A cautionary tale for py3k planners from the php situation with php 4, and php 5.

php4 is still so popular and widely used, even after four years.

py3k should really study the php situation in order to avoid repeating those mistakes.


I don't think python has that much legacy code out there compared to php, but I still think there is enough that python2.4, 2.5, and 2.6 will be around with us for ages.

This page lists the reasons for php4 still hanging around. php is often installed by the web hosts, not by individuals. This is the main benefit for php versus python. Php is already installed. However as it is hard to run both php4 and php5 at the same time guess which one gets installed? Php 4 gets installed, because of all the legacy applications which require php 4. Since there are 20-1000 web pages on a single host, if only 5% require php4 then that's what will be installed. Some major webhosts have just upgraded to php4 this year!!! (Media temple) Many open source proj…

qhtml, qurl, qsql, qjs

These are some easily remembered functions for quoting used in website programming.

Using the idea of consistency allows you to remember how to quote things. Just use the function with a q in front of it.

url quoting, html quoting, sql quoting, and javascript quoting are things that web developers do almost every day in some frameworks.

Please consider using these short cut functions in your web frame work. Maybe if quoting was easier to use then people would use it more often.

It's probably the next best step compared to quoting by default, and not needing to quote at all.

They should be top level functions as well so they are easy to use.

* Note, I also use qhtm as a shortcut for qhtml. Just like how htm and html are used for webservers. qjavascript would probably be another good alias - but not one I use. I don't use a qxml, since when writing xml I use more verbose forms for constructing xml - but maybe it would make sense too?

Abstract Base Class - a poor name. Role is better.

For someone new to programming, or maybe from a non-maths background 'Abstract Base Class' sounds foreign, and weird. Whereas Role rolls off the tongue - giving me language elegance goose bumps.

How many people can guess what an Abstract Base Class is from the name? Even given it's context of 'relating to objects'. I think more people could guess from the name Role.

Reading about Abstract Base Classes over time always gave me troubles. Even reading the PEP now I find it hard to answer the question 'What is an Abstract Base Class'. A simple question don't you think?

Maybe the name is too abstract.

When discussing objects to people I could talk about classes, then about instances, inheritance, and interfaces. When I begin to talk about Abstract Base Classes then blank looks jump out. Maybe it's that the name is so long. The abbreviation into the acronym ABC makes even less sense - as it is using an existing term and changing its meaning. Not that…

Pygame weekly mini sprint 2007/06/20

I spent some time looking at the FastRenderGroups code by DR0ID.

I sent a first review to the mailing list about FastRenderGroup. So we can discuss some of the things we need to do to it before getting into pygame. It has a number of features missing from the current pygame sprite code. Including being adaptable when updating the whole screen, or just parts of the screen is quicker, as well as layers and support for the new pygame blending modes (like additive blending).


ideasman_42 came along and noted a few reference counting bugs in pygame. He also plans to send in a patch with a few speed ups - by avoiding PyArg_ParseTuple when not needed, and using METH_NOARGS when appropriate.

I started on a mask.from_surface() function, but got caught up finding a bug when printing a surface. I think that was caused by the last set of changes to surface. I wrote a unittest for it, and submitted the bug to the mailing list.

Richard Goedeken submitted a patch for a smooth scaling function for p…

Webserver DOS, with linux move file - and broken file move semantics with webservers.

When a file is moved or removed on linux any processes with that file open still see the old file. So this means if you move a new 2 gig file over the top of an old 2 gig file, and some processes still have that file open there will be about 4 gigs of space used up - until the old file is closed.

Some webservers keep a file open for as long as the client is downloading it. Apache is one web server that does this. Some other webservers do not do this - like lighttpd.

The problem with reopening a file for smaller parts of a file as it is served to a web client - is that it breaks unix move semantics. The webclient will get a combination of both files, not one file or the other. This can be a problem in many cases. Consider a client downloading a html file that changes mid file. html tags won't balance up, and the client will download a syntactically invalid file.

So here is how a DOS can happen...

Say you have a big file mirror or something with lots of files that change fairly r…

Making Pygames more easily runnable.

Image
There are a few things which would allow pygames to be run more easily. I had a little chat with Phil the other day about where pygame could be heading. So these are some of the things we talked about. In case anyone else is interested.

First though, the why. Why should pygames be easier to run? So all of the people making games can have their friends and family play them. So they can get more feedback about them. People like feedback - feedback is an engine which drives people to work on something for fun. They create things in a way, and want to show the world. Or sometimes people make things to just show their friends and family. Or their peers. However do you want opinionated, uneducated game players giving you feedback? Isn't a nice little community of game developers a worthwhile thing? I don't want to lose our nice little pygame community of artistic folks. People interested in making small games, rather than working on engines - and 3D MMORPG web browser…

Validating XML with a DTD and python.

Image
Below is a way to validate an XML file using python and an external DTD.

Are there any other ways to do XML DTD validation with python?

A DTD is one way of specifying how an XML should be formed - a schema for XML documents.


from xml.parsers.xmlproc import xmlproc
from xml.parsers.xmlproc import xmlval
from xml.parsers.xmlproc import xmldtd

def validate_xml(xml_filename, dtd_filename):
"""Validate a given XML file with a given external DTD.
If the XML file is not valid, an exception will be
printed with an error message.
"""
dtd = xmldtd.load_dtd(dtd_filename)
parser = xmlproc.XMLProcessor()
parser.set_application(xmlval.ValidatingApp(dtd, parser))
parser.dtd = dtd
parser.ent = dtd
parser.parse_resource(xml_filename)


if __name__ == "__main__":
import sys
xml_filename, dtd_filename = sys.argv[1], sys.argv[2]
validate_xml(xml_filename, dtd_filename)






Written by a Melbourne web developer. Available for your p…

Pygame weekly mini sprint 2007/05/30

These are my notes from this weeks pygame mini sprint.

Fixed some documentation. mask, scrap, font modules.

Fixed the mask.set_at get_at functions to raise a nice exception. Thanks piman!

surface.fill() now takes the same BLEND_ADD BLEND_SUB etc flags that
surface.blit() takes. Which makes fade to white, and fade to black
type operations simple and fast. Thanks Marcus!!

Added the GL_SWAP_CONTROL constant from SDL. Thanks Eyal Lotem!

Added the new blitters from Marcus. These speed up the blend functions
and the alpha blit function.

Added a -warnings flag to setup.py for extra warnings with gcc.

A fix from Marcus for the scrap module in X11.

DR0ID has been working on a new sprite module which has a number of features. Including support for layers, and blend modes. It's supposed to be quite quick, and automatically detect if dirty rectangles will be faster, or a full screen update. DR0ID wants to make it compatible with the pygame.sprite.RenderUpdates so that people…

Pretty print xml with python - indenting xml.

Image
Here's a fairly simple way to pretty print xml with python. By pretty printing XML, I mean indenting XML with python nicely.

from xml.dom.ext import PrettyPrint
from xml.dom.ext.reader.Sax import FromXmlFile
import sys
doc = FromXmlFile(sys.argv[1])
PrettyPrint(doc, sys.stdout)


Are there any other ways to pretty print xml with python?

How do you pretty print xml with your favourite xml API? Pretty printing xml with ElementTree anyone?

UPDATE: there's a few other ways listed in the comments.



Written by a Melbourne web developer. Available for your projects - php, mysql, e commerce, javascript, CMS, css, flash, actionscript, python, games, postgresql, xml.

Pygame weekly mini sprint 2007/05/16

Image
This week there were a number of patches, and bug reports to the mailing list.

Marcus got to most of them - fixing up some 64bit issues, as well as some crashes with hardware surfaces inside the transform module. Thanks to John Myers, John Poppleweel, and Christopher Stone.

Marcus also added some more warnings for gcc. Which you can enable with the command:
python setup.py build -bigw

Marcus then went through and got rid of a bunch of problems that the warnings showed.


I committed sprite changes that John Krukoff proposed in an email to the mailing list last week. They allowed the sprite module to be extended with regards to collision detection. We fixed up a slight performance problem with it for the existing type of collision detection it does.

I started to look at adding the bitmask collision stuff into the sprite module - and then noticed we weren't using a lot of its functionality. Then we got onto discussing collision response... and I wrote another big email to the mailing l…

Pygame weekly mini sprint 2007/05/09

Image
In this weeks pygame mini sprint a few things got done.


Marcus has been working on the scrap module some more this week. He got image pasting working with the gimp. As well as got images working on windows. In the process of trying to get it working on MacOSX a mac got broken! oh noes!! Hopefully Bob can step up and do his MacOSX magic once more.


I worked on getting the bitmask library from Ulf Ekstrom integrated into pygame.

Pixel perfect collision detection is what it is good for. Since it is in C it runs very quickly too. The demo looks really cool, with things bouncing off each other.

It's in subversion now, but there's still a few things I need to do.

- make constructor which takes a surface.
- a 'make_from_surface' method in C. should take a threshold for alpha.
- complete the documentation (now in src/mask.doc)
- complete the unittests (test/test/mask_test.py)
- make set_at and get_at raise IndexError when wrong index is given.
- double check the reference counti…

Consistent variable names across different languages - for Webs.

Image
A dynamic website is often made up of at least three parts:
- html
- a server side programming language (eg python, php)
- a database

(* note, in the current web world, there's more than three. You probably have CSS, javascript, json, xmlprc, rss, and possibly many other encodings of a variable name.)


Why do people still use different variable names for the same data? The html form variable name, the programming variable name, and the database variable name.

Say you have a form which asks people to type their name in and their favourite colour.

<form>
First name <input type="text" name="first_name">
Favourite colour <input type="text" name="colour">
<input type="submit" name="submit" value="What is your favourite Colour?">
</form>


First name
Favourite colour



Now in the server side programming language they convert that to 'firstName' for some weird reason. That's one change that …

Pygame weekly mini sprint 2007/05/02

Image
Today I worked through the list of patches, and bug reports.

[BUG] fromstring,tostring work for alpha. Thanks Brian Fisher.
[BUG] Surf.set_clip(None) works correctly. Thanks Diego Essaya.
Scrap changes from Marcus so windows/osx compile.
Added scancode attribute to keyboard events. Thanks Quentin Smith.
[BUG] movie_set_display hangs on movie file-like object. Thanks Martin.

So there's a few new unittests in there for these bugs/patches too.

I think I'll finish my way through the remaining bugs, and patches next week. After that I want to resurrect movieext. movieext is a half finished module that uses ffmpeg to display movies. Also there are heaps of doc comments to look through. About 300 spam ones I reckon - but there's good stuff in there too. I also need to set my windows development environment up again. I'm hoping to fully document it this time, so that other people can get a windows pygame dev environment set up easily.

Marcus is trying to con…

One Speaker Per Child (OSPC) project.

Image
100 speakers. One for each person at a party.

Here's six mini usb sound cards attached to some usb hubs and extension cables.



The plan is to hook up 100 speakers to 50 sound cards attached to a bunch of linux computers connected via the network. Then using the OSC protocol to get them to act as one massive speaker system.

The cool thing is that there'll also be 50 microphone inputs.

I'm not sure what kind of limits I'll run into yet. It'll be interesting to see how many sound cards I can attach to each computer. Hopefully all 50 sound cards on one computer!




Written by a Melbourne web developer. Available for your projects - php, mysql, e commerce, javascript, CMS, css, flash, actionscript, python, games, postgresql, xml.

pygame - weekly mini development sprint.

Image
Marcus and I started up a weekly pygame sprint for a few hours on Wednesdays/Tuesdays.

Using this link you can find out what time it starts in other places:
http://www.worldtimeserver.com/time_converter.aspx?f=AU-VIC

Germany: Tuesday 10pm
UK: Tuesday 9pm
US: Tuesday 4pm
AU: Wednesday 6am

What happened in this weeks mini sprint

I collected all of the bugs and patches together onto a todo page. This took a while, so I didn't get that much work done on code things.

Marcus got the font metrics patch integrated. This allows pygame access to font metrics information. To understand what font metrics are read this. Pango seems to be the preferred way forward for fonts. There are plans for pygame support of Pango too.

The scrap clipboard module also got some love from Marcus. It's much more complete than the last version that's been in svn for a few months now. You can get all different types of clipboard data. I even managed to paste an image from The Gimp into my pygame program. T…

Backup option for apps. - web apps need it too.

Image
All of your web applications should have an automated backup - and restore procedure.

For web applications, allow your users to back up their accounts.

Luckily many web hosts have backup software enabled within their control panels (cpanel etc). So it's easy to set up automated backups from these control panels.

End users should also have the option of backing up their data. Just so they can have an extra piece of mind. If they stuff something up, they can just restore from a backup. Pretty simple.

An sql dump might not be the best backup format... although it's pretty good. Maybe you didn't separate your data for different users when you designed your database. So just doing a database dump might not be available. If you give them a database dump they might get other clients data. You might need to write a custom backup procedure - one which knows how your database is designed.

I guess this is why most web applications fail to give end users backups - All of the user …

Green PCs in open source, free software - the next challenge.

Image
Linux is seeing massive install bases around the world. Millions of PC computers - not including the millions of embedded systems like routers, and phones.

OSS, and free software already does a great job in reducing the amount of waste generated by computer use. Being able to make use of old hardware, and the ability efficiently virtualise computers resulting in less hardware being used. Web hosts can run thousands of websites off one computer - now other servers are taking virtualisation of computers for other tasks too.

However there is much more that could be done for saving energy with OSS, free software such as Linux, Debian, and Ubuntu.

Distributions need to focus on turning on the power saving features. If Debian, and Ubuntu make this easy, then lots of power can be saved in the world. Debian should put something about power consumption, and reducing resource use into its social contract.

Is concentrating on power savings worth while? If a 10% difference could be made in powe…