Daily graphic 2

Todays daily graphic I'm getting familiar with grids (in shoebot), Vector maths from the planar library .. this started from the grid example from shoebot / nodebox.

Shoebot Code Below the fold

Everyday graphic

Not sure how practical it is, but will try and upload a new graphic everyday .. to start with will probably be quite basic 🙂 Here is the first, some moving granular thingies..


Shoebot code:

import random
from math import sin, cos

size(800, 800)

def draw():
    scale(1, 1)
    fill(0.1, 0.2, 0.3)

    for y in xrange(0, HEIGHT, 80):
        wiggle = sin(FRAME * 0.1)
        xs = 2.0 + (cos(y * 0.1) + sin(y) * 8.1)

        distance = 1.0 / HEIGHT * y
        fill(1.0, 1.0-distance, 0, distance)
        for x in xrange(0, 60):
            xpos = ((xs * FRAME-x * 40) % (WIDTH + 40)) - 20
            circle(xpos, y + (wiggle * random.random() * 20.0), 20 + (wiggle * 2.0) * distance * 8.0)

        #xs = -sin(y) * 4.0
        #for x in xrange(0, 60):
        #    circle(WIDTH-xs * WIDTH - FRAME + x * 40, y+40, 20)

To run this, install shoebot and type: sbot -w granuals.sbot

Workflow for debugging issues on python on windows with a VM

Recently I had to look at an issue where the behaviour on windows was subtly different to that on linux... unfortunately most potential users are on Windows so it's not good enough to just write them off 🙂

This workflow was quite good for checking python internals on different versions of python and being able to revert things easily.

To get things going quickly I use the IE11 VM from microsoft, and download from xdissent


That way you just need to enter a command to download it

curl -s https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh | env IEVMS_VERSIONS="11" bash

Next I install all the tools I need before python (we will save the state of the VM before then).

chocolatey.org makes installing tools easy*


Open a command Window as Administrator then install chocolatey:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

Once thats done you can install tools you need - I install everything *except* python:

choco install git conemu

While these are installing start the downloads for python and it's C compiler (remember not to install them yet):

Grab python from here:

For python 2.7.x you will probably need the VC compiler

My app was for PyGtk so I also downloaded that - download anything else you need at this stage.

Download your project...
Using git or whatever, grab your own project to a directory.

Save the VM state.
In virtualbox save the machine state, I called mine 'Tools Installed'.

From here you can install python + know that you can poke around in the internals, any time you want to check against a different version, just revert the VM to the previous state.


TL;DR - Install all tools except python, grab projects, SNAPSHOT, install python - find bugs.

*when it works.

Setting up Backups

A day of Admin .. Spent a good amount of time getting backups setup on ubuntu .. Insynch to backup google drive to my computer - https://www.insynchq.com/ Setup good old Thunderbird to download email to my computer - the trick is to get an an app specific password. Finally, bought cloud backup from SpiderOak it seems quite good from a security point of view, the app itself is a little 'java', but seems to work OK.

Docker and caching apt-get for guests on the same host

Docker is great for isolation, you probably still want some caching, the Dockerfile from extellisys is a great start: https://github.com/extellisys/docker-image-apt-cacher-ng Running the above, runs apt-cache-ng and exposes it's port as 3142. This is great for a LAN, if you want to use this for caching on your dev box then read on. If you just want lines to paste into other Dockerfiles, skip to the end.
To avoid surprises I tend to change the "FROM" part of any Ubuntu or Debian based Dockerfiles to use the same distro as the host (in this case "ubuntu:14.10"), this should save a little space too.

Optionally use the cache with Docker guests on the same host.

Desired result - use the cache if available, otherwise don't. Avahi is the usual way to do this, unfortunately it doesn't work easily in between host and guest. We can make our own way of doing this. So all we need to do is find the host IP from another guest -
$ route -n | awk '/^ {print $2}'
The other part is optionally using a proxy - the undocumented apt.conf.d setting Acquire::http::ProxyAutoDetect is what we want. It runs a discovery script that either outputs an IP of a proxy, or DIRECT if there is none.

