kern.log
SignupLogin

Public

  1. Node.js module search path

    change require.paths dynamically or set NODE_PATH environmental variable

    When require('assert') is called Node looks for:

    1. /home/ryan/.node_libraries/assert.js
    2. /home/ryan/.node_libraries/assert.node
    3. /home/ryan/.node_libraries/assert/index.js
    4. /home/ryan/.node_libraries/assert/index.node

    #nodejs

  2. Display the top ten running processes sorted by memory usage

    $ ps aux | sort -nk +4 | tail
    
  3. Save a file you edited in vim without the needed permissions

    :w !sudo tee %
    

    The tee command takes standard input and write it to a file. % is a read-only register containing the current file name.

    #vim

  4. Flush DNS cache in OS X 10.5

    $ dscacheutil -flushcache
    

    #osx

  5. Run the previous shell command but replace string "foo" with "bar"

    $ ^foo^bar^
    

    This is a shortcut for

    $ !!:s/foo/bar/
    

    Note that this one-liner replaces just the first word in the previous command. To replace all words, add the g modifer (g for global):

    $ !!:gs/foo/bar
    
  6. Quickly backup or copy a file

    cp filename{,.bak}

  7. Copy your public-key to remote-machine for public-key authentication

    $ ssh-copy-id remote-machine
    
  8. Capture video of a linux desktop

    $ ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg
    

    -r 25 sets the framerate of the video to 25fps.
    -i :0.0 sets the video input file to X11 display 0.0 at localhost.
    -sameq preserves the quality of input stream. It's best to preserve the quality and post-process it later.

    #ffmpeg