The Road to Elysium

January 17, 2011

Vim: Commenting out multiple lines

Filed under: Snippets — jorge @ 11:31

There are two ways to do this without a vim plugin:

  1. Select your lines with VISUAL BLOCK (CTRL-V), then press I to insert before all highlighted lines. Next type your comment character (#, ;, depending on the language), then press ESC twice.
  2. Select your lines with VISUAL LINE (SHIFT-V) then type:
s/^/#

In other words, substitute the selected start of lines with the # character.

October 20, 2010

Select browser from variable DISPLAY

Filed under: Snippets — Tags: , , , , , , , , , , — jorge @ 11:20

I have two monitors at work, which I like to use in a separate X-screen setup. Meaning that each monitor has an own X-server running on it. Thing is though, I like to use Firefox on Monitor 1, while I use Google Chrome on Monitor 2. So with this script, right-clicking a link in Monitor 1 will open it up in Firefox, while if I do so on Monitor 2, it will open it up in Google Chrome. Very nifty. Just go to System -> Preferences -> Preferred Applications (if you’re using GNOME like moi) and select this script instead of a regular browser.

#!/bin/bash
# A little script that selects a browser
# to show an URL on, based on the variable
# DISPLAY on a separate X-screen setup.
# In other words, the active monitor.
#
# Jorge Enrique Barrera <jorge@fbarr.net>
 
if [ "$DISPLAY" = ":0.0" ]; then
    /usr/bin/firefox $1
elif [ "$DISPLAY" = ":0.1" ]; then
    /usr/bin/google-chrome $1
fi

September 15, 2010

Python password generator

Filed under: Snippets — Tags: , , — jorge @ 17:07
#!/usr/bin/env python
# Filename: passgen.py
 
import random, string
 
mystr = string.ascii_letters+string.digits
random_string = []
 
while len(random_string) <= 8:
    random_string.append(random.choice(mystr))
print "".join(random_string)

March 17, 2010

Embedding subtitles srt into avi files with mencoder

Filed under: Snippets — jorge @ 09:59

Easier than you might think:

$ mencoder -sub movie_subtitle.srt -ovc xvid -xvidencopts bitrate=-700000 -oac copy -o new.movie.name.avi movie.avi

November 26, 2009

Removing your Master Boot Record (MBR)

Filed under: Snippets — jorge @ 09:42

Removing MBR (including the partition table):

# dd if=/dev/null of=/dev/sdX bs=512 count=1

Removing MBR (excluding the partition table):

# dd if=/dev/null of=/dev/sdX bs=446 count=1

sdX is the device you want to remove the MBR of (like a USB-stick).

Older Posts »

Powered by WordPress