Password requirements WTF

November 23rd, 2009

Just trying to change my password for $COLLABORATOR’s network. Does anyone have any idea what sort of password would satisfy this? I’ve tried many, many different things :).

Your new password does not meet the following password policy requirements:

  • The password must contain: 0 lowercase characters, 0 uppercase characters, 2 alphabetic characters, 8 unique characters, at least 2 digits, digits in positions: 0, 0 ending digits, at least 2 special characters, special characters in positions: 0, 0 ending special characters. The check is case sensitive.

Update: I found the following command somehow generated a valid password:

$ dd if=/dev/urandom bs=10 count=1 2>/dev/null | uuencode - | head -2 | tail -1

Using Firtree from Python (part 2)

October 6th, 2009

Update: It appears the wordpress/LJ cross poster can’t handle indentation. I suggest you just download the full source from the link at the bottom.

Update 2: Fixed it (whit a bit of a hack).

This time we’ll learn how to use one of Firtree’s most powerful features: kernels. Firtree includes a little C-like language which can be used to specify image processing operations. In essence, it is a function that is called once per output pixel and is asked to compute the colour of that pixel. The kernel can, itself, make use of samplers just like a rendering engine.

Under the covers Firtree compiles all of your kernel functions (and it’s the samplers it uses) into one optimised machine code routine.

Firstly, we’ll write a Python function which can help us compile kernels. It takes a string containing some kernel source and returns a kernel and a sampler for that kernel. It also prints out an error log if you made a mistake in the syntax:

 Python |  copy code |? 
01
<pre>def compile_kernel(source):
02
        """
03
        A simple function which compiles a kernel, checks that the
04
        compilation succeeded and returns a pair containing the kernel and a
05
        sampler for it. 
06
        """
07
 
08
        kernel = ft.Kernel()
09
        kernel.compile_from_source(source)
10
        if not kernel.get_compile_status():
11
                print("Error compiling kernel:")
12
                print("\n".join(kernel.get_compile_log()))
13
                return
14
 
15
        kernel_sampler = ft.KernelSampler()
16
        kernel_sampler.set_kernel(kernel)
17
 
18
        return (kernel, kernel_sampler)</pre>

Now let’s actually create a kernel. I’m going to use the example of a desaturate kernel, essentially converting a colour image into a black and white one:

 Python |  copy code |? 
01
<pre># Create a desaturate kernel.
02
(desat, desat_sampler) = compile_kernel("""
03
        kernel vec4 desaturate(sampler src)
04
        {
05
                vec4 src_colour = unpremultiply( sample(src, samplerCoord(src)) );
06
                float luminance = dot(src_colour, vec4(0.299,0.587,0.114,0));
07
                return premultiply(
08
                        vec4(luminance,luminance,luminance,src_colour.a)
09
                );
10
        }
11
""")</pre>

The kernel language itself should be familiar to anyone who has programmed in C, GLSL or CoreImage. I’ll explain some of the functions we use:

  • [un]premultiply – Firtree uses a pre-multiplied representation internally. That is to say that the red, green and blue components of a colour are pre-multiplied by the alpha value. These functions can be used to undo and redo this operation.
  • sample – Call a sampler. It takes two parameters: one is the sampler to sample from and the second is a 2d vector specifying where to do so.
  • samplerCoord – Samplers have associated with them a co-ordinate transform. This function returns the co-ordinate in the sampler’s co-ordinate system of the current pixel.
  • dot – Perform a dot-product between two vectors. In this case, it takes the right combination of red, green and blue components to return a luminance value.

We now need to tell the kernel what sampler to use for ’src’. We do this with one line of Python:

 Python |  copy code |? 
1
# Wire the lena sampler into the desaturate kernel.
2
desat['src'] = lena_sampler

Finally we need to tell the CPU renderer to use the desat_sampler sampler instead of the Lena one:

 Python |  copy code |? 
1
<pre># Use the engine to render the output.
2
engine.set_sampler(desat_sampler)
3
engine.render_into_cairo_surface(
4
        lena_sampler.get_extent(),         # what area of the input to render
5
        output_surface                     # into what
6
        )</pre>

The output image is what we wanted, a desaturated version of Lena.

If one wanted to check that Firtree is indeed doing some work behind the scenes, we can get it to print out the compiled assembler for the function. Simply add the following line:

 Python |  copy code |? 
1
print(ft.debug_dump_cpu_renderer_asm(engine, ft.FORMAT_RGBA32))

Compating the resulting output to the kernel language input clearly shows how much easier it is writing image processing kernels in Firtree! :)

