From d72e304aee9abd0352e4ddaa993eae64e9233d59 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Sun, 5 Feb 2012 16:52:39 -0800 Subject: [PATCH 01/16] tagger.py: loosen mp3 regex a little bit Allow mp3 names to have any number of digits in their initial number, as long as it's at least one. Signed-off-by: Colin McCabe --- tagger.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tagger.py b/tagger.py index 88d2b0e..870da42 100755 --- a/tagger.py +++ b/tagger.py @@ -81,7 +81,7 @@ music_file_re = re.compile(".*\.mp3$") music_file_name_re = re.compile(".*/" + "(?P[^/]*)/" + - "(?P[0123456789][0123456789]) - " + + "(?P[0123456789][0123456789]*) - " + "(?P[^/]*)" + "\.[a-zA-Z0123456789]*$") -- 1.6.6.rc1.39.g9a42 From 811a93986d1a051c550f2ec39f83c714ee7738ff Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Wed, 8 Feb 2012 20:20:19 -0800 Subject: [PATCH 02/16] names_to_numbers.rb: fix rename same-to-same Don't give an error when the source and destination file names happen to be the same in our rename operation. (This would occur if some of the files were already named as we desire.) Signed-off-by: Colin McCabe --- names_to_numbers.rb | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/names_to_numbers.rb b/names_to_numbers.rb index 9439fd1..0fac484 100755 --- a/names_to_numbers.rb +++ b/names_to_numbers.rb @@ -76,8 +76,10 @@ def get_file_name(num) end def rename_files(file) - FileUtils.mv(file, "#{get_file_name(1 + $total_files)}.#{$opts.extension}", - $fu_args) + dst="#{get_file_name(1 + $total_files)}.#{$opts.extension}" + if (file != dst) then + FileUtils.mv(file, dst, $fu_args) + end $total_files = $total_files + 1 end -- 1.6.6.rc1.39.g9a42 From fceef8f2454d64aec2fcb8f9cfd6e931b3ce034b Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Thu, 9 Feb 2012 22:00:27 -0800 Subject: [PATCH 03/16] pickrand.py: seed RNG with process ID Seed the random number generator with the current process ID rather than with the clock. Signed-off-by: Colin McCabe --- pickrand.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pickrand.py b/pickrand.py index 558115c..6340971 100755 --- a/pickrand.py +++ b/pickrand.py @@ -20,7 +20,7 @@ for root, dirs, files in os.walk("."): allfiles.append(os.path.join(root, f)) if (len(allfiles) == 0): sys.exit(1) -random.seed(None) +random.seed(os.getpid()) r = random.randint(0,len(allfiles) - 1) print(allfiles[r]) if (print_to_stderr): -- 1.6.6.rc1.39.g9a42 From 9374e89eef8115bf1680585eb32ab11bb1942525 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Tue, 14 Feb 2012 08:10:28 -0800 Subject: [PATCH 04/16] Create git-identity.sh Signed-off-by: Colin McCabe --- git-identity.sh | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) create mode 100755 git-identity.sh diff --git a/git-identity.sh b/git-identity.sh new file mode 100755 index 0000000..5c4c0f1 --- /dev/null +++ b/git-identity.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# +# Configure git identities on a repo-by-repo basis +# +# Colin Patrick McCabe +# + +die() { + echo $@ + exit 1 +} + +[ $# -eq 1 ] || die "You must supply one argument: work or priv" +case $1 in + work) + git config user.email cmccabe@cloudera.com --file || die "${LINENO}" + git config user.name "Colin Patrick Mccabe" --file || die "${LINENO}" + ;; + priv) + git config user.email cmccabe@alumni.cmu.edu --file || die "${LINENO}" + git config user.name "Colin Patrick Mccabe" --file || die "${LINENO}" + ;; + *) + die "logic error" + ;; +esac + +exit 0 -- 1.6.6.rc1.39.g9a42 From bc6188375e6ed28311fed0b30b7048c1b88f70d8 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Tue, 14 Feb 2012 08:12:14 -0800 Subject: [PATCH 05/16] git-identity.sh: improve usage Signed-off-by: Colin McCabe --- git-identity.sh | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/git-identity.sh b/git-identity.sh index 5c4c0f1..07cf63d 100755 --- a/git-identity.sh +++ b/git-identity.sh @@ -11,7 +11,9 @@ die() { exit 1 } -[ $# -eq 1 ] || die "You must supply one argument: work or priv" +USAGE="You must supply one argument: work or priv" + +[ $# -eq 1 ] || die "${USAGE}" case $1 in work) git config user.email cmccabe@cloudera.com --file || die "${LINENO}" @@ -22,7 +24,7 @@ case $1 in git config user.name "Colin Patrick Mccabe" --file || die "${LINENO}" ;; *) - die "logic error" + die "${USAGE}" ;; esac -- 1.6.6.rc1.39.g9a42 From 612a2d277605db622a53e35ade6f190ad459cf65 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Tue, 21 Feb 2012 12:01:55 -0800 Subject: [PATCH 06/16] git-identity.sh: set git config diff.noprefix true For the work identity, set "config diff.noprefix true". This makes it easier to generate Apache-style diff files. Signed-off-by: Colin McCabe --- git-identity.sh | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/git-identity.sh b/git-identity.sh index 07cf63d..e69bceb 100755 --- a/git-identity.sh +++ b/git-identity.sh @@ -18,6 +18,7 @@ case $1 in work) git config user.email cmccabe@cloudera.com --file || die "${LINENO}" git config user.name "Colin Patrick Mccabe" --file || die "${LINENO}" + git config diff.noprefix true ;; priv) git config user.email cmccabe@alumni.cmu.edu --file || die "${LINENO}" -- 1.6.6.rc1.39.g9a42 From 8ce181b3e616462ee264ef1893be58787fe61f68 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Thu, 23 Feb 2012 19:28:40 -0800 Subject: [PATCH 07/16] Add iocaine.sh A little script to renice / ionice mplayer. Signed-off-by: Colin McCabe --- iocaine.sh | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) create mode 100755 iocaine.sh diff --git a/iocaine.sh b/iocaine.sh new file mode 100755 index 0000000..a5bd5dd --- /dev/null +++ b/iocaine.sh @@ -0,0 +1,4 @@ +#!/bin/bash -ex + +renice -n -20 -p `pidof mplayer` +ionice -c 1 -p `pidof mplayer` -- 1.6.6.rc1.39.g9a42 From a88effa808214a3282f35d8ebf3ebfb3cbe98d19 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Thu, 23 Feb 2012 19:36:17 -0800 Subject: [PATCH 08/16] iocaine: also renice pulseaudio Signed-off-by: Colin McCabe --- iocaine.sh | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/iocaine.sh b/iocaine.sh index a5bd5dd..0f56944 100755 --- a/iocaine.sh +++ b/iocaine.sh @@ -1,4 +1,5 @@ #!/bin/bash -ex +renice -n -20 -p `pidof pulseaudio` renice -n -20 -p `pidof mplayer` ionice -c 1 -p `pidof mplayer` -- 1.6.6.rc1.39.g9a42 From 98340bd6de4e28d1d75a25ecb6f9a72b2bb2082a Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Fri, 4 May 2012 21:25:37 -0700 Subject: [PATCH 09/16] pickrand.py: allow selecting from a set of files Allow selecting from a set of files specified on the command line, rather than just all files in the current directory tree. Signed-off-by: Colin McCabe --- pickrand.py | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) diff --git a/pickrand.py b/pickrand.py index 6340971..688460a 100755 --- a/pickrand.py +++ b/pickrand.py @@ -3,26 +3,29 @@ import os import random import sys +import time print_to_stderr = False +random.seed(os.getpid() + int(time.time())) + +file_name = None if (len(sys.argv) == 1): - pass + allfiles = [] + for root, dirs, files in os.walk("."): + for f in files: + allfiles.append(os.path.join(root, f)) + if (len(allfiles) == 0): + sys.exit(1) + r = random.randint(0,len(allfiles) - 1) + file_name = allfiles[r] elif (len(sys.argv) == 2) and (sys.argv[1] == "-S"): print_to_stderr = True else: - print >>sys.stderr, "invalid command-line arguments" - sys.exit(1) - -allfiles = [] + allfiles = sys.argv[1:] + r = random.randint(0,len(allfiles) - 1) + file_name = allfiles[r] -for root, dirs, files in os.walk("."): - for f in files: - allfiles.append(os.path.join(root, f)) -if (len(allfiles) == 0): - sys.exit(1) -random.seed(os.getpid()) -r = random.randint(0,len(allfiles) - 1) -print(allfiles[r]) +print(file_name) if (print_to_stderr): - print >>sys.stderr, (allfiles[r]) + print >>sys.stderr, file_name sys.exit(0) -- 1.6.6.rc1.39.g9a42 From d9e5c761346ee0f41b521d5424341d4338da296a Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Sat, 5 May 2012 13:24:34 -0700 Subject: [PATCH 10/16] Add xy tool for opening Java code Signed-off-by: Colin McCabe --- xy | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) create mode 100755 xy diff --git a/xy b/xy new file mode 100755 index 0000000..f47b92e --- /dev/null +++ b/xy @@ -0,0 +1,3 @@ +#!/bin/bash + +find . -noleaf -xdev -name '*.java' | grep $@ | xx -- 1.6.6.rc1.39.g9a42 From ecc29888dd2616af70779130cfa6f9a27177a014 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Sat, 5 May 2012 13:26:16 -0700 Subject: [PATCH 11/16] add git-foo, which lists new and modified files from git Signed-off-by: Colin McCabe --- git-foo | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) create mode 100755 git-foo diff --git a/git-foo b/git-foo new file mode 100755 index 0000000..476edd2 --- /dev/null +++ b/git-foo @@ -0,0 +1,3 @@ +#!/bin/bash + +git status | egrep '(modified:)|(new file:)' | sed 's/.*://' -- 1.6.6.rc1.39.g9a42 From b232f73b4d6eecd1d6066f6ab3510a046ff58511 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Sat, 5 May 2012 15:22:10 -0700 Subject: [PATCH 12/16] audiorip.sh: up quality Signed-off-by: Colin McCabe --- audiorip.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/audiorip.sh b/audiorip.sh index 9a3ab7a..47d808c 100755 --- a/audiorip.sh +++ b/audiorip.sh @@ -107,7 +107,7 @@ if [ ${no_cdparanoia} -eq 0 ]; then fi ############# mp3 ############### -wav_to_mp3 192 1 +wav_to_mp3 256 2 ############# flac ############### mv *.wav "${lossless_dir}/" -- 1.6.6.rc1.39.g9a42 From abddbea2f5499968a925deadc581e397aa77d1cf Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Fri, 1 Jun 2012 11:14:14 -0700 Subject: [PATCH 13/16] add vbridge.sh script Signed-off-by: Colin McCabe --- vbridge.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 insertions(+), 0 deletions(-) create mode 100755 vbridge.sh diff --git a/vbridge.sh b/vbridge.sh new file mode 100755 index 0000000..f59ee33 --- /dev/null +++ b/vbridge.sh @@ -0,0 +1,38 @@ +#!/bin/bash -xe + +# +# Create tun and bridge interfaces for qemu. +# + +TAP=tap0 +BR=br0 + +die() { + echo $@ + exit 1 +} + +up() { + /sbin/tunctl -b -t $TAP + /sbin/ifconfig $TAP up + /sbin/brctl addbr $BR + /sbin/brctl addif $BR $TAP + /sbin/ifconfig $BR 192.168.123.1 netmask 255.255.255.0 + /sbin/ifconfig $BR up +} + +down() { + /sbin/ifconfig $BR down + /sbin/ifconfig $TAP down + /sbin/brctl delbr $BR + /sbin/tunctl -d $TAP +} + +ARG="x$1" +if [ $ARG == "xup" ]; then + up +elif [ $ARG == "xdown" ]; then + down +else + die "must specify either up or down." +fi -- 1.6.6.rc1.39.g9a42 From 489d488547b8ebf9b7da059fdc11d01bdce61b3f Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Thu, 7 Jun 2012 14:06:50 -0700 Subject: [PATCH 14/16] Add vm-common.sh, remove vbridge.sh Using -net socket is much more convenient than setting up the bridge and tap interfaces. Signed-off-by: Colin McCabe --- vbridge.sh | 38 -------------------------------------- vm-common.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 38 deletions(-) delete mode 100755 vbridge.sh create mode 100644 vm-common.sh diff --git a/vbridge.sh b/vbridge.sh deleted file mode 100755 index f59ee33..0000000 --- a/vbridge.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -xe - -# -# Create tun and bridge interfaces for qemu. -# - -TAP=tap0 -BR=br0 - -die() { - echo $@ - exit 1 -} - -up() { - /sbin/tunctl -b -t $TAP - /sbin/ifconfig $TAP up - /sbin/brctl addbr $BR - /sbin/brctl addif $BR $TAP - /sbin/ifconfig $BR 192.168.123.1 netmask 255.255.255.0 - /sbin/ifconfig $BR up -} - -down() { - /sbin/ifconfig $BR down - /sbin/ifconfig $TAP down - /sbin/brctl delbr $BR - /sbin/tunctl -d $TAP -} - -ARG="x$1" -if [ $ARG == "xup" ]; then - up -elif [ $ARG == "xdown" ]; then - down -else - die "must specify either up or down." -fi diff --git a/vm-common.sh b/vm-common.sh new file mode 100644 index 0000000..d702b80 --- /dev/null +++ b/vm-common.sh @@ -0,0 +1,40 @@ +die() { + echo $@ + exit 1 +} + +run_vm() { + ID=$1 + shift + NARGS=$@ + ADMIN_PORT=`expr 2232 + $ID` + MID_BYTE=`printf "%02X" $ID` + MAC_ADDR="F0:DE:$MID_BYTE:58:B2:69" + /sbin/modprobe kvm kvm_intel kvm_amd || die "modprobe failed" + echo "running qemu with ssh port $ADMIN_PORT, vnc ID $ID" + VNC_EFFECTIVE_PORT=`expr 5900 + $ID` + echo "see output with vncviewer 127.0.0.1:$VNC_EFFECTIVE_PORT" + qemu-kvm \ + -daemonize \ + -vga std \ + -redir tcp:$ADMIN_PORT::22 \ + -vnc 127.0.0.1:$ID \ + -net nic,vlan=0,model=e1000 \ + -net user,vlan=0,net=10.0.2.0/8,host=10.0.2.2,hostname=vm$ID \ + -net nic,vlan=1,macaddr=$MAC_ADDR,model=e1000 \ + -net socket,vlan=1,mcast=230.0.0.1:1234 \ + $NARGS || die "qemu invocation failed." +} + +# Tap stuff (currently unused): +#-net nic,vlan=0,macaddr=$MAC_ADDR,model=e1000 \ +#-net tap,vlan=0,ifname=tap0,downscript=no,script=no \ + +# To add to /etc/hosts in VMs: +# 192.168.123.10 vm0.local vm0 +# 192.168.123.11 vm1.local vm1 +# 192.168.123.12 vm2.local vm2 +# 192.168.123.13 vm3.local vm3 +# 192.168.123.14 vm4.local vm4 +# 192.168.123.15 vm5.local vm5 +# 192.168.123.16 vm6.local vm6 -- 1.6.6.rc1.39.g9a42 From feb108f20ae15b0bd47ce11fc6e382013876aa86 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Tue, 19 Jun 2012 17:52:40 -0700 Subject: [PATCH 15/16] vm-common.sh: enable ip forwarding just in case Signed-off-by: Colin McCabe --- vm-common.sh | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/vm-common.sh b/vm-common.sh index d702b80..2c57b05 100644 --- a/vm-common.sh +++ b/vm-common.sh @@ -4,6 +4,7 @@ die() { } run_vm() { + sysctl -w net.ipv4.ip_forward=1 || die "failed to enable ip_forward" ID=$1 shift NARGS=$@ -- 1.6.6.rc1.39.g9a42 From 2c1e447111e0043adcb0a8c8418a6ee02e82e8e1 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Tue, 19 Jun 2012 17:53:01 -0700 Subject: [PATCH 16/16] git-foo: add git ls-files -o Signed-off-by: Colin McCabe --- git-foo | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/git-foo b/git-foo index 476edd2..d2817cf 100755 --- a/git-foo +++ b/git-foo @@ -1,3 +1,5 @@ #!/bin/bash git status | egrep '(modified:)|(new file:)' | sed 's/.*://' + +git ls-files -o -- 1.6.6.rc1.39.g9a42