Topics › Python

SVG optimiser

I've started work on a program I've been meaning to make for a while: an SVG optimiser. I've often found myself spending a lot of time tidying, simplifying and compressing SVGs  created by Inkscape or Illustrator. Sometimes, changes are merely aesthetic, e.g. reducing numbers from an unnecessary six decimal places to one, or removing unused attributes. These changes make it easier to read the file, and can reduce its size noticeably. Other changes are more practical, such as removing transforms which otherwise make it difficult to see where paths and shapes are actually placed.

Simulating a demand curve

Recently, I've been watching the new microeconomics lectures at Khan Academy, which got me thinking about creating an economics simulation, something I've thought about many times. Specifically, I was wondering about how to come up with a reasonable demand curve. They always seem to be drawn as a straight line but with no justification other than simplicity.

How to get black hole badges on Khan Academy

I finally worked out how to get the black hole badges on Khan Academy. I have probably spent way too much time on Khan Academy, trying to get points and badges. I'm getting close to 2 million energy points and was hoping that that would be enough for a black hole badge. The main reason (other than wishful thinking) was that I read on a developer's blog that only one person had ever got one, and 2 million seemed like a sufficiently large, but not improbably large total.

Pygame particle simulation in 3D

Below is a video of my first attempt to move my Pygame particle simulation into the third dimension (thus combining it with my Pygame 3D tutorial). I meant to write about it a while ago, but got distracted trying to work out how to display an image rotated in three dimension (for the walls). I still haven't worked it out.

Cell evolution game - basic interface

Today I started to make a game that I've been thinking about for a quite a while now (I mention here). The general idea is that you play as a single-celled microbe which evolves ever more complex metabolic and regulatory systems as it moves to ever more challenging environments. It's related to my cell simulation, but you get to choose how the cell evolves (so it's not really evolution).

Pygame Landscape generator

Today I came across this page, which contain many interesting things, including some sections on generating landscapes in a procedural way. I'd been meaning to try this for a while and I finally got around to it.

Python regression finder

I've been working my way through Stanford's online Machine Learning course recently and I thought I should put some of what I've learnt to use.

The program I made (file below) reads a file of tab-delimited data, assuming the first column is the independent values (x) and the second is the dependent values (y). It then gives some options:

Python SVG writer

I've written dozens of different Python programs that write SVGs of various types, so I thought it was about time I wrote a single generic module to make writing SVGs easy. Unsurprisingly, I'm not the only person to have had this idea, but rather than try to learn how to use someone else's module, I decided to write my one. It's more fun anyway. If anyone else wants to use the module it's available to download (and edit) on Github:

https://github.com/petercollingridge/DrawSVG

Python Fibonacci generator using reduce()

Khan Academy now has a series of videos on Python programming, and I've spent way too much of this weekend watching them, despite knowing all the basics of Python (I did learn a couple of things though). In fact, I spent so much time watching video, I finally broke the million point mark (and now have 77 points in binary):

My million points on Khan

Retrospectroscope

Today I wrote a small Python program that is likely to be of interest to almost no one else. Still, I like it because it uses modules I've not used much before and has the potential to be very useful if only could think of a suitable project. The program goes to Victoria's blog and find out what she was doing this time last year by parsing the relavant page in her Today section.