Next time, we’ll see how to chain kernels together and let Firtree worry about the details.

The full source code is available.

Using Firtree from Python (part 1)

October 6th, 2009

I’m going to write a set of blog posts all about how to use Firtree from Python. This post is about the simplest thing that you can do with Firtree, load an image and write it back out again.

To get Firtree on Ubuntu Karmic, you can add the Firtree PPA to your system and install the python-firtree package.

Firtree is based around the concept of a sampler. A sampler in essence knows how to get the colour of a pixel given it’s location. The location is specified as a 2d vector of floats and the colour is a 4d vector of floats. The colour is made up of the red, green, blue and alpha components scaled into the rage zero to one.

Our first example will load our input, the ubiquitous Lena, into a Cairo surface and create a sampler which knows how to get data out of that surface:

 Python |  copy code |? 
1
import cairo
2
import pyfirtree as ft
3
 
4
# Firstly, load the lena image
5
lena_surface = cairo.ImageSurface.create_from_png('lena.png')
6
 
7
# Create a sampler for the surface
8
lena_sampler = ft.CairoSurfaceSampler()
9
lena_sampler.set_cairo_surface(lena_surface)

So far, so easy. Firtree also has the concept of a renderer which knows how to run over each pixel in an output, ask the sampler for the appropriate pixel colour and write it out. Firtree ships with a CPU based renderer which uses LLVM to compile your pipeline down into efficient code and run it over all the CPUs in your machine. Let’s make use of that:

 Python |  copy code |? 
01
# Create an output surface similar to the input
02
output_surface = cairo.ImageSurface(
03
	cairo.FORMAT_ARGB32,
04
	lena_surface.get_width(),
05
	lena_surface.get_height() )
06
 
07
# Create a CPU render engine.
08
engine = ft.CpuRenderer()
09
 
10
# Use the engine to write the input to the output.
11
engine.set_sampler(lena_sampler)
12
engine.render_into_cairo_surface(
13
	lena_sampler.get_extent(), 	# what area of the input to render
14
	output_surface 			# into what
15
	)
16
 
17
# Write the output
18
output_surface.write_to_png('output.png')

And that is it, you have written some code that loads an input file and writes it back out to another file. Next time you’ll learn how to make use of the main feature of Firtree: image processing kernels.

The source code for this example is available.

Tomorrow’s World

September 14th, 2009

The BBC Archive have released a number of old Tomorrow’s World episodes. One particular episode has the infamous ‘beachball’ opening sequence. The moment I saw that I was immediately transported back to my childhood, having just got out of the bath (Tomorrow’s World day was bath day) and sitting downstairs freshly washed in a dressing gown.

Tomorrow’s World is one of my happy recollections of a time when the BBC’s science output actually excited and engaged me. The pre-Peter Snow and Phillipa Forrester Tomorrow’s World was an excellent programme that celebrated the innovation and optimism about technology before the cynical 90s killed it all. Similarly I remember the two-programme Horizon special on the Voyager space probes as an excellent high point before the ’single scientist against the world with strange camera angles and visual metaphors’ rot that has reduced the once proud flagship science programme into the stupid dumbed down claptrap is is now.

Blog moved server

September 14th, 2009

The canonical source for this blog has moved server. Hopefully all the cross-posting magic has retained its power. This post acts as a test for this :).

Twitter Weekly Updates for 2009-09-06

