Toxic Elephant

Don't bury it in your back yard!

Choosing a Distributed File System

Posted by matijs 30/06/2011 at 18h15

It’s happening, like it happens to all of us: My hard disk is getting full, and although the free space would have seemed like an ocean just a decade ago, now it’s a worryingly small pool of tiny little gigabytes. I could try freeing up some by tediously going through all the photos I never bothered to cull before, but with Gb-sized videos being added on a regular basis, that isn’t a long term solution. Where long term is anything that will tide me over to my next laptop.

But, what if I could offload some of those files to some other storage medium? I’m not really that fond of external hard disks, but perhaps a file server? Great! You mount some remote directory, and it’s like it’s right there on your machine.

2 comments no trackbacks

GirFFI - An Introduction

Posted by matijs 10/05/2011 at 07h09

Over two years ago, I had the idea, that it should be possible to combine two great technologies, ruby-ffi, and GObject Introspection, to dynamically create bindings for GLib-based libraries.

This idea, like many, was born from frustration: The development of Ruby-GNOME2 is labour-intensive, and therefore, it lags behind the development of Gnome libraries. In particular, I wanted to use the Gio library, which had no bindings at the time, to fetch generated icons for images.

Tags no comments no trackbacks

Benchmarking Dynamic Method Creation in Ruby

Posted by matijs 22/04/2011 at 09h30

Let’s look at dynamic method generation. I need it for GirFFI, and if you do any kind of metaprogramming, you probably need it too. It was already shown a long time ago that using string evaluation is preferable to using define_method with a block.

That is, if you care at all about speed.

Tags no comments no trackbacks

Materialized Path to Nested Set

Posted by matijs 13/12/2010 at 23h14

On twitter, @clemensk asks:

Hey SQL experts, is it somehow possible in pure (My)SQL to extract a nested set from a table full of paths (think: Category 1 > Category 2)?

To do this, you need to do two things: Extract the names of the nodes, and calculate values for lft and rgt. Here’s my take on the latter part:

Tags no comments no trackbacks

Redefined Accessors

Posted by matijs 10/12/2010 at 09h29

If you’re going to do this:

<typo:code lang=”ruby”> def foo= f

@foo = f + " bar"

end </typo:code>

Then don’t first do this:

<typo:code lang=”ruby”> attr_accessor :foo </typo:code>

But instead do this:

<typo:code lang=”ruby”> attr_reader :foo </typo:code>

That way, there won’t be “method redefined” warnings all over the place.

Let’s make this more general: Before you release your gem, make sure it runs without warnings. They should stick out like a sore thumb when you run your tests, anyway.

Thanks.

Tags no comments no trackbacks

If you have Oops commits, you're doing it wrong

Posted by matijs 16/09/2010 at 17h22

If you still have commits with messages like ‘Oops, I forgot this file’, you’re doing something wrong. Just use git commit --amend.

Tags no comments no trackbacks

Indistinguishable

Posted by matijs 08/09/2010 at 05h22

Sometimes we say something that sounds right but is in fact the exact opposite of what we mean.

So it’s entirely possible that a talk you started presenting a year and a half ago is so different now as to be almost indistinguishable from the original.

Andy Budd – 7 Ways to improve your public speaking

Tags no comments no trackbacks

Gem for memory_test_fix

Posted by matijs 27/06/2010 at 21h10

In some of my Rails projects, I have been a contented user of the memory_test_fix plugin. However, I rather dislike the use of Rails plugins, because I find updating them later on rather difficult, and I don’t like including external libraries in my own source tree (hence, I don’t like the practice of vendoring gems much either). When the concept of ‘gem plugins’ was introduced, I created a fork on github and created the necessary files to build the plugin as a gem, and have Rails properly load it.

Tags no comments no trackbacks

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 no 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 tr.im 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 , no comments no trackbacks