Toxic Elephant

Don't bury it in your back yard!

Implemented in X

Posted by matijs 15/04/2010 at 05h42

You can implement a programming language in assembly. C is an example. This has the advantage of being able to leave your language and use assembly when necessary. You drop down to assembly for speed.

You can also implement a programming language in lisp. CLPython is an example. This has the advantage of being able to leave your language and use lisp when necessary. You drop down to lisp for expressiveness.

If lisp is the ultimate language, does this not make it the best option for implementing other languages?

Tags no comments Trackbacks

Creating My Own URL Shortener

Posted by matijs 11/04/2010 at 12h22

Because URL shortening services can go away at any time, I decided to install my own. In the spirit of your-own-dogfood, and to make hacking it as enjoyable as possible, it had to be in Ruby (this ruled out YOURLS, which otherwise does exactly what I want). There are tons of URL shortening projects in Ruby on GitHub. Unfortunately, they all lacked one feature: password protection for the adding of URLs. In the end, I picked a nice simple one and changed it to my liking. The result can be found in my fork of turl.

Why is this safer than using one of the existing services? The reason went under is that they couldn't make it pay for itself, and there was a lot of abuse from spammers. Both problems are absent for my own service: I don't need to make any money off of it, and I'm the only one who can create new short URLs.

Some observations on developing this software:

  • For a small project like this, putting everything in one file is very, very nice. Ramaze allows you to do this (as do other frameworks), Ruby on Rails does not. I wonder how seamless the transition is if your project starts small like this and then gradually becomes big enough that you need to split it into different files.

  • Ramaze's documentation needs some love. Everything is documented well in principle, but with the split-off of the innate library, it took me ages to find the documentation for the a method and friends.

  • I really like the idea of [Sequel][sq]::Model where you define the table schema right in the model. I'm not sure how or how well it works with migrations, but for a small project like this, it's nice and clean.

  • Ramaze could use some more options for session storage. In particular, something file-based shouldn't be too much to ask for. I'm using the LocalMemCache option, and keep having to log in.

I really like Ramaze, and am eager to try Sinatra. I have been ignoring these more light-weight frameworks for far too long.

Tags , 1 comment Trackbacks

Quote of the Day

Posted by matijs 18/02/2010 at 19h15

Efficiency without ethics is psychopathic

Pecking Order by Peter Lennox via Kottke

Tags no comments Trackbacks


Posted by matijs 02/02/2010 at 09h20

Daring Fireball quotes Zeldman:

Flash won’t die tomorrow, but plug-in technology is on its way out.

Exactly. And good riddance.

Tags , no comments Trackbacks

Training People to Just Click Anything

Posted by matijs 31/01/2010 at 12h18

Today I got an email from someone using a hotmail account. At the bottom was the following text:

Hotmail: Trusted email with Microsoft’s powerful SPAM protection. Sign up now.

The text “Sign up now” links to a URL that is completely opaque. Not in the old-style non-Web-2.0 company website way, where at least the domain name would tell you it’s a legitimate link to one of the company’s websites. No, it’s domain part was

If we/they/whoever expect people to click such links, how can we ever expect people stop clicking links like

It’s almost as bad as training people to give their email login and password to any site that asks them to.

Tags no comments Trackbacks

Tab Sweep: Monads

Posted by matijs 29/01/2010 at 12h47

Learning about monads is hard, and there seems to be no magic pill. Probably one reason is that they have several different uses. Many articles focus on one of those uses, making it hard to get the whole picture. On the other hand, articles that try to directly explain what monads are leave the reader wandering what they're good for. Some links.

  • Brent Yorgey argues that any shortcut by focusing on a particular metaphor (e.g., monads are like burritos) will not work.
  • Mark Dominus argues why monads are indeed like burritos.
  • [Monads as Containers][cont] fits in nicely by abstracting away from burritos (or space suits) to containers. It goes on to talk about how this relates to IO and other uses for monads. I'm still working on reading through this article.
  • sigfpe starts from the other end, showing how certain needs could automatically lead to monads. I haven't finished that one either, but so far it's been very insightful.
  • I also found The Continuation Monad in Clojure very insightful. Again, it focuses more in the use and implementation, rather than abstract theory. I'm not yet sure whether the insights I myself got from it are actually correct. More on that later, perhaps.

Tags no comments Trackbacks

How to Get Apache and Typo Page Caching to Play Nice

Posted by matijs 13/12/2009 at 18h58

The Problem

You have been running a Typo blog [since 2005][since], but you still can’t quite get your Apache configuration right. In particular, you still get the occasional

Not found:

Note the weird 07.html part.

Tags , , no comments Trackbacks

Photos from Tokyo

Posted by matijs 29/11/2009 at 10h56

We recently returned from a trip to visit Naoko’s parents in Tokyo. We took lots of pictures. Here are some of them.

Bowl of Ramen with bean sprouts and a slice of pork

A nice bowl of ramen with creamy broth, crunchy bean sprouts and delicious soft pork. I love ramen.

Bride in traditional Japanese wedding kimono

A wedding at Meiji Shrine. We went to the shrine during Shichi-Go-San, so there were lots of little girls and a couple of little boys all dressed up in kimono. Our daughter, having just turned three, was one of them.

Close-up of red autumn leaves of the Japanses maple

Of course, it is the season of beautiful autumn leaves. It is actually quite hard to capture the beauty of these maples.

Female Nephila clavata, seen from below

This picture of a female Nephila clavata spider was taken near Chichibu. This one measured about 6 or 7 cm diameter (including legs). One of the locals told us that they let the spiders fight each other for entertainment. Of the locals, that is.

Pile of small raw octopus

A pile of small raw octopus at the famous Tsukiji fish market, which I finally managed to visit.

Tags no comments Trackbacks

RSpec Still Sucks

Posted by matijs 25/10/2009 at 11h25

I run rake spec and get:

Test::Unit::AssertionFailedError in 'XmlController test_bad_format'
Expected response to be a <:missing>, but was <301>
/var/lib/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/test_case.rb:114:in `clean_backtrace'
./spec/controllers/xml_controller_spec.rb:152:in `test_bad_format'

So, things fail in xml_controller_spec, right? So, I run:

./script/spec spec/controllers/xml_controller_spec.rb

And I get this:

27 examples, 0 failures


Yes, this turns out to be due to the fact that the spec in question was in its original form as migrated from Test::Unit. But that’s not really an excuse: Either Test::Unit style tests work in RSpec, or they don’t. They shouldn’t work some of the time. Now I suddenly can’t trust any of the Test::Unit style tests in Typo anymore: Are they passing because the code works, or because of some mystical internal RSpec magic?

I am mass-replacing lines of def test_bla_bla by it "test_bla_bla" do right now.

Tags no comments Trackbacks

Very Simple Nautilus Plugin to Show Deletion Date

Posted by matijs 18/05/2009 at 09h14

Gnome’s file manager, Nautilus, does not natively support showing the deletion date for trashed items. This has annoyed me, and others, for a very long time.

Long story short, I created a very simple implementation in Python as a Nautilus plugin. You can find it in its github repository.

This solution has one drawback to : Nautilus plugins can only add string columns, so to make it sort right the date is not in a very user-friendly format. I like to think of it more as proof-of-concept.

What’s next? Nautilus has hard-coded support for sorting by each of its possible date columns. It would be nice to make that more generic so as to allow adding arbitrary date columns, or columns with the sort key and user-visible text separated.

Tags no comments Trackbacks