September 6th, 2009
  • Last show today. Good turn out and good show. We might even have made our money back! #
  • Back at work #
  • http://is.gd/2NMVu I think the Americans have a different idea of improv and humour to us. This is not the #captainimprov you’re looking for #
  • http://is.gd/2NN3o This *is* the #captainimprov you are looking for. I shall certainly attend. #
  • Pleased I had to foresight to bring a waterproof to work with me. I don’t need a mummy^Wgirlfriend any more! #
  • When did Virgin Media break DNS? Honestly, I go away for a bit… #
  • http://tinyurl.com/mray5q Dear Telegraph: No, Apple’s website did not pre-date the invention of the web by 4 years. #obviouslywrong #
  • @lukejostins: When it comes back up: http://is.gd/2PBA7 (see http://is.gd/2PBAT) in reply to lukejostins #
  • I really can’t wait for pub o’clock. Just finished draft 1 of a presentation. #
  • Have ordered a metric buggerload of brewing stuff. In 2 or 3 weeks I should have a load of cider and beer ready. #
  • http://is.gd/2PR4k Something fun to read when you get bored. #
  • Am off to the pub #
  • Good pubbage. I’ll never cease to be amazed at the gossip people can generate out of nothing though! #
  • Have spent all day using the most awful conference submission website ever created by man. #
  • Just installed xmonad and vimperator for Firefox. I am a happy bunny! #
  • Discovered I can upgrade to Snow Leopard for 8 quid… #
  • Is bored #
  • Just watched a programme about Blackadder. Made me feel a failure for not doing more acting/writing things :( #
  • @ohdontaskwhy Punternet.com is your friend here. #
  • There are now, oddly, too many people in my house making noise and mess :( #

Twitter Weekly Updates for 2009-08-30

August 30th, 2009
  • http://tinyurl.com/nl6d8c Some Steve-ers go to the seaside near Edinburgh #aihoae #fringe #ed2009 #
  • 1:50 am and suddenly the tube unclog and I get HSPDA. This is *after* I uploaded all the photos of course. #
  • 1Mbit down, 2Mbit up. I think my cunning compressing proxy confuses speedtest.net. #
  • http://tinyurl.com/ml9jme Photos of our dress rehearsal/tech get in #aihoae #
  • RT @aihoae: “Combining a dry, wry sense of humour with considerable intelligence…a charming, affable and enjoyable performance.” - 3weeks #

Second night in Edinburgh

August 24th, 2009

The second night in Edinburgh is about to begin. The first one doesn’t really count given that the entire day was pretty much lost to travelling. The train trip up was fun though. Having people to talk to, and space to breathe really does make a hell of a difference. The second leg (Stevenage to Edinburgh) took around 6 hours but I hardly noticed.

Today we had a bit of a practise in the morning followed by a relaxing day to prepare us for the stress to come. Laila, Alex, Jon and I went to the seaside. Photos of which can be seen on the Project Steve blog. After the beach, there was a well deserved pub.

I really love Edinburgh. The quality of the air up here is always so crisp and refreshing. Just breathing makes me feel like I’m cleaning my insides out.

Tomorrow is our get in. Luckily it is at the civilised time of 2pm but before that I have a publicity meeting with TSOB at 12pm and a Steve meeting at 10am. This, coupled with the inevitable flyering, means I should be pretty busy tomorrow.

The Internet connection here can be described as ’spotty at best’. My phone, when it has 3G + HSPDA is absolutely wonderful. When it has 2G, it sucks donkey balls. Luckily I have found a magic location within my room where 3G goodness can be had. One bar of goodness, but goodness nonetheless.

Twitter Weekly Updates for 2009-08-23

August 23rd, 2009
  • Preview of @aihoae last night. We were all very tired (as were the audience) but in general it could have been worse :). #
  • Lab cricket match and BBQ this evening. Cue the ominous clouds… #
  • My house is full of people having a far better time than I - poo. #
  • http://bit.ly/2hARQJ Trailer for OUAT. I wrote the trailer and a bit of the play. Am in the trailer but not the play. The entire credit goes #
  • Adium fails at counting chars. As I said, credit goes to Cat. #
  • http://is.gd/2mHT2 Shooting #script for the #ouat #trailer now available. Witness the stark beauty of the #celtx scriptwriting software. #
  • @MethodDan: Amen to that! in reply to MethodDan #
  • Siting in on an #ouat rehearsal for it now seems I’m understudying the generic guards. #
  • @jennielees 22nd Aug - 1st Sep in the ‘boro. Performing 25th-31st. in reply to jennielees #
  • http://tinyurl.com/lkfjpf The illustrius @Herring1967 lives my fantasy of going to retire somewhere comfy on Radio 4. #
  • Where did it all go! I’m now 89kg. Only 9kg to go… #
  • http://tinyurl.com/np2d9b FaceBook releases their patches to MySQL. #
  • Packing for Edinburgh. 80% of bag taken up with booklets and teeshirts… #
  • Looks like I can (physically) connect my phone to the new MacBook correctly. 1.5Mb of mobile intertron, woo. #
  • Someone last night said how slim I was looking. Made me a happy Rich. #
  • Argh!!! PyGObject in macports is Python 2.4, CMake by default links with Python 2.5. #
  • @raimue Thanks! Is this documented anywhere or shall I make a Google fodder blog post? #macports #problemsolved #
  • @jennielees Am in the ‘boro. Want to meet up? #
  • Only 2G in the flat :( - The tubes here are tiny. #

Problem solved: PyGObject versions on OS X

August 21st, 2009

If you, like me, are trying to port a big GObject-based codebase with Python bindings over to OS X you may have run into the problem that the py-gobject port links agains Python 2.4. If, like me, you use CMake as a build system you’ll know that it is tricky to persuade CMake to do the same. The solution is to install the py25-gobject port.