Archive for the ‘tech’ Category

A note about fey

Wednesday, June 17th, 2009

I am in the process of transitioning a DBIx::Class application to Fey abd Fey::ORM. I must say Fey::ORM is more comfortable than DBIC.

Fey is a framework for representing database schemas and generating queries from that representation. Fey::ORM is a SQL-lovers object-relational mapping built on top of Fey’s impressive SQL generation capabilities.

I do mean impressive, as Fey is able to infer join conditions entirely on its own:

# A User has many units, and units have many users, via the lnk_unit_users table.

my $unit_users = $schema->table('lnk_unit_users');
my $unit       = $schema->table('lkup_unit');

my $select_units = $factory->new_select
    ->select($unit)
    ->from($unit, $unit_users)
    ->where($unit_users->column('user_id'), '=', Fey::Placeholder->new)
;

has_many 'units' => (
    table       => $unit,
    select      => $select_units,
    bind_params => sub { $_[0]->user_id },
);

So, when I go $user->units, I get an iterator object full of Units, which executes the following sql:

SELECT *
    FROM lkup_unit 
    JOIN lnk_unit_users ON (lnk_unit_users.unit_id = lkup_unit.unit_id) 
    WHERE lnk_unit_users.user_id = ?

Note, in my $select_units query I did not specify the join condition, I merely passed two Fey::Table objects, and using the foreign key constraints Fey figured out what to do.

I think this is pretty cool. :)

Ono vowol to rolo thom oll!

Saturday, June 6th, 2009

O wroto o scropt thot osos xmodmop to roploco vowols woth ony othor koyboord choroctor: http://gist.github.com/125133

Os o rosolt of thos, O ondod op on o bot woth my froond Oftron to spook ond typo osong O onstood of tho rogolor Onglosh vowols (oxclodong y) for twonty foor hoors. Tho prozo of tho bot os o sodo or othor non-olcoholoc bovorogo.

Onothor condotoon of tho bot os to wroto thos blog post, whoch os now dono.

Of yoo don’t ondorstond thos, O woll post somothong on mondoy to oxploon. :)

Spring shell-cleaning

Friday, May 29th, 2009

I updated my shell’s prompt for the first time in years. New prompt has a right-aligned timestamp/datestamp, shows the number of background jobs (if any) and shows the current git branch if I’m in a git repository.

I think it’s also not as obnoxiously colored.

Old Prompt:

dylan's old prompt

dylan's old prompt

New Prompt:

dylan's new prompt

dylan's new prompt

Perl Oasis 2009

Tuesday, January 27th, 2009

So, in addition to the new job, another interesting thing that happened: I delivered a talk at Perl Oasis 2009.

I was quite nervous, but it turned out alright. I hope next year I can give a more interesting talk.

Oh, also I met a bunch cool perl people, including Jonathon Rockway, who is coincidently one of my new co-workers.

Camping with Ruby

Thursday, January 1st, 2009

I am applying for a job that wanted a code sample written in Ruby.

I’m sure there’s something my ~/bin written in ruby I could have used, but instead of doing that, I downloaded the Camping microframework and put together a very simple time-tracking application.

It does not feature authentication (right now) because camping/session.rb seems to be broken.

Here’s the source code: jot.rb

Generating C code Using Lua

Thursday, September 13th, 2007

I have been working on article about how I wrote Lua code to generate C code to help wrapping object-oriented C (glib-style) and exposing it to Lua, however I have realized that as neat as this sounds, it is terribly difficult to maintain. So let’s pretend it never happened.

basic urxvt setup with terminus for kyevan

Sunday, July 22nd, 2007

type in a terminal window: aptitude install xfonts-terminus xfont-terminus

restart X

Open ~/.Xdefaults, and make it read exactly like this:

Rxvt.font: -xos4-terminus-bold-r-*-*-*-120-100-100-*-*-iso8859-1
Rxvt.color0:    #000000
Rxvt.color1:    #A80000
Rxvt.color2:    #00A800
Rxvt.color3:    Orange3
Rxvt.color4:    #000078
Rxvt.color5:    #A800A8
Rxvt.color6:    #00A8A8
Rxvt.color7:    #A8A8A8
Rxvt.color8:    #646464
Rxvt.color9:    #FF0054
Rxvt.color10:   #00FF54
Rxvt.color11:   #FFFF54
Rxvt.color12:   #0000FF
Rxvt.color13:   #FF00FF
Rxvt.color14:   #00FFFF
Rxvt.color15:   #FFFFFF
Rxvt.foreground:    #A8A8A8
Rxvt.background:    #000000
Rxvt.cursorColor:   #A8A8A8
Rxvt.reverseVideo:  false
Rxvt.geometry:  80x25
Rxvt.scrollBar: false
Rxvt.meta8: false
Rxvt.modifier:  mod1

type in a terminal window: xrdb -merge ~/.Xdefaults

Odin downtime

Saturday, July 7th, 2007

It seems the server I keep at my parent’s house, odin, is having disk corruption. I shut it down yesterday, and sometime today or tomorrow I should attempt data rescue. I don’t think anything would be lost even if the disk is totally trashed, but it’s the principal of the thing…

This effects the cosine sine server, since it ran on odin.

Wordpress

Friday, July 6th, 2007

Alright, after much deliberation, I have decided that I don’t want to write my own blog engine right now.

So, for the time being I will use wordpress. Even if it is slow.

XMonad

Sunday, June 10th, 2007

I have been using dwm for months now. Actually, I’ve been maintaining a fork of it, with patches that I like and such.

Being a lurker in #haskell I have been aware of the development of xmonad, which is a dwm-like window manager written in haskell. I tried xmonad a few months ago, and it was okay. It was missing some features of dwm that I thought I needed, like tags. I continued using dwm.

XMonad development has continued on, with many contributed extensions being added (including novel layout algorithms), and as of yesterday I decided to take the plunge and start using it.

So far, it requires a lot less changes to the config file to behave the way I want.

(Footnote: In fact, I first heard about dwm from Don Stewart, who is also one of the hackers behind xmonad.)