Other articles

  1. "I have nothing to hide."

    • I have nothing to hide.
    • I have not, nor will I ever, do anything wrong.
    • I have not, nor will I ever, do anything wrong, as defined by the government.
    • I have only ever done, and only ever will do, things defined as right by the government.

    By stating that ...

    read more
  2. Switching to Pelican

    This blog used to be a Ruby on Rails app that I wrote myself. It was way too time consuming to keep updating Ruby and Ruby on Rails (for security patches), so I gave up. This blog is now just static .html files generated from .rst files with Pelican.

    Hopefully ...

    read more
  3. How to Maximize X in Your Life

    How to maximize X (success, happiness, skill, or whatever) in your life:

    1. Every week, spend at least an hour reviewing what you did the previous week. Think of what you could have done better to increase X even more. Apply the things you find to the next week.
    2. Every month ...
    read more
  4. [Ruby] Password Training Script

    This is a simple Ruby script that helps you memorize a password by making you type it over and over again. It first breaks the password into chunks of 4 characters, helps you to memorize each chunk, then every consecutive pair of chunks, then every consecutive triple... and so on ...

    read more
  5. Windows Magnifier Hack

    Steps to reset a Windows account password given physical access to the box:

    1. Boot a Linux live cd and mount C:somewhere.
    2. Find magnifier.exe (somewhere in System32) and replace it with cmd.exe.
    3. Boot to the Windows login screen.
    4. Press WinKey + U
    5. Start the magnifier, which should run cmd ...
    read more
  6. Why Unsafe State != Deadlock

    You have a list of processes and a list of resources, and for each process you have:

    • The number of each resource they will ever need at once.
    • The number of each resource they are currently allocated.

    When a process makes a request for a resource, you only allocate the ...

    read more
  7. x86 Stack Diagrams

    All of the x86 stack diagrams I could find are either cluttered with too much information, can't be read from a distance, or put the high address on top (I'm sure there are people who prefer that but... I'm not one of them). So I made my ...

    read more
  8. Visual Basic's "With" in Ruby

    def with( obj )
      yield obj
    with Math do |m|
      puts m.exp( 1 )
      puts m.exp( 2 )
      puts m.exp( 3 )
    # Deeply nested modules
    module Foo
      module Bar
        module Baz
          A_CONSTANT = 3
          def self.aMethod( x )
            x * A_CONSTANT + A_CONSTANT
        module Biz
          def self.anotherMethod( x )
            "hello ...
    read more
  9. Linux: Fix pipe character on ASUS laptops

    Is your pipe/backslash key not typing pipes and backslashes? Is it typing less-than and greater-than symbols? If so, add...

    key <LSGT> { [ backslash, bar, backslash, bar] };

    ..to /usr/share/X11/xkb/symbols/us in the kxb_symbols "basic" section.

    This seems to be a problem with ASUS laptops, I've seen ...

    read more
  10. Escaping String Literals (for JavaScript) in PHP

    Use the following code to escape user-supplied input before inserting it into a JavaScript string literal.

    function js_string_escape($data)
        $safe = "";
        for($i = 0; $i < strlen($data); $i++)
                $safe .= $data[$i];
                $safe .= sprintf("\\x%02X", ord($data[$i]));
        return $safe;


    var foo = "<?php ...
    read more
  11. Disable 'locate' Command Index Databases

    If you use Truecrypt on GNU/Linux, you will want to stop mlocate (the locate command) from automatically indexing your files and compromising your privacy.

    To do so on Debian Squeeze:

    apt-get remove mlocate rm /etc/cron.daily/mlocate

    The database files are stored in:


    Delete them ...

    read more
  12. Awesome Desktop Calculator using Ruby's IRB

    Ruby is an awesome programming language. Its metaprogramming capabilities make it easy to turn the interactive ruby interpreter (irb) into an awesome desktop calculator. To do so, we can make irb execute a ruby script, containing some calculator extensions before it starts, with the following command:

    irb -r /path/to ...
    read more
  13. Ruby Obfuscation

    Just having fun...

    Obfuscated #1

    This evaluates to the string "?".

    ??????????????:????????:??:??:??:??:?????:?? # => "?"

    Obfuscated #2

    $i=0;[$c="[$s=['p '],[$s<<[*1?3??'+?<+?3:?y:?]],$s+=[?b],$s|=[*?y+?'],$s[2,0]=5??r+?u:?$],($i+=1)<30?eval($s.join<<?;<<$c):nil]",eval($c)]


    "<3ruby ...
    read more
  14. Ruby Maze Solver

    Here's a recursive-backtracking ASCII maze solver I wrote to practice ruby. The o's are the solution.


    $ ruby maze.rb maze.txt
    ++++oooooooo  ++++++++++++++++++++++ ++++++++++++++++++++++++        ++++ ++++++
    +oooo++ +++o++++++++++++++++++++++++ ++++ +++++++++++++++++++ +++ +++++++ ++++++
    ++++ ++   oo+++++++++++++++++++ ++++ ++++                 +++ +++ +++++++ ++++++
    ++++ ++ ++o++++++++ooooooo+++++ ++++ ++++ +++++++++++++++++++ +++         ++++++
    ++   +++++o++++++++o+++++o+++++           ++++ ++++++++++++++ ++++++++ +++++++++
    ++++++++++o++++++++o+++++o+++++ +++++ ++++++++ +++oooooooooooooo++++++ +++++++++
    ++++++++++o+oooooooo+++++ooooooo+++++ ++++++++ +++o++++++++ +++o++++++ +++++++++
    ++++++++++ooo++++++++++++ +++++o+++++ +++++++++   o++++++++++++o++++++ +++++++++
    +++++++++++++++++++++++++      o++++++++++++++++++o      ++++++o       +++++++++
    +++++++ +++++++++++++++++++++++o ...
    read more
  15. My Favorite 'Rubyisms'

    I've been using Ruby at work to write watir tests, and I am constantly amazed at how elegant it is. Here are some of my favorite techniques:

    Pass a default value block to Hash.new to implement a memoized recursive function:

    fibonacci = Hash.new do |h,k|
        h[k ...
    read more
  16. Random .vimrc Tips

    Here are some of my favorite .vimrc lines.

    Save quickly from any mode by pressing CTRL+:

    imap <C-\> <Esc>:w<Cr>
    map <C-\> <Esc>:w<Cr>

    Make indenting and de-indenting in visual mode preserve the selection:

    vnoremap > ><CR>gv
    vnoremap < <<CR>gv

    Quick case insensitive search with double slash or ...

    read more
  17. Clipboard over SSH with Vim

    The following is a simple and easy way to get clipboard sharing with Vim working between two Linux installations (specifically a desktop and remote server).

    First install xclip on both your local machine and the server:

    apt-get install xclip

    Installing xclip will bring along some dependencies like x11-common, but don ...

    read more