diff options
author | jluehrs2 <jluehrs2@uiuc.edu> | 2007-09-09 17:41:22 -0500 |
---|---|---|
committer | jluehrs2 <jluehrs2@uiuc.edu> | 2007-09-09 17:41:22 -0500 |
commit | a15446b3fd41656efa0677b8f10a9be4ad8b74fd (patch) | |
tree | 0b303c85546ea4b8db749a9bb7bbb196fb3cb9f2 /bin | |
parent | 575acc6740d468197537dbb20ff53c93da54e50b (diff) | |
download | conf-a15446b3fd41656efa0677b8f10a9be4ad8b74fd.tar.gz conf-a15446b3fd41656efa0677b8f10a9be4ad8b74fd.zip |
add my bin directory
Diffstat (limited to 'bin')
-rw-r--r-- | bin/alarm | 29 | ||||
-rw-r--r-- | bin/checkmessages | 3 | ||||
-rw-r--r-- | bin/colors.sh | 17 | ||||
-rw-r--r-- | bin/dcl_proxy | 3 | ||||
-rw-r--r-- | bin/emerge_file | 8 | ||||
-rw-r--r-- | bin/fig2eps | 20 | ||||
-rw-r--r-- | bin/get_ip | 15 | ||||
-rw-r--r-- | bin/installed_kernel_modules | 9 | ||||
-rw-r--r-- | bin/ipod_movie | 18 | ||||
-rw-r--r-- | bin/kuakes | 6 | ||||
-rw-r--r-- | bin/lastaim | 4 | ||||
-rw-r--r-- | bin/latexpdf | 14 | ||||
-rw-r--r-- | bin/learn_spam | 9 | ||||
-rw-r--r-- | bin/marathon/marathon | 18 | ||||
-rw-r--r-- | bin/mem_usage | 8 | ||||
-rw-r--r-- | bin/mp3_rename | 10 | ||||
-rw-r--r-- | bin/nm | 256 | ||||
-rw-r--r-- | bin/on_lock | 4 | ||||
-rw-r--r-- | bin/opened_files | 3 | ||||
-rw-r--r-- | bin/package_space | 3 | ||||
-rw-r--r-- | bin/pictures | 14 | ||||
-rw-r--r-- | bin/playcd | 14 | ||||
-rw-r--r-- | bin/playmusic | 7 | ||||
-rw-r--r-- | bin/playvt | 8 | ||||
-rw-r--r-- | bin/procmem | 67 | ||||
-rw-r--r-- | bin/scrobble_cache | 87 | ||||
-rw-r--r-- | bin/sendmessage | 8 | ||||
-rw-r--r-- | bin/ssh | 7 | ||||
-rw-r--r-- | bin/start_runlevel | 11 | ||||
-rw-r--r-- | bin/watch_lock | 9 |
30 files changed, 689 insertions, 0 deletions
diff --git a/bin/alarm b/bin/alarm new file mode 100644 index 0000000..d247c58 --- /dev/null +++ b/bin/alarm @@ -0,0 +1,29 @@ +#!/bin/bash +reset_mixer() +{ + amixer set Master $OLDVOL_M $M > /dev/null + amixer set PCM $OLDVOL_P $P > /dev/null +} + +set_mixer() +{ + OLDVOL_M=`amixer get Master | egrep "$Front Left.*\[.*%\]" | sed s/".*\[\(.*%\)].*"/"\1"/` + OLDVOL_P=`amixer get PCM | egrep "$Front Left.*\[.*%\]" | sed s/".*\[\(.*%\)].*"/"\1"/` + OLDMUTE_M=`amixer get Master | egrep "$Front Left.*\[.*%\]" | sed s/".*\[\(.*%\)].*\[\(.*\)\]"/"\2"/` + OLDMUTE_P=`amixer get PCM | egrep "$Front Left.*\[.*%\]" | sed s/".*\[\(.*%\)].*\[\(.*\)\]"/"\2"/` + echo $OLDMUTE_M | grep -q on || M='mute' + echo $OLDMUTE_P | grep -q on || P='mute' + amixer set Master 100% unmute > /dev/null + amixer set PCM 100% unmute > /dev/null +} + +trap reset_mixer 2 +trap reset_mixer 3 +trap reset_mixer 15 +for i in {1..100};do + set_mixer + mplayer ~/.alarm.mp3 > /dev/null + reset_mixer + sleep 600 +done +reset_mixer diff --git a/bin/checkmessages b/bin/checkmessages new file mode 100644 index 0000000..02d6453 --- /dev/null +++ b/bin/checkmessages @@ -0,0 +1,3 @@ +#!/bin/bash + +find ~/.gaim/logs/ -mmin -$1 -type f | grep -v .system | xargs tail -n $2 diff --git a/bin/colors.sh b/bin/colors.sh new file mode 100644 index 0000000..136ad98 --- /dev/null +++ b/bin/colors.sh @@ -0,0 +1,17 @@ +#!/bin/sh +############################################################ +# Nico Golde <nico(at)ngolde.de> Homepage: http://www.ngolde.de +# Last change: Mon Feb 16 16:24:41 CET 2004 +############################################################ + +for attr in 0 1 4 5 7 ; do + echo "----------------------------------------------------------------" + printf "ESC[%s;Foreground;Background - \n" $attr + for fore in 30 31 32 33 34 35 36 37; do + for back in 40 41 42 43 44 45 46 47; do + printf '\033[%s;%s;%sm %02s;%02s ' $attr $fore $back $fore $back + done + printf '\n' + done + printf '\033[0m' +done diff --git a/bin/dcl_proxy b/bin/dcl_proxy new file mode 100644 index 0000000..e826ea1 --- /dev/null +++ b/bin/dcl_proxy @@ -0,0 +1,3 @@ +#!/bin/bash + +ssh jluehrs2@dcllnx7.ews.uiuc.edu tinyproxy-controller $1 diff --git a/bin/emerge_file b/bin/emerge_file new file mode 100644 index 0000000..d2ba596 --- /dev/null +++ b/bin/emerge_file @@ -0,0 +1,8 @@ +#!/bin/bash +while read line; do + line="=$line" + ebuild_list="$ebuild_list $line" +done + +echo "emerge $@ $ebuild_list" +emerge $@ $ebuild_list diff --git a/bin/fig2eps b/bin/fig2eps new file mode 100644 index 0000000..a912a66 --- /dev/null +++ b/bin/fig2eps @@ -0,0 +1,20 @@ +#!/bin/bash + +base=${1/.fig/} + +( +cat << EOF +\documentclass{article} +\usepackage{epsfig} +\usepackage{color} +\setlength{\textwidth}{100cm} +\setlength{\textheight}{100cm} +\begin{document} +\pagestyle{empty} +\input{$base.pstex_t} +\end{document} +EOF +) > $base.tex + +latex $base.tex +dvips -E $base.dvi -o $base.eps diff --git a/bin/get_ip b/bin/get_ip new file mode 100644 index 0000000..c0d3273 --- /dev/null +++ b/bin/get_ip @@ -0,0 +1,15 @@ +#!/usr/bin/perl + +my $page = "http://www.lawrencegoetz.com/programs/ipinfo/"; + +open my $site, "wget -qO- $page|" or die "Could not get web page"; + +my $next_line_is_ip = 0; +while (<$site>) { + if ($next_line_is_ip == 1) { + s/ //g; + print $_; + last; + } + $next_line_is_ip = 1 if /Your IP address is/; +} diff --git a/bin/installed_kernel_modules b/bin/installed_kernel_modules new file mode 100644 index 0000000..3cabadd --- /dev/null +++ b/bin/installed_kernel_modules @@ -0,0 +1,9 @@ +#!/bin/bash + +if [[ "$1x" == "x" ]]; then + kernel_name=`uname -r` +else + kernel_name=$1 +fi + +find /lib/modules/$kernel_name/ -iname '*.ko' | sed 's:.*/\(.*\)\.ko:\1:' diff --git a/bin/ipod_movie b/bin/ipod_movie new file mode 100644 index 0000000..8f0cdb4 --- /dev/null +++ b/bin/ipod_movie @@ -0,0 +1,18 @@ +#!/bin/bash + +in_name=$1 +out_name=$( echo ${in_name} | sed 's/\(.*\)\..*/\1_ipod.mov/' ) +aspect=$2 + +echo "Writing out ${in_name} in iPod format to ${out_name}..." +echo + +ffmpeg -vcodec xvid -b 350 -bufsize 4096 -g 300 -acodec aac -ab 96 -ac 2 -i "${in_name}" -s 320x240 -aspect ${aspect} "${out_name}" + +if [[ $? -eq 0 ]]; then + echo + echo "done." +else + echo + echo "failed." +fi diff --git a/bin/kuakes b/bin/kuakes new file mode 100644 index 0000000..2edef8c --- /dev/null +++ b/bin/kuakes @@ -0,0 +1,6 @@ +#!/bin/bash + +for num in {1..7}; do + urxvt -pe "kuake<F$num>" -fn 6x10 -g 94x24 -name urxvt-kuake & + sleep 0.2 +done diff --git a/bin/lastaim b/bin/lastaim new file mode 100644 index 0000000..27253c9 --- /dev/null +++ b/bin/lastaim @@ -0,0 +1,4 @@ +#!/bin/bash + +cd ~/.gaim/logs/aim/thedoyster/$1 +less $(ls | tail -n1) diff --git a/bin/latexpdf b/bin/latexpdf new file mode 100644 index 0000000..a8016aa --- /dev/null +++ b/bin/latexpdf @@ -0,0 +1,14 @@ +#!/bin/bash + +if [[ "x$1" == "x--show" ]]; then + show=1 + shift +fi + +export TEXINPUTS=".:~/writing:" +base=${1/.tex/} + +pdflatex $base.tex || exit +if [[ ! -z ${show} ]]; then + xpdf $base.pdf +fi diff --git a/bin/learn_spam b/bin/learn_spam new file mode 100644 index 0000000..f013fc2 --- /dev/null +++ b/bin/learn_spam @@ -0,0 +1,9 @@ +#!/bin/bash + +MAILDIR=~/Mail + +echo -n "Learning spam..." +find ${MAILDIR} -mindepth 1 -type d -iname '*spam*' -exec echo \; -exec echo " From directory" {} \; -exec sa-learn --showdots --spam {}/* \; + +echo -n "Learning ham..." +find ${MAILDIR} -mindepth 1 -type d ! -iname '*spam*' ! -iname '*inbox*' ! -iname '*sent*' ! -iname '*trash*' ! -iname '*draft*' ! -iname '*school mail*' -exec echo \; -exec echo " From directory" {} \; -exec sa-learn --showdots --ham {}/* \; diff --git a/bin/marathon/marathon b/bin/marathon/marathon new file mode 100644 index 0000000..8fd85c4 --- /dev/null +++ b/bin/marathon/marathon @@ -0,0 +1,18 @@ +#!/bin/bash + +A1_MAIN_DIR=/usr/local/share/AlephOne +A1_SCEN_DIR=/usr/local/share/AlephOneScenarios + +if [[ "x$(basename $0)" == "xmarathon" ]]; then + if [[ "x$1" == "x--list" ]]; then + ls ${A1_SCEN_DIR} + exit 0 + fi + scenario=$1 +else + scenario=$(basename $0) +fi + +export ALEPHONE_DATA="${A1_MAIN_DIR}:${A1_SCEN_DIR}/${scenario}" +cd ~/games/marathon +alephone diff --git a/bin/mem_usage b/bin/mem_usage new file mode 100644 index 0000000..ad712dc --- /dev/null +++ b/bin/mem_usage @@ -0,0 +1,8 @@ +#!/bin/bash + +if [[ -z "$1" ]]; then + num=20 +else + num=$1 +fi +ps -eo size,ucmd | sort -rn | head -n${num} diff --git a/bin/mp3_rename b/bin/mp3_rename new file mode 100644 index 0000000..829ad63 --- /dev/null +++ b/bin/mp3_rename @@ -0,0 +1,10 @@ +#!/bin/bash + +for file in *.mp3; do + INFO=$(id3info "${file}") + TRACK_NUM=$(echo "${INFO}" | grep TRCK | cut -d":" -f2 | sed 's/ //') + ARTIST=$(echo "${INFO}" | grep TPE1 | cut -d":" -f2 | sed 's/ //') + NAME=$(echo "${INFO}" | grep TIT2 | cut -d":" -f2 | sed 's/ //') + + mv "${file}" "$(printf "%02d - %s - %s.mp3" "${TRACK_NUM}" "${ARTIST}" "${NAME}" | sed 's:/:_:g')" +done @@ -0,0 +1,256 @@ +#!/usr/bin/perl +use strict; +use warnings; + +die "usage: $0 [module-name]" unless @ARGV == 1; +my $name = shift; + +my ($colons, $hyphens); +if ($name =~ /::/) +{ + $colons = $name; + ($hyphens = $name) =~ s/::/-/g; +} +else +{ + $hyphens = $name; + ($colons = $name) =~ s/-/::/g; +} + +my @parts = split '-', $hyphens; +my $dir = "lib/" . join('/', @parts[0..$#parts-1]); +system("mkdir $hyphens"); +chdir $hyphens; +system("mkdir -p $dir"); +system("mkdir t"); + +open my $handle, '>', "$dir/$parts[-1].pm" + or die "Unable to open $dir/$parts[-1].pm for writing: $!"; +print {$handle} module_contents(); +close $handle; + +open $handle, '>', "t/000-load.t" + or die "Unable to open t/000-load.t for writing: $!"; +print {$handle} load_contents(); +close $handle; + +open $handle, '>', "t/001-basic.t" + or die "Unable to open t/001-basic.t for writing: $!"; +print {$handle} basic_contents(); +close $handle; + +open $handle, '>', "Makefile.PL" + or die "Unable to open Makefile.PL for writing: $!"; +print {$handle} makefile_contents(); +close $handle; + +open $handle, '>', "README" + or die "Unable to open README for writing: $!"; +print {$handle} readme_contents(); +close $handle; + +open $handle, '>', "Changes" + or die "Unable to open Changes for writing: $!"; +print {$handle} changes_contents(); +close $handle; + +#system('darcs init && darcs add $(darcs whatsnew -ls | perl -ple "s/^a //") && darcs record -a -m"Initial import of '.$colons.'"'); + +sub readme_contents +{ + return << "README"; +$hyphens 0.01 + +$colons is + +MAJOR CHANGES + 0.01: first version + +INSTALLATION + +To install this module, run the following commands: + + perl Makefile.PL + make + make test + make install + +SUPPORT AND DOCUMENTATION + +After installing, you can find documentation for this module with the perldoc +command. + + perldoc $colons + +You can also look for information at: + + Search CPAN + http://search.cpan.org/dist/$hyphens + + CPAN Request Tracker: + http://rt.cpan.org/NoAuth/Bugs.html?Dist=$hyphens + + AnnoCPAN, annotated CPAN documentation: + http://annocpan.org/dist/$hyphens + + CPAN Ratings: + http://cpanratings.perl.org/d/$hyphens + +COPYRIGHT AND LICENSE + +Copyright (C) 2007 Shawn M Moore + +This program is free software; you can redistribute it and/or modify it +under the same terms as Perl itself. + +README +} + +sub changes_contents +{ + my $time = localtime; + return << "CHANGES"; +Revision history for $hyphens + +0.01 $time + First version, released on an unsuspecting world. + +CHANGES +} + +sub makefile_contents +{ + return << "MAKEFILE"; +# Load the Module::Install bundled in ./inc/ +use inc::Module::Install; + +# Define metadata +name '$hyphens'; +all_from '$dir/$parts[-1].pm'; + +requires ''; + +build_requires 'Test::More'; + +auto_install; +WriteAll; + +MAKEFILE +} + +sub basic_contents +{ + return << "TEST"; +#!perl -T +use strict; +use warnings; +use Test::More tests => 1; +use $colons; + +ok(1); + +TEST +} + +sub load_contents +{ + return << "TEST"; +#!perl -T +use strict; +use warnings; +use Test::More tests => 1; + +use_ok '$colons'; + +TEST +} + +sub module_contents +{ + return << "MODULE"; +#!perl +package $colons; +use strict; +use warnings; + + + +=head1 NAME + +$colons - ??? + +=head1 VERSION + +Version 0.01 released ??? + +=cut + +our \$VERSION = '0.01'; + +=head1 SYNOPSIS + + use $colons; + do_stuff(); + +=head1 DESCRIPTION + + + +=head1 SEE ALSO + +L<Foo::Bar> + +=head1 AUTHOR + +Shawn M Moore, C<< <sartak at gmail.com> >> + +=head1 BUGS + +No known bugs. + +Please report any bugs through RT: email +C<bug-\L$hyphens\E at rt.cpan.org>, or browse to +L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=$hyphens>. + +=head1 SUPPORT + +You can find this documentation for this module with the perldoc command. + + perldoc $colons + +You can also look for information at: + +=over 4 + +=item * AnnoCPAN: Annotated CPAN documentation + +L<http://annocpan.org/dist/$hyphens> + +=item * CPAN Ratings + +L<http://cpanratings.perl.org/d/$hyphens> + +=item * RT: CPAN's request tracker + +L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=$hyphens> + +=item * Search CPAN + +L<http://search.cpan.org/dist/$hyphens> + +=back + +=head1 COPYRIGHT AND LICENSE + +Copyright 2007 Shawn M Moore. + +This program is free software; you can redistribute it and/or modify it +under the same terms as Perl itself. + +=cut + +1; + +MODULE +} + diff --git a/bin/on_lock b/bin/on_lock new file mode 100644 index 0000000..75daccc --- /dev/null +++ b/bin/on_lock @@ -0,0 +1,4 @@ +#!/bin/bash + +sudo -k +keychain -q --clear diff --git a/bin/opened_files b/bin/opened_files new file mode 100644 index 0000000..af5e87b --- /dev/null +++ b/bin/opened_files @@ -0,0 +1,3 @@ +#!/bin/bash + +strace $* 2>&1 | grep -E '^open\(' | grep -v ENOENT | grep -v O_DIRECTORY | cut -f2 -d"\"" | grep -vE '^/proc/' | grep -v '^/sys/' | grep -v '^/dev/' diff --git a/bin/package_space b/bin/package_space new file mode 100644 index 0000000..9aa850a --- /dev/null +++ b/bin/package_space @@ -0,0 +1,3 @@ +#!/bin/bash + +equery files $1 | grep -v '\->' | grep -v '*' | while read line;do [ -f "$line" ] && echo $line;done | xargs du -cb | grep total | cut -d" " -f1 | while read line;do total=$((total+line));echo $total;done | tail -n1 diff --git a/bin/pictures b/bin/pictures new file mode 100644 index 0000000..d6fcca9 --- /dev/null +++ b/bin/pictures @@ -0,0 +1,14 @@ +#!/bin/bash +mount /mnt/camera || exit +fold=`date +%Y%m%d%H%M` +to_dir=~/media/images/photos/unsorted/$fold +from_dir=/mnt/camera/dcim/100olymp +numpictures=0 +mkdir $to_dir +for picture in $from_dir/*;do +cp $picture $to_dir/ +(( numpictures += 1 )) +done +chmod 644 $to_dir/* +echo "$numpictures images copied" +umount /mnt/camera diff --git a/bin/playcd b/bin/playcd new file mode 100644 index 0000000..1c2bde1 --- /dev/null +++ b/bin/playcd @@ -0,0 +1,14 @@ +#!/bin/bash + +if [[ -z $1 ]]; then + cdda2wav -q -e -d0 -N -B dev=/dev/cdrom & +else + cdda2wav -q -e -d0 -N -t$1 dev=/dev/cdrom & +fi + +PID=$! + +# this program skips a lot +sudo renice -5 ${PID} + +wait ${PID} diff --git a/bin/playmusic b/bin/playmusic new file mode 100644 index 0000000..0f492ad --- /dev/null +++ b/bin/playmusic @@ -0,0 +1,7 @@ +while read line; do + nline=`echo $line | sed s/'^\#.*'//g` + [ -z "$nline" ] && continue + echo $nline + echo $nline | grep -q '.mp3' && mpg123 "$nline" && continue + echo $nline | grep -q '.ogg' && ogg123 "$nline" && continue +done diff --git a/bin/playvt b/bin/playvt new file mode 100644 index 0000000..182a5f3 --- /dev/null +++ b/bin/playvt @@ -0,0 +1,8 @@ +#!/bin/bash + +rate=$2 +if [[ -z "$rate" ]]; then + rate=1200 +fi + +wget -O- $1 --limit-rate=$rate 2>/dev/null diff --git a/bin/procmem b/bin/procmem new file mode 100644 index 0000000..3a7ce76 --- /dev/null +++ b/bin/procmem @@ -0,0 +1,67 @@ +#!/bin/bash + +if [ "$1" = "--help" -o "$1" = "-h" ]; then + echo "Syntax: `basename $0` [pid]..." + echo "If no pids are specified, all processes are listed" + exit 1 +fi + +cd /proc 2> /dev/null || { echo "No /proc directory."; exit 1; } + + +get_cmdline() { + local cmd + cmd="`tr '\000' ' ' < $1/cmdline`" + test -z "$cmd" && cmd="[`tr -d '()' < $1/stat | cut -d' ' -f2`]" + echo "$cmd" +} + +get_rss() { + grep "^VmRSS:" $1/status | awk '{ print $2 }' +} + + +# Determine the width of the stdout tty (if it is a tty) for clipping +width=`stty -F $$/fd/1 size 2> /dev/null | awk '{ print $2 }'` + +clip_line() { + test -n "$width" && expr substr "$1" 1 "$width" || echo "$1" +} + + +test -z "$1" && set -- `echo [0-9]* | tr " " "\n" | sort -n` + +header=$(printf "%5s %6s %6s %6s %6s %6s %s\n" \ +PID VSZ DEVMAP LIBMAP ALLOC RSS CMDLINE) + +clip_line "$header" + +for pid; do + totalmap=0 + devmap=0 + libmap=0 + alloc=0 + + test -f $pid/maps || continue + + { while read -u 99 range _ _ _ _ lib; do + size=$(( -(0x${range/-/-0x}) )) + let totalmap+=size + case $lib in + /dev/*) + let devmap+=size + ;; + "") + let alloc+=size + ;; + *) + let libmap+=size + esac + done; } 99< $pid/maps # '99<' is a workaround for a stupid bash bug + + output=$(printf "%5d %6d %6d %6d %6d %6d %s\n" \ + $pid $((totalmap/1024)) $((devmap/1024)) $((libmap/1024)) \ + $((alloc/1024)) "`get_rss $pid`" "`get_cmdline $pid`") + + clip_line "$output" +done diff --git a/bin/scrobble_cache b/bin/scrobble_cache new file mode 100644 index 0000000..4418211 --- /dev/null +++ b/bin/scrobble_cache @@ -0,0 +1,87 @@ +#!/usr/bin/env lua + +local socket = require 'socket' +local http = require 'socket.http' +local url = require 'socket.url' +local math = require 'math' + +local username = 'doyster' +local pass_hash = '63ff9c4d9cf5d1a68a63deeb74b034ef' + +function md5(str) + local file = io.popen('echo -n ' .. str .. ' | md5sum', 'r') + local ret = file:read() + file:close() + ret = string.sub(ret, 1, 32) + return ret +end + +function handshake(username) + local handshake_url = 'http://post.audioscrobbler.com/?hs=true&p=1.1&c=tst&v=1.0&u=' .. username + + print("Sending handshake request to " .. handshake_url) + response = http.request(handshake_url) + print("Response to handshake:\n" .. response) + local i = 1 + local response_lines = {} + for line in string.gfind(response, "[^\n]+") do + response_lines[i] = line + i = i + 1 + end + if i ~= 5 or string.sub(response_lines[1], 1, 2) ~= 'UP' then + return nil, "Error in handshake!" + end + + return response_lines +end + +function parse_cache(cache_text) + local tracks = {} + for track in string.gfind(cache_text, "a%[%d+%]=[^&]*&t%[%d+%]=[^&]*&b%[%d+%]=[^&]*&l%[%d+%]=[^&]*&i%[%d+%]=[^&]*&m%[%d+%]=[^&]*&") do + local _, _, artist, track, album, length, time, mbid = string.find(track, "a%[%d+%]=([^&]*)&t%[%d+%]=([^&]*)&b%[%d+%]=([^&]*)&l%[%d+%]=([^&]*)&i%[%d+%]=([^&]*)&m%[%d+%]=([^&]*)&") + table.insert(tracks, {artist = artist, + track = track, + album = album, + length = length, + time = time, + mbid = mbid}) + end + return tracks +end + +function submit(username, challenge_response, submit_url, tracks) + local to_submit = "" + for i, track in ipairs(tracks) do + to_submit = to_submit .. string.format("a[%d]=%s&t[%d]=%s&b[%d]=%s&l[%d]=%s&i[%d]=%s&m[%d]=%s&", i - 1, track.artist, i - 1, track.track, i - 1, track.album, i - 1, track.length, i - 1, track.time, i - 1, track.mbid) + end + + submission = 'u=' .. username .. '&s=' .. challenge_response .. '&' .. to_submit + print('Submitting ' .. submission .. ' to ' .. submit_url) + response = http.request(submit_url, url.unescape(submission)) + print("Response to submission:\n" .. response) +end + +local handshake_response = assert(handshake(username)) + +local challenge_response = md5(pass_hash .. handshake_response[2]) + +local file = io.open(arg[1], 'r') +local raw_tracks = file:read() +file:close() + +local tracks = parse_cache(raw_tracks) + +local to_submit = {} +for i = 0, math.floor(table.getn(tracks) / 10) - 1 do + for j = 1, 10 do + to_submit[j] = tracks[j+10*i] + end + submit(username, challenge_response, handshake_response[3], to_submit) + to_submit = {} + print("Sleeping...") + socket.sleep(2) +end +for j = 1, math.mod(table.getn(tracks), 10) do + to_submit[j] = tracks[j+10*math.floor(table.getn(tracks) / 10)] +end +submit(username, challenge_response, handshake_response[3], to_submit) diff --git a/bin/sendmessage b/bin/sendmessage new file mode 100644 index 0000000..14cbb38 --- /dev/null +++ b/bin/sendmessage @@ -0,0 +1,8 @@ +#!/bin/bash + +name=$1 +shift + +eval `dbus-launch` +export DBUS_SESSION_BUS_ADDRESS +gaim-remote "aim:goim?screenname=$name&message=$*" @@ -0,0 +1,7 @@ +#!/bin/bash + +SSH=/usr/bin/$(basename $0) + +keychain -q --timeout 30 ~/.ssh/id_dsa +. ~/.keychain/${HOSTNAME}-sh +$SSH $* diff --git a/bin/start_runlevel b/bin/start_runlevel new file mode 100644 index 0000000..1e467f0 --- /dev/null +++ b/bin/start_runlevel @@ -0,0 +1,11 @@ +#!/usr/bin/perl + +open LEVEL, "/var/lib/init.d/softlevel" or die; +$current_level = <LEVEL>; +close LEVEL; +chomp $current_level; + +@services = qx(ls /etc/runlevels/$current_level) =~ /\b\w+\b/g; +foreach $service(@services) { + system("/etc/init.d/$service start") unless -e "/var/lib/init.d/started/$service"; +} diff --git a/bin/watch_lock b/bin/watch_lock new file mode 100644 index 0000000..8d74e27 --- /dev/null +++ b/bin/watch_lock @@ -0,0 +1,9 @@ +#!/usr/bin/perl +open (IN, "xscreensaver-command -watch |"); +while (<IN>) { + if (m/^LOCK/) { + system "$ENV{HOME}/bin/on_lock" + } elsif (m/^UNBLANK/) { + #system "on_unlock" + } +} |