Discovery script and setting

 HOST_IP=$(route -n | awk '/^ {print $2}')
 if nc -w1 -z $HOST_IP 3142; then printf http://$HOST_IP:3142; else printf DIRECT; fi
 Acquire::http::ProxyAutoDetect "/usr/local/bin/apt-ng-host-discover";

Putting it together / tl;dr;

Everything can be munged into 5 lines you paste into your Dockerfile:
 RUN HOST_IP=$(route -n | awk '/^ {print $2}'); \
 echo "#!/bin/bash" > /usr/local/bin/apt-ng-host-discover; \
 echo "if nc -w1 -z $HOST_IP 3142; then printf http://$HOST_IP:3142; else printf DIRECT; fi" >> /usr/local/bin/apt-ng-host-discover && \
 chmod +x /usr/local/bin/apt-ng-host-discover
 RUN echo 'Acquire::http::ProxyAutoDetect "/usr/local/bin/apt-ng-host-discover";' > /etc/apt/apt.conf.d/30proxy

Further work

Run the extellisys cache on boot, and disable any other caching ( http://ask.xmodulo.com/disable-apt-cache-debian-ubuntu.html ).

3d in the era of J2me

Back in the deep dark past (2004-2007) I worked on a 3D game for phones of that era (before iphone, android). I recently found some of the test files for the engine, here are some videos.


Very low poly racetrack


The ubiquitous cube


Spacekid in the spacestation corridors

Our Mascot wanders the corridors .. you can't look too far ahead, to keep things really low, which means popup is a little...severe.
Movement is a better in reality - the capture has made the movement a bit jerky.

Dire Straits

Obviously we didn't make this, but it heavily inspired our 3D engine ... textures were just too slow, so we aimed for this look.

Belated post on libregraphics meeting 2014

Here is my very late post on LGM 2014! Back in April I went to Leipzig for my first in-the-flesh meeting of Shoebot devs .. I met with Ricardo + to collaborate on a workshop on shoebot. To make it more fun we hadn't decided what to do it on ! In the anarchic OSP (open source publishing) house we came with a plan to get people making examples for shoebot. Luckily Ricardo had done a lot of this sort of thing before so did most of the talking, then I showed off some bots - evolution, spirals and also the livecoding work. Overall the workshop seemed to go over well; we got a bunch of examples, and there was even a plugin for sublime text !

Things that came out of the workshop:

People want an integrated editor - this is OK, since the IDE still exists. Differences between the Nodebox/Shoebot API and Cairo are not always intuitive. Livecoding is cool! Shoebot 2 ... or something else ? Going forward, it might be best to take the Nodebox approach and build something new based on these lessons, I'm not sure exactly what yet. What is the most intuitive API, how can we be close to standard APIs.

Non Shoebot Stuff

Outside of the workshops and talks there were plenty of time to drink and chat - apart from talking the head off of one of the mypaint guys I learned quite a lot about OSP off Sarah Magnan and Brendan Howell .. which made me regret missing many of their talks, including Brendans on the screenless office. Leipzig was a really great city to visit, the venue for LGM was particularly impressive being inside an old church that the East Germans repurposed to a university. Importantly for me I learned about the "kebab circle" - the ring of gentrification moving from the inside of the city outwards (beyond which you can still buy kebabs). With any luck LGM will be able to make it next year and meet everyone again.

Drawing to the same content to many windows, cairo and zeromq

Playing with python, zeromq and Gtk, I made this code to send graphics commands to several windows.

Commands are sent over a zeromq PUB socket, the windows recieve them using zeromq SUB.

Only a few commands are wrapped as it's a proof of concept.

I'll clean it up and abstract some bits and it should be quite easy for building something like a live coding environment.

Screenshot from 2013-06-15 19:19:37

See below for code -

Posted code to github, update to work with multiprocessing.




Shoebot experiment – perlin noise..

Perlin noise is pretty cool, you can use it to generate realistic looking clouds or mountains. Here's a bot for shoebot I made a while back that uses perlin noise to generate some nice circles. You'll need shoebot and the lib "noise" installed into your environment for it to work;
# pip install noise
Then to run;
sbot -w perlin-circlescape1.bot
Here's a video of them in action - See below the break for the code - (more…)