From: Don Armstrong Date: Sat, 1 Oct 2005 11:13:21 +0000 (+0000) Subject: added bin directory X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=7be10d24b200a2b83669c132f25badf75e2fd8fb;p=bin.git added bin directory --- 7be10d24b200a2b83669c132f25badf75e2fd8fb diff --git a/checksigs b/checksigs new file mode 100755 index 0000000..d0467f3 --- /dev/null +++ b/checksigs @@ -0,0 +1,42 @@ +#! /usr/bin/perl + +use warnings; +use strict; + +use IO::Dir; + +use Getopt::Long; + +my $config = {gpg => 'gpg', + }; + +($config->{program_name}) = $0 =~/([^\/]+)\s*$/; + +GetOptions($config,'gpg=s',); + +$config->{gpg_command} = qq($config->{gpg}); + +my @keys_to_check = @ARGV; + + +sub _get_unknown_keys($$){ + my ($config,$key_id) = @_; + + my $uid_listing = qx($config->{gpg_command} --with-colons --list-sigs $key_id 2>/dev/null); + foreach my $key_record (split(/\n/,$uid_listing)) { + next unless $key_record =~ /\:/; + my ($record_type,$calculated_trust,$key_length,$algorithm, + $full_key_id,$creation_date,$expiration_date,$serial_no, + $owner_trust,$user_id,$signature_class,$key_capabilities, + $smime_fingerprint,$flag_field, + ) = split(/\:/,$key_record); + next unless defined $user_id and $user_id eq '[User id not found]'; + qx($config->{gpg_command} --recv-keys $full_key_id 2>/dev/null); + print "Retreveved key: 0x".(substr $full_key_id, -8)."\n"; + } +} + +foreach my $key_id (@keys_to_check) { + _get_unknown_keys($config,$key_id); + print qx($config->{gpg_command} --check-sigs $key_id); +} diff --git a/deletemailbox b/deletemailbox new file mode 100755 index 0000000..cdd6f32 --- /dev/null +++ b/deletemailbox @@ -0,0 +1,108 @@ +#! /usr/bin/perl +# ss makes a screenshot of the screen using import, and is released +# under the terms of the GPL version 2, or any later version, at your +# option. See the file README and COPYING for more information. +# Copyright 2004 by Don Armstrong . +# $Id: ss,v 1.3 2004/09/27 05:58:55 don Exp $ + + +use warnings; +use strict; + + +use Getopt::Long; +use Pod::Usage; + +use POSIX qw(strftime); + +=head1 NAME + +deletemailbox -- deletes a mailbox and the offlineimap information corresponding to that mailbox + +=head1 SYNOPSIS + +ss [options] mailbox + + Options: + --account, -a account (Default lists) + --debug, -d debugging level (Default 0) + --help, -h display this help + --man, -m display manual + +=head1 OPTIONS + +=over + +=item B<--account, -a> + +Name of the account from which the folder will be deleted + +=item B<--debug, -d> + +Debug verbosity. (Default 0) + +=item B<--help, -h> + +Display brief useage information. + +=item B<--man, -m> + +Display this manual. + +=back + +=head1 EXAMPLES + +deletemailbox -a lists rnm-devel + +=cut + + +use User; +use vars qw($DEBUG); + +# XXX parse config file + +my %options = (debug => 0, + help => 0, + man => 0, + offlineimap => User->Home.'/.offlineimap', + maildir => User->Home.'/Mail', + account => 'lists', + ); + +GetOptions(\%options,'account|a=s','debug|d+','help|h|?','man|m'); + +pod2usage() if $options{help}; +pod2usage({verbose=>2}) if $options{man}; + +$DEBUG = $options{debug}; + + +for my $mbox (@ARGV) { + # Delete ~/.offlineimap/Repository-{Local,Remote}Lists/FolderValidity/mbox + # initialcaps account needed for the account name + my $cmd = qq(rm $options{offlineimap}/Repository-Local). + ucfirst($options{account}). + qq(/FolderValidity/$mbox;\n); + print $cmd; + qx($cmd); + $cmd = qq(rm $options{offlineimap}/Repository-Remote). + ucfirst($options{account}). + qq(/FolderValidity/$options{account}.$mbox;\n); + print $cmd; + qx($cmd); + # Delete ~/.offlineimap/Account-Lists/mbox + $cmd = qq(rm $options{offlineimap}/Account-).ucfirst($options{account}). + qq(/LocalStatus/$mbox;\n); + print $cmd; + qx($cmd); + # Delete ~/Mail/mbox + $cmd = qq(rm -rf $options{maildir}/$options{account}/$mbox;\n); + print $cmd; + qx($cmd); +} + + + +__END__ diff --git a/fixpic b/fixpic new file mode 100755 index 0000000..c23edbb --- /dev/null +++ b/fixpic @@ -0,0 +1,47 @@ +#! /usr/bin/perl + +use warnings; +use strict; + +use Image::Info qw(image_info); + +use IO::Dir; + +use Getopt::Std; + +my $config = {}; + +($config->{program_name}) = $0 =~/([^\/]+)\s*$/; + +if ($#ARGV < 0) { + print STDERR "No Directory Specified\nUsage: $config->{program_name} \n"; + exit 1; +} + +$config->{dir} ||= $ARGV[0]; + +my $current_directory = new IO::Dir $config->{dir} or die "Unable to read directory $config->{dir}"; + +while (defined($_ = $current_directory->read)) { + chomp; + next unless /(jpg|gif|jpeg|png|pict|bmp)$/i; + next unless -f $_; + + my $image_info = image_info($_); + next if not defined $image_info; + if ($image_info->{Orientation} eq 'left_bot') { + qx(mogrify -rotate -90 $_); + } + elsif ($image_info->{Orientation} eq 'top_left') { + qx(mogrify -noop $_); + } + elsif ($image_info->{Orientation} eq 'right_top') { + qx(mogrify -rotate 90 $_); + } + elsif ($image_info->{Orientation} eq 'right_bot') { + qx(mogrify -rotate 180 $_); + } + else { + qx(mogrify -noop $_); + } +} diff --git a/getmail b/getmail new file mode 100755 index 0000000..77900af --- /dev/null +++ b/getmail @@ -0,0 +1,22 @@ +#!/bin/sh + +# Configure the two things below for your MUA and the host being run. +IMAPHOST=rzlab.ucr.edu +MUA=mutt + +#set -x + +# Don't check mail if ~/.nocheck exists and we're not running +# interactively. +if [[ -z "$CRON" && -e ~/.nocheck ]]; then + exit 0; +fi; + +# See if the server exists +if [ -z "$CRON" ] || kill -0 `pgrep -U $(id -u) -x $MUA` 2>/dev/null; then + if ping -q -c 3 $IMAPHOST >/dev/null; then + nice -n 19 offlineimap -o -u Noninteractive.Basic 2>/dev/null |grep validity| \ + perl -ne 'my ($account,$list) = /UID validity problem for folder ([\w-]+)\.([\w-]+)/; + qx(/home/don/bin/deletemailbox -a $account $list > /dev/null);'; + fi; +fi; diff --git a/ps2ai b/ps2ai new file mode 100755 index 0000000..7efca1d --- /dev/null +++ b/ps2ai @@ -0,0 +1,27 @@ +#!/bin/sh +# $RCSfile: ps2epsi,v $ $Revision: 1.4.2.2 $ + +if [ $# -lt 1 -o $# -gt 2 ]; then + echo "Usage: `basename $0` file.ps [file.ai]" 1>&2 + exit 1 +fi + +infile=$1; + +if [ $# -eq 1 ] +then + case "${infile}" in + *.ps) base=`basename ${infile} .ps` ;; + *.cps) base=`basename ${infile} .cps` ;; + *.eps) base=`basename ${infile} .eps` ;; + *.epsf) base=`basename ${infile} .epsf` ;; + *) base=`basename ${infile}` ;; + esac + outfile=$( echo "${infile}"|perl -pe 's/\.[^\.]+$//').ai +else + outfile=$2 +fi + +gs -q -dNODISPLAY ps2ai.ps <${infile} > $outfile + +exit 0 diff --git a/renamepic b/renamepic new file mode 100755 index 0000000..9fcc567 --- /dev/null +++ b/renamepic @@ -0,0 +1,130 @@ +#! /usr/bin/perl + +# This program is used to rename pictures in a directory. First it +# displays the picture, then it lists a reasonable default name which +# can be edited. +# +# The image is then renamed if there doesn't exist an image with the +# same name already in the directory. + +# Sorting now is fixed. Images are sorted by shot order, rather than +# directory transversal. + +# BUGS: +# +# Renaming should be done in a loop rather than going through once +# only. [Eg, repeat the file on a renaming error.] + +# TODO: +# +# number of leading zeros adjustable... [or automatic?] +# + + +use warnings; +use strict; + +use IO::Dir; + +use Term::ReadLine; + +use Image::Info qw(image_info); + +use Getopt::Long; + +use Date::Calc qw(Date_to_Time); + +my $config = {counter_start => 1, + renumber_only => 0, + }; + +($config->{program_name}) = $0 =~/([^\/]+)\s*$/; + +GetOptions($config,'counter_start|c=i','renumber_only|r!'); + +if ($#ARGV < 0) { + print STDERR "No Directory Specified\nUsage: $config->{program_name} \n"; + exit 1; +} + +$config->{dir} ||= $ARGV[0]; + + +# The counter is used to keep the images in the order in which they +# were shot. It assumes that the order they are listed in the +# directory is the same as the order in which they were shot. May not +# always be true, but it's a decent guess. +my $file_counter = $config->{counter_start}; + +my $current_directory = new IO::Dir $config->{dir} or die "Unable to read directory $config->{dir}"; + +# We use readline to handle prompting for a new name for the picture +my $readline = new Term::ReadLine 'RenamePicture'; + +my @pictures = (); + +while (defined($_ = $current_directory->read)) { + #skip non images + next unless /(jpg|gif|jpeg|png|pict|bmp)$/i; + # Change the extension to lower case. + + my %picture = (); + + $picture{extension} = lc $1; + # ignore directories [directories named .bmp? strange.] + next unless -f $_; + + + # Read image info, and ignore images for which there is no + # info. [probably not really an image.] + $picture{image_info} = image_info($_); + next if not defined $picture{image_info}; + + $picture{old_name} = $_; + + # Default name is ${file_counter}__${picture_time}.${extension} + ($picture{clean_old_name}) = $picture{old_name} =~ /\d+\_(.*?)\_?\d+\.(?:jpg|gif|jpeg|png|pict|bmp)/i; + $picture{clean_old_name} ||= ''; + # Pull out the date and time when the image was shot + $picture{date_ymdhms} = [split(/[\s\:]+/,$picture{image_info}{DateTime})]; + $picture{picture_time} = join('',@{$picture{date_ymdhms}}[0..2]); + $picture{default_name} = qq(_$picture{clean_old_name}_$picture{picture_time}.$picture{extension}); + push @pictures, \%picture; +} + +# Sort + +@pictures = sort {Date_to_Time(@{$$a{date_ymdhms}})<=> Date_to_Time(@{$$b{date_ymdhms}})} @pictures; + +# Rename + +foreach my $picture (@pictures) { + my $line = sprintf('%03s',$file_counter).$$picture{default_name}; + # view the image + `xview -shrink $$picture{old_name} > /dev/null` unless $$config{renumber_only}; + + #prompt to rename the picture + print "Rename $$picture{old_name}\n"; + +# sprintf('%03s',$file_counter); + + $line = $readline->readline('new name:',$line) + unless $$config{renumber_only}; + # Remove leading and trailing spaces, replace all remaining + # spaces with _, and remove ugly characters. lowercase everything + # while we're at it. + $line =~ s/^\s*//; + $line =~ s/\s*$//; + $line =~ s/\s+/\_/g; + $line =~ tr/A-Z/a-z/; + $line =~ s/[^\w\_\-\d\.]//g; + # Make sure we're not saving over an existing file. + if (not -e $line) { + rename $$picture{old_name}, $line; + print "Renamed $$picture{old_name} to $line\n"; + } + else { + print STDERR "$line already exists, cowardly doing nothing to $$picture{old_name}.\n"; + } + $file_counter++; +} diff --git a/sanitize_filename b/sanitize_filename new file mode 100755 index 0000000..41f8b39 --- /dev/null +++ b/sanitize_filename @@ -0,0 +1,4 @@ +#! /bin/sh +# replace spaces with underscores, lowercase everything, ditch multiple underscores, and ditch _.foo. +# should probably try to avoid overwriting existing files, but c'est la vie! +rename 's/\s+/\_/g; $_ = lc($_); s/\_+/\_/g; s/\_\././' "$@" diff --git a/ss b/ss new file mode 100755 index 0000000..7dfc032 --- /dev/null +++ b/ss @@ -0,0 +1,158 @@ +#! /usr/bin/perl +# ss makes a screenshot of the screen using import, and is released +# under the terms of the GPL version 2, or any later version, at your +# option. See the file README and COPYING for more information. +# Copyright 2004 by Don Armstrong . +# $Id: ss,v 1.3 2004/09/27 05:58:55 don Exp $ + + +use warnings; +use strict; + + +use Getopt::Long; +use Pod::Usage; + +=head1 NAME + +ss - Take a screenshot of the screen, scale it, and upload it to a server + +=head1 SYNOPSIS + +ss [options] + + Options: + --host, -H host to upload image to + --dir, -D dir to place image (on host of -H set) + --import-options, -I options to import (default -window root) + --convert-options, -C options to convert (for scaling) + --scale, -s make scaled image (default) + --debug, -d debugging level (Default 0) + --help, -h display this help + --man, -m display manual + +=head1 OPTIONS + +=over + +=item B<--host, -H> + +The host where the image will be uploaded to using scp + +=item B<--dir, -D> + +The local (or remote if -H used) directory to place the resultant +screenshots + +=item B<--import-options, -I> + +The options used to invoke import. By default, -window root. (Which +will take a screenshot of the entire screen) + +=item B<--convert-options, -C> + +The options used to invoke convert, which will make a smaller image by +default. Only usefull if -s is set (which it is by default.) + +=item B<--scale, -s> + +If set (the default) a smaller image is made. (Technically, convert is +invoked with --convert-options, whether this scales depends on those +options.) To forgo scaling, use -s0 or --scale=0. + +=item B<--debug, -d> + +Debug verbosity. (Default 0) + +=item B<--help, -h> + +Display brief useage information. + +=item B<--man, -m> + +Display this manual. + +=back + +=head1 EXAMPLES + + ss + +Will pretty much do what you want + + ss -I + +Will take a picture of a window you select. + +=cut + + + +use User; +use File::Temp qw/tempfile tempdir/; + +use vars qw($DEBUG); + +# XXX parse config file + +my %options = (debug => 0, + help => 0, + man => 0, + host => undef, + dir => User->Home . '/ss', + import_options => '-window root', + import => 'import', + convert => 'convert', + convert_options => '-scale 25%', + scale => 1, + file_type => 'png', + scp => 'scp', + ); + +GetOptions(\%options,'host|H=s','import_options|I=s','file_type|t=s','scale|s!', + 'convert_options|C=s','dir|D=s','debug|d+','help|h|?','man|m'); + +pod2usage() if $options{help}; +pod2usage({verbose=>2}) if $options{man}; + +$DEBUG = $options{debug}; + + +# XXX use perl's date command instead +my ($sec,$min,$hour,$mday,$mon, + $year,$wday,$yday,$isdst) = localtime(time); +$year += 1900; +my $date = qq($year).(${mon}+1).qq(${mday}_${hour}${min}${sec}); + +my $tempdir = undef; + +# use tempdir if host defined +if (defined $options{host}) { + $tempdir = $options{tempdir} || tempdir( CLEANUP => 1 ); + print "chdir $tempdir\n" if $options{debug}; + chdir $tempdir or die "Unable to chidr to $tempdir"; +} +else { + print "chdir $options{dir}\n" if $options{debug}; + chdir $options{dir} or die "Unable to chdir to $options{dir}"; +} + +# import the image +print qq($options{import} $options{import_options} ss_${date}.$options{file_type}\n) if $options{debug}; +qx($options{import} $options{import_options} ss_${date}.$options{file_type}); + +# scale the image + +print qq($options{convert} $options{convert_options} ss_${date}.$options{file_type} ss_${date}_small.$options{file_type}\n) if $options{scale} and $options{debug}; +qx($options{convert} $options{convert_options} ss_${date}.$options{file_type} ss_${date}_small.$options{file_type}) if $options{scale}; + +# upload +if (defined $options{host}) { + my $files = "ss_${date}.$options{file_type}"; + $files .= " ss_${date}_small.$options{file_type}" if $options{scale}; + print qq($options{scp} $files $options{host}:$options{dir}\n) if $options{debug}; + qx($options{scp} $files $options{host}:$options{dir}); +} + + +__END__ diff --git a/wnppalert b/wnppalert new file mode 100755 index 0000000..2c2f4f8 --- /dev/null +++ b/wnppalert @@ -0,0 +1,39 @@ +#! /bin/sh -e + +# wnppalert -- check for orphaned or put up for adoption, installed packages + +# get a list of packages with bugnumbers. I tried with LDAP, but this is _much_ +# faster + +INSTALLED=`mktemp ${TMPDIR:-/tmp}/wnppalert-installed.XXXXXX` +WNPP=`mktemp ${TMPDIR:-/tmp}/wnppalert-wnpp.XXXXXX` +WNPP_PACKAGES=`mktemp ${TMPDIR:-/tmp}/wnppalert-wnpp_packages.XXXXXX` + +wget -qO - http://www.debian.org/devel/wnpp/orphaned| \ +egrep '^
  • \([^:]*\): \([^<]*\)<\/a>.*/O \1 \2 -- \3/'\ +> $WNPP + +wget -qO - http://www.debian.org/devel/wnpp/rfa_bypackage| \ +egrep '^
  • \([^:]*\): \([^<]*\)<\/a>.*/RFA \1 \2 -- \3/'\ +>> $WNPP + +cut -f3 -d' ' $WNPP | sort > $WNPP_PACKAGES + +# A list of installed files. This shouldn't use /var/lib/dpkg/status directly, but speed ... + +grep -B1 'Status: install ok installed' /var/lib/dpkg/status| \ +grep Package| \ +cut -f2 -d' '| \ +sort \ +> $INSTALLED + +( +comm -12 $WNPP_PACKAGES $INSTALLED | xargs -i grep {} $WNPP +echo +echo "Yours obediently, $0" +) + +rm $WNPP $WNPP_PACKAGES $INSTALLED +