Tuesday, April 21, 2009

Logic in Java

From Wadler's Blog, What does logic have to do with Java? (wait for the gimmick at the very end):

Thursday, April 16, 2009

Remove Unwanted Icons (Windows)

In Windows, there are icons that cannot be deleted by right clicking, dragging to the recycle bin, or hitting the delete key. To get rid of these pesky, unwanted icons:
  1. Right click on the Desktop and select Properties.
  2. Select the Desktop tab.
  3. Click the Customize Desktop button.
  4. Click the Clean Desktop Now button.
  5. Check the checkboxes for any icons you do not want.
  6. Click the Apply button.
  7. Now the icons you despise are in a folder on the Desktop. Delete that folder.
I found these instructions here.

Tuesday, April 14, 2009

xdotool

xdotool is an awesome command that enables programmatic control of X events, e.g. pressing keys, moving or clicking the mouse, resizing windows, etc. It is a great response to this xkcd:



You can even make the mouse infinitely loop:
    #!/usr/bin/env bash
    
    OFF=300
    RAD=300
    
    C=$(expr $OFF + $RAD)
    
    function x {
      echo "$RAD * c($1)" \
        | bc -l \
        | awk '{print int($1 + 0.5)}' \
        | xargs expr $C +
    }
    
    function y {
      echo "$RAD * s($1)" \
        | bc -l \
        | awk '{print int($1 + 0.5)}' \
        | xargs expr $C +
    }
    
    t=0
    d=0.02
    while true; do
      xdotool mousemove $(x $t) $(y $t)
      d=$(echo "$d * 1.001" | bc -l)
      t=$(echo "$t + $d" | bc -l)
    done
    
Watch this for a few minutes; it eventually starts doing some crazy things. The script also contains several tricks for rounding, etc. that could be more generally useful.

Sunday, April 12, 2009

Twitter on Scala

Here is a nice interview with Twitter developers about replacing an enterprise Ruby backend with Scala. Interesting topics include: flexibility, correctness, concurrency, and fun programming.

Best excerpt:
I think it may just be a property of large systems in dynamic languages, that eventually you end up rewriting your own type system, and you sort of do it badly.

Sunday, April 5, 2009

Media Subversion

Peace, Propaganda, and the Promised Land is a fairly well-made documentary available for free download. A first approximation of its theme could be:
    Coverage of the Israeli occupation of Palestine from a
    perspective absent in US news sources.
but the real point of the film is that:
    US news organizations have been subverted.
Evidence of journalistic infidelity is provided by comparing US and British reports on identical events. The differences are disturbing. Of course, this comparison alone only shows someone got it wrong, not necessarily the US. The documentary also covers history, motivation, and influence for the players involved in both the conflict and its media coverage. These factors suggest that the BBC's version of events is more reliable.

The film provides very interesting examples of how the media's language has been controlled; the effects are dramatic. The whole situation seems quite Orwellian.

Take-home point: Supplement your news intake with sources from outside your home country.

Saturday, April 4, 2009

OCaml Documentation in Vim

To have vim open a firefox tab to the documentation for a standard OCaml module:
  1. Place this script :
        #!/bin/bash
        
        firefox http://caml.inria.fr/pub/docs/manual-ocaml/libref/${1}.html
    
    in ~/bin/ocaml_lkup_module.

  2. $ chmod +x ~/bin/ocaml_lkup_module

  3. Add this line :
        " lookup modules in OCaml online documentation
        au BufRead,BufNewFile *.ml set keywordprg=~/bin/ocaml_lkup_module
    
    to your ~/.vimrc.


To use, simply:
  1. Open up an OCaml source in vim.
  2. In command mode, move the cursor onto a standard library module name.
  3. Press 'K'.
  4. Tah dah! The documentation for that module is open in a new firefox tab.


Similar coverage of vim's keywordprog in a past thesaurus in vim post and from a post over at Daily Vim : Making K Useful.

Thursday, April 2, 2009

Dynamically Resive Font in URxvt

This script allows you to dynamically change the URxvt font size:
    #!/usr/bin/env bash
    
    printf '\33]50;%s%d\007' "xft:Monospace:pixelsize=" $1    
So to change to a 16 pixel font:
    $ fontsize 16


I have no idea what the control characters mean or what they will do to other terminal emulators. I found this script on a very helpful Arch Linux forum.