Diagrams 2010 – day 0 (well, mostly -1)

August 8th, 2010 by balor

We arrived in Portland, Oregon last night (local time) after a 23 hour trip from London. My first impressions of this city are very positive. We’re on the Portland State University campus, which is it’s own – couple of square blocks – district about a 20 minute walk from the centre of down town. The rooms are large, clean and have lots of services.

Portland appears to have a very good public transport system. Buses are a common site and there’s a train/metro system. Furthermore, cycling seems to be actively encouraged through public notices. This morning I witnessed a cycling event over the bridges which must have had several thousand participants. Other than public transport, recycling appears to be taken as a core civic responsibility. I suppose, I get the feeling that Portland has an outlook that chimes with my European biases. Unfortunately, like many US cities I’ve visited, there seems to be a very visible population of homeless people. Again, my Euro-social-safteynet bias kicks in and I assume that the proportion of homeless people in Dublin/London/Berlin is lower.

There’s a food festival today, which I intend to attend. Portland is also noted for it’s numerous micro-breweries. In order to escape the effects of jet-lag, we partook in a sampling of the local Ale specialities last night. And as a food and beer lover I was impressed. Moreso by the beer than the food, however I’ve high expectations from the food festival today. It was recommended by some locals we got talking to in one of the Ale establishments. For what it’s worth, in the 15 hours or so that I’ve spent here I’ve only encountered friendly people.

And the blurry image reveals…

June 11th, 2010 by balor

The blurry image below is of the shiny new baby that Lorraine is expecting. This development is on an aggressive time/feature based release cycle and is due in time for the Christmas market . This baby reflects a 100% growth in our child portfolio.

Our last experience having Cillian on the publicly funded NHS was brilliant. So far it appears that the standard of maternity care has maintained it’s excellence. We’ve met the midwife and (obviously) been in for a scan. It may be hard for some people (particularly USians) to understand the depth of appreciation British society has for the NHS (it took me a while to learn this). Sufficing to say that there were massive protests last year when local maternity services were threatened with cuts. Nothing gets the British onto the streets quicker than poll tax, illegal wars and threats to the NHS.

A lib2geom braindump

April 30th, 2010 by balor

I’m hacking with lib2geom, the base geometry library that underlies Inkscape. I don’t understand a lot of it, so here’s a braindump of what I’ve figured out now. I’ll modify it as I figure out where I’m wrong. (We’re all n00bs all the time :) )

A user inputting using a mouse or pen device can click and drag. On click we record a sequence of points in device coordinates until the user releases the mouse button. However close these recorded points are, they are not a continuous function. If you zoom in close enough, there are gaps between the points. In order to solve this problem we interpolate between the points. We’re – effectively – guessing the path of the mouse/pen movement in real space (i.e. R^2) as we can’t know the real function.

There are several ways to interpolate. The most common using cubic or Bezier curves. We fit an n-order polynomial between each pair of points. To ensure the smoothness of the curve we insist that either the first or second derivative (or both derivatives) of the join is a continuous function. Thus fitting multiple cubics to a set of points results in a cubic-spline. Fitting multiple Bezier curves to a set of points results in a Bezier-spline. It is common for graphics APIs to allow curve representation using non-uniform rational B-splines.

Recently [2000] S-power basis functions were proposed as a basic building building block of splines. Inkscape represents interpolated input strokes as sequences of pairs of S-power basis functions (SBasis functions in lib2geom speak).

Each SBasis function is lifted into two dimensions. Thus a D2 function (from the documentation) “provides a 2d parametric function which maps t to a point x(t) y(t)” [[Todo: Explain This With a Diagram]]. A sequence of D2 functions, as interpolated from input pen strokes, is a Piecewise<D2 >. A Piecewise has the added advantage of storing the temporal nature of the input points.

Iterating through a Piecewise<D2 >:
Piecewises are useful for two reasons
(a) we may compute very high fidelity operations such as dot product, and
(b) we may compute stuff that uses the temporal information stored in a Piecewise.
For general computation, such as computing the intersection of a Piecewise and a primitive shape, we need to build Paths from our Piecewise. The joins between the splines in a Piecewise are called knots. The following builds a Path from a Piecewise (with thanks to Johan Engelen):

// Where spline_path is a Piecewise<D2 >
Geom::Point knot = spline_path[i].at0();
Geom::Path path = Geom::Path(knot);
for (unsigned i=0; i < spline_path.size(); i++) {
path.append(spline_path[i]);
}

Eight years (really!) since MiNDS>

January 4th, 2010 by balor

