Archive for April, 2009

More fun with xsel

Monday, April 6th, 2009

Bind this to a keyboard shortcut:

xsel -i | pastebinit | xsel -o

It takes the current selection buffer, dumps it to a pastebin (pastebin.com by default) and replaces the contents of the selection buffer with the URL of the paste, ready for you to use anywhere.  Works in any program you like.

planet scala now on github

Sunday, April 5th, 2009

We were talking in #scala about how there was a bunch of infrastructure work I’m supposed to do on Planet Scala but probably never will. They’re basically all to do with the web frontend aspect of it – a logo, a bunch of style oddities, etc.

Thing is, I really don’t care about the web frontend. As far as I’m concerned, planet scala is a feed aggregator that happens to have a web page. I’m not going to take it away or anything – clearly a lot of people like to use it – but it rather discourages me from putting a lot of effort into it. Additionally, I hate doing web development. So there’s not much chance of me actually ever making the web frontend great.

What I really need is someone else to do it for me. Someone who actually cares about the web page, is good at it and has the time to work on it.

If only there were some way of getting a distributed group of programmers with disparate interests to collaborate on a project…

So, planet scala is now available for you to hack on. Feel free to have a play, see if you can get yourself happy with the results, then see if you can get me happy with them so I merge them in to the main planet scala.

Scala trivia of the day: Traits can extend classes

Sunday, April 5th, 2009

A lot of people seem to not know this. In particular 90% of use of self types I’ve seen appear to exist solely because people do not know this.

Observe the following interpreter session:

scala> class Foo;
defined class Foo

scala> class Bar;
defined class Bar

scala> trait Stuff extends Foo;
defined trait Stuff

scala> new Foo with Stuff;
res0: Foo with Stuff = $anon$1@148b272

scala> new Bar with Stuff;
<console>:8: error: illegal inheritance; superclass Bar
 is not a subclass of the superclass Foo
 of the mixin trait Stuff
       new Bar with Stuff;
                    ^

You can basically view this as putting a constraint on the trait, saying that all classes that implement this trait must extend this superclass. This can be particularly useful for adding various sorts of behaviour to classes. e.g. traits which add behaviours to GUI components.

Thus ends our public service announcement.

A workaround for misbehaving X citizens

Wednesday, April 1st, 2009

Some programs (most notably amongst those I use firefox and pidgin) don’t work properly with shift-insert for pasting from the primary X Selection. If you’re like me and virtually live in the command line, this is a real pain in the ass. It became more of a pain in the ass recently because I’ve started using a graphics tablet instead of a mouse, so no longer have a middle click. I could no longer paste from IRC into firefox.

After some hacking around, I settled on the following solution. “xsel -o -p | xsel -i -b” dumps the primary X selection into the clipboard (xsel is a nice little application. You should probably have it installed). So I’ve bound this to a shortcut in xmonad and now can at the press of a magic key combination take the current selection and make it pasteable. Hurray.