Y-combinator in Ruby with REAL λ!

Posted by flori Mon, 08 Oct 2007 17:02:00 GMT

#!/usr/bin/ruby -KU
# -*- coding: utf-8 -*- 

# Do ":imap <C-l> <C-k>l*" in vim

alias λ lambda

Y = λ{ |c|
  λ{ |f| f[f] }[
    λ{ |f| c[
      λ{ |x| f[f][x] } ] } ] }

Y[ λ{ |f| λ{ |n| n < 1 ? 1 : n * f[n-1] } } ][10] # => 3628800

And they say reading ruby-core doesn't pay off! :-)

Tags , ,  | no comments

Open Containing Folder in Firefox under Linux

Posted by flori Tue, 11 Sep 2007 19:09:00 GMT

After Downloading a file in firefox and right-clicking on the filename in the download manager, you can choose the popup menu entry "Open Containing Folder". This should open a filebrowser for the directory this file was saved in. I have to admit, that this never worked for me under Linux, only under MacOS X and under Windows. I assume the reason for this is, that you have a lot of options under Linux, but no general default for a file manager. Firefox did never show a very smart reaction (and only displays an error) if no filebrowser could be found: Perhaps asking me what to do would be a good idea?

I finally couldn't take it anymore and researched how to configure this feature. I wanted XFCE4's file manager Thunar to be opened, so this is what you have to do: Open the about:config dialog in you location toolbar (or pick it from the Help menu). Now right click onto the configuration entry list, and choose New -> Boolean from the popup menu. Create the following two entries and set them both to true:

network.protocol-handler.expose.file = true (Boolean) network.protocol-handler.external.file = true (Boolean)

Now choose New -> String from the popup menu, and set the value to thunar:

network.protocol-handler.app.file = thunar (String)

This will start thunar with containing directory (with a file:// url) as an argument. You can as well use nautilus or konqueror or whatever here. Another possibility is to use open, which would cause firefox itself to open the directory as a file:// url.

Now type network.protocol-handler into the about:config filter. The resulting filtered list should now include these entries:

Configuration Entries in about:config

Now try it with a downloaded file, I hope it works for you.

Tags , , , ,  | 3 comments

Automatically changing Background Wallpaper in XFCE4

Posted by flori Fri, 31 Aug 2007 13:41:00 GMT

I recently switched from the good, old trusty WindowMaker to XFCE4 as a window manager/desktop environment.

Before the switch I used xsetbg in the crontab to change my background from the standard wallpaper of my theme to another image every hour. Now I configured Desktop Preferences -> Image -> New list to create a list of desktop images to choose from. But how to swtich every hour or at all? xsetbg stopped to work under XFCE4 for some reason. It's also strange, that you can configure a list in XFCE4, but it is only used once after login in.

The solution

Put this line into your crontab:

0 * * * * killall -USR1 xfdesktop

This will reload xfdesktop's configuration and also switch to a new backdrop image. Yeah, it's that easy, but it took me a while to figure it out.

There is also the xfdesktop -reload command, but I had some problems to connect to the X server from the crond. Maybe this is caused by my paranoid X configuration, though.

Tags , , ,  | no comments

Older posts: 1 2 3 ... 9