As an undergrad I was quite active in the NUI Maynooth IT society. We called it MiNDS>. Though These days it’s written as Minds. I have a soft spot for Rowan Nairn’s original site design and logo featuring that angular bracket. To my surprise I was recently contacted by some guy wanting to talk to MiNDS>. I think he was flogging SEO, however I pointed him at the committee email address. I don’t run MiNDS> anymore. But I did write a small paragraph on why the committee may not reply to him on the subject of SEO. It makes for good reading as to the personal accomplishments of several alumni.

“Many of our past members are the technical plumbers for both the Google and Amazon Irish operations. At least one of our alumnus works in the PowerSet team that develops an engine that Microsoft are integrating with Bing. Furthermore, several other alumni members have completed PhDs in the area of heterogeneous distributed searching and sorting and several others own web development and SEO firms. We’re bursting at the seams with high-quality talent.”

And that’s just from the people I know about. I’m getting all teary eyed thinking about days in the Union, modding Athlons into MPs and general mayhem. Someone should write an official history. Maybe I can meet Mags for a coffee some day and get the story about the founding. I was at the meeting that she took over from the postgrads (or I believe I was) but I don’t remember the whole story.

A C++ Cheat Sheet

October 4th, 2009 by balor

Many of my students have small, niggling issues with C++ syntax -v- Java syntax. I’ve put together a syntax cheat sheet.

c++-crib-sheet, now updated with all the feedback from comments. Thanks a lot.

I’d appreciate it if people could point out errors and omissions.

Feeding cheese to monkeys

July 28th, 2009 by balor

Sometimes you’ve got a monkey and he won’t sit still. How do you manage to take a picture of him? The answer is simple. Feed him cheese. Try our non-patented, copylefted Cheese, now with burst mode support.

Example:



Organising unit tests in Haskell

July 5th, 2009 by balor

I’ve had a lot on my plate recently so I’ve gone a bit underground. The DTubes stuff is still limping along, but it turns out that I wasn’t the only one with that idea and that others seem to be working on it with much more gusto. Banshee now supports sharing your playlist over DTubes i.e. with all your IM contacts. I don’t use Banshee, but this feature could convert me to their cause. My timelapse patch for Cheese will hopefully be finished today, or at least early next week.

What has been occupying most of my time (apart from Monster and research) is getting into this Haskell thing. I’m coming in through the back door I suppose. I’ve taken over maintenance of a Haskell library for automata theory. I’ve largely given up on libAMoRE, the codebase is featurefull but a nightmare to maintain. It’s time to start over, and in a higher level language than C. Luckily Prof. Simon Thompson from the University of Kent already had an automata library. It’s the minix of automata libraries as it strives for understandable code over micro-optimisation. It is also written in Haskell. He was even happy to relicence it to me under the BSD-new. You can find the code for Mira here.

Which leads me to unit testing. I’ve got a thing for unit testing. Eric has previously blogged about it. However, it didn’t answer one or two of my questions. Actually, it’s more to do with my testing style.

Say I have a file called BuildNfa.hs or alternatively BuildNfa.java, or BuildNfa.py. I like to then have my test file for that unit in a subdirectory called tests with filename TestBuildNfa.hs. Then I want one main file that will run all the tests for the entire project. Furthermore, I tend to just use the xUnit clone for the particular language I’m working with, and the native build system. So for Haskell this means using HUnit as the testing framework and Cabal for the build system.

My source files are in a directory called Mira and the tests are in a subdirectory Mira/Tests. For some reason Haskell insisted that the subdirectory start with a capital letter. Now I’m a total Haskell n00b, so this may simply have been a mistake or a lack of understanding on my part.

I stole/borrowed/attributed the Cabal Setup.hs from some happy hacker called Holden. Thanks Holden. My entire Setup.hs file looks like

import Distribution.Simple
import Distribution.PackageDescription(PackageDescription)
import Distribution.Simple.LocalBuildInfo(LocalBuildInfo)
import System.Cmd(system)
import Distribution.Simple.LocalBuildInfo

main = defaultMainWithHooks (simpleUserHooks {runTests = runzeTests})

runzeTests:: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO ()
runzeTests a b pd lb = system ( "runhaskell ./Tests/RunTests.hs") >> return()

Which implies that I have the file Tests/RunTests.hs as my mainline for running all my project tests.

Each test in the project has the following form

module Tests.TestBuildNfa
where

import Test.HUnit

.
.
.

suite =
TestList [TestLabel "Simple Nfa Or construction" test_simple_or]

So each Unit test has a function called suite which builds a list of tests.

Thus the runner file

module RunTests
where

import Test.HUnit
import Tests.TestBuildNfa as TestBuildNfa

main =
runTestTT TestBuildNfa.suite

need only import each “test suite” and call the HUnit function runTestTT on it.

Now I’m unsure if this is a good Haskellish way of doing unit testing, but it chimes with my experience from C, C++, Java, Python, Perl and a few other languages. It also sets up a structure for organising unit tests that is a little more extensible than other setups I’ve seen on the Interwebs. Many other people lob all their tests into one file. I simply don’t like that approach. Using this approach a simple runhaskell Setup.hs test will build and run all the tests for your project.

So, still hacking and am interested in two short term code related goals

  1. looking at literal Haskell, and
  2. getting my cheese timelapse feature finished.

And in the more medium term (i.e. over the summer) I have the following goals:

  • Have a look at how C# and F# can be integrated so that C# does the UI and F# the logic.
  • Repackage my spu-gcc, spu-newlib and update my gallium3d package for Fedora 11 on PS3.
  • Package OpenSG for Fedora.
  • That’s on top of trying to finish my Ph.D. and actually have a holiday this year. I’m visiting Vienna with my wife but intend to take my netbook along to hack on thesis.

Ghosts in DTubes

April 26th, 2009 by balor

I’ve been playing around with an idea for a few weeks. It’s evolved into something that I can actually hack on. The idea solves two problems

  • sharing my photos with my wife, and
  • to select only a subset of my files on my netbook.

It may be complete UI-crack, but you’ll be the judge of that.

A ghost is a set of metadata about a file. For example, a photo has a thumbnail and a set of tags. I can download all the meta-data for my wife’s photo collection onto my laptop. Ghosts are represented graphically in some manner. For example, in the F-Spot UI ghosts of my wife’s photos could show up in greyscale at 50% transparency. You can imagine a similar UI for music files in rhythmbox. I imagine the actual files, that the ghosts represent, are downloaded on-demand by me. This solves my netbook probem (a problem I call “the subset problem”) by allowing me to easily download images and music to my netbook from my laptop.

Both of these problems can be solved by putting a server between me and my wife. But life’s too short for that. And there’s an existing set of cool technologies in Gnome which can be used to implement a p2p(ish) solution.

Maybe I’m not great at explaining the high-level stuff. If you don’t have a wife it may be difficult to understand that her photo collection and mine are actually the same collection. We just use our laptops to “interface” with the collection. We could use a site like Flickr to combine our collection. However, Flickr doesn’t allow me to share gigs of data. And the upload/download bandwidth is generally slower than our LAN speeds that we would achieve when we’re both on our home network. Also, if you don’t have a netbook it’s hard to understand what I’m talking about. Sometimes I’ll want to travel home to my parents and bring my netbook with only photos of my son and some Bach to listen to on the journey. I can’t fit my entire photo collection and music collection on the netbook.

Anyway…the solution currently passes Ghosts (only F-Spot photos at the moment) over a DTube. A DTube can be opened between two XMPP users (think Jabber or Google Talk) and you can pass arbitrary DBus objects over it. I’ve implemented Alice who shares her photo collection with the Hatter. The Hatter has a very crude Clutter based presentation of the Ghosts. The code is at the experimental-proof-of-concept stage. I’m now wondering how to further this. Should I implement a “ghost://” GVFS backend?

Code is here. It’s not pretty, and you’ll have to change the jabber id’s in the source. Helping to put the Network back into GNOME, one idea at a time :)

Reintereact looks interesting

March 27th, 2009 by balor

As a long time octave user I was intrigued when I came across Reinteract. Reinteract appears to leverage the power of mathplotlib in an easy-to-use interface. Where easy-to-use is a very relative term for an advanced maths graphing package. You obviously still have to understand the underlying maths.

Twecipe day 17: The end of the line

March 17th, 2009 by balor

Happy Paddys day. I’m in a strange and distant land, so I have to work through it. I’d really love to be in a decent pub with a pint of plain.

I’ve not finished this Twecipe challenge that I’ve set myself, but I think I’m going to leave it at day 17. I’m beginning to find it a bit limiting – in a strange kind of way. I want to go more down the route of a poor-man’s haute cuisine for a while. To this end I cooked steak with sautee potatoes with a mayonnaise last night. I made bruschetta for two for starter aswel.

My presentation needs to be improved a lot. And I need to put a lot more effort into being precise. But the dish was nice and the basic mayonnaise was tasty.