From 2627ee478439508e76837e9e26d6401be95a5522 Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Tue, 5 Jul 2011 23:29:44 +0200 Subject: [PATCH] added bizzybotte, cleaned up backup --- bitcoin.shallow/generate.py | 15 +++- bizzybotte/bizzybotte.pl | 138 ++++++++++++++++++++++++++++++++++++ osxbackup/backup.command | 34 +++++---- 3 files changed, 171 insertions(+), 16 deletions(-) create mode 100644 bizzybotte/bizzybotte.pl diff --git a/bitcoin.shallow/generate.py b/bitcoin.shallow/generate.py index 0b5e59e..7f08fde 100755 --- a/bitcoin.shallow/generate.py +++ b/bitcoin.shallow/generate.py @@ -8,12 +8,25 @@ import decimal def main(argv): current = fetch_mtgox_orders() + selling = selling_stats(current['bids']) + buying = buying_stats(current['asks']) + + +def selling_stats(bids): + high = max([bid[0] for bid in bids]) + low = min([bid[0] for bid in bids]) + print "highbid %s" % high + print "lowbid %s" % low + +def buying_stats(asks): + pass + def fetch_mtgox_orders(): url = 'https://mtgox.com/code/data/getDepth.php' parsed = json.loads( urllib.urlopen(url).read(), parse_float=decimal.Decimal ) - print repr(parsed) + return parsed sys.exit(main(sys.argv)) diff --git a/bizzybotte/bizzybotte.pl b/bizzybotte/bizzybotte.pl new file mode 100644 index 0000000..752a53e --- /dev/null +++ b/bizzybotte/bizzybotte.pl @@ -0,0 +1,138 @@ +use strict; +use warnings qw( all ); +use vars qw($VERSION %IRSSI); + +use Irssi; +$VERSION = '20070322'; +%IRSSI = ( + authors => 'sneak for #bantown', + contact => 'sneak@datavibe.net', + name => 'bizzybotte', + description => 'this script makes you sound like bizzy.', + license => 'Public Domain', +); + +sub send_text { + + #"send text", char *line, SERVER_REC, WI_ITEM_REC + my ( $data, $server, $witem ) = @_; + if ( $witem + && ( $witem->{type} eq "CHANNEL" ) + && $data + ) + { + $witem->command("msg $witem->{name} " . fuckestring($data)); + Irssi::signal_stop(); + } +} + +sub fuckestring ($) { + my $string; + if(@_) { + $string = shift; + } else { + $string = $_; + } + return '' unless $string; + my @things = parseline($string); + my $out; + foreach my $thing (@things) { + if($thing->{'type'} eq 'word') { + my $word = suffixword($thing->{'content'}); + $word = uc($word) + if + uc($thing->{'content'}) eq $thing->{'content'}; + $out .= $word; + } else { + $out .= $thing->{'content'}; + } + } + return $out; +} + +sub parseline { + local $_ = shift; + return unless $_; + my @sentence; + until (/\G$/gc) { # until pos at end of string + if (/\G([A-Za-z']+)/gc) { + push @sentence, { type => 'word', 'content' => $1 }; + } elsif (/\G([^A-Za-z']+)/gc) { + push @sentence, { type => 'other', 'content' => $1} ; + } + } + return @sentence; +} + +sub suffixword { + local $_ = shift; + return unless $_; + + return('lolle') if lc($_) eq 'lol'; + return('butte') if lc($_) eq 'but'; + + # some simple skips: + my $tmp = lc($_); + $tmp =~ s/[^a-z]//g; + return $_ if length($tmp) < 4; + #foreach my $skip (qw( + # bad heh ooh + #)) { + # return $_ if $tmp eq $skip; + #} + + # skip rules: + foreach my $suf (qw( e ng ing ed es ah l er )) { + if(/$suf[sS]*$/i) { + return $_; + } + } + + my $out = $_; + + # special cases where a consonant gets doubled + return('whatte') if ($tmp eq 'what'); + + # letters that end words that get doubled + # i.e. l as in 'lol'->'lolle' + foreach my $suf (qw( l g m n et p r )) { + if(/${suf}[sS]*$/i) { + return double_laste($_); + } else { + next; + } + return $out; + } + + # letters that end words that just get 'e' + # i.e. k as in 'fuck'->'fucke' + foreach my $suf (qw( d k h t )) { + if(/$suf[sS]*$/i) { + return single_laste($_); + } else { + next; + } + } + + # if we got this far, just return the original word unmodified + return $_; +} + +sub single_laste { + local $_ = shift; + my $s = ''; + if(/s$/i) { $s = 's'; s/s$//; } + return($_ . 'e' .$s); +} + +sub double_laste { + local $_ = shift; + my $s = ''; + if(/s$/i) { $s = 's'; s/s$//; } + /([a-zA-Z])$/; + my $last = $1; + $last = '' if /${last}${last}$/; + return($_ . $last . 'e' . $s); +} + +Irssi::signal_add('send text' => 'send_text'); diff --git a/osxbackup/backup.command b/osxbackup/backup.command index 34b8b40..97b2a90 100755 --- a/osxbackup/backup.command +++ b/osxbackup/backup.command @@ -7,8 +7,7 @@ NOW="`date +%Y%m%d.%H%M%S`" -BACKUPHOST=${BACKUPHOST:-"jfk1.datavibe.net"} -SERVERPATH=${SERVERPATH:-backup/} +BACKUPDEST=${BACKUPDEST:-"${USER}@jfk1.datavibe.net:backup/"} RSYNC="/usr/bin/rsync" OPTS="-aPSz --no-owner --no-group --delete-excluded --delete-after" @@ -24,13 +23,8 @@ RE+=" --exclude=/Library/Application?Support/Evernote/" RE+=" --exclude=/Library/Application?Support/InsomniaX/" RE+=" --exclude=/Music/iTunes/Album?Artwork/" RE+=" --exclude=/Documents/Steam?Content/" -RE+=" --exclude=/tmp/" -RE+=" --exclude=/.Spotlight-V100/" -RE+=" --exclude=/.fseventsd/" RE+=" --exclude=/.cpan/build/" RE+=" --exclude=/.cpan/sources/" -RE+=" --exclude=/.Trash/" -RE+=" --exclude=/.Trashes/" RE+=" --exclude=/Library/Logs/" # keep your mail on the server! RE+=" --exclude=/Library/Mail/" @@ -48,40 +42,50 @@ RE+=" --exclude=/Library/Safari/HistoryIndex.sk" RE+=" --exclude=/Library/Application?Support/CrossOver?Games/" RE+=" --exclude=/Library/Preferences/Macromedia/Flash?Player/" RE+=" --exclude=/Library/PubSub/" +# just say no to skynet RE+=" --exclude=/Library/Google/" RE+=" --exclude=/Library/Cookies/" -RE+=" --exclude=/.TemporaryItems/" -RE+=" --exclude=/.rnd/" RE+=" --exclude=/Receivd/" MINRE="" MINRE+=" --exclude=/.fseventsd/" MINRE+=" --exclude=/.Spotlight-V100/" +MINRE+=" --exclude=/.Trash/" MINRE+=" --exclude=/.Trashes/" MINRE+=" --exclude=/tmp/" +MINRE+=" --exclude=/.TemporaryItems/" +MINRE+=" --exclude=/.rnd/" + +RE+=" ${MINRE}" # before anything else, backup gpg keys if any: if [ -d ${HOME}/.gnupg ]; then - $RSYNC $OPTS -c ${HOME}/.gnupg/ ${BACKUPHOST}:${SERVERPATH}/Home/.gnupg/ + $RSYNC $OPTS -c ${HOME}/.gnupg/ ${BACKUPDEST}/Home/.gnupg/ +fi + +if [ -d ${HOME}/Development ]; then + $RSYNC $OPTS -c ${HOME}/Development/ \ + ${BACKUPDEST}/Home/Development/ fi RETVAL=255 while [ $RETVAL -ne 0 ]; do - $RSYNC $OPTS $RE ${HOME}/ ${BACKUPHOST}:${SERVERPATH}/Home/ + $RSYNC $OPTS $RE ${HOME}/ ${BACKUPDEST}/Home/ RETVAL=$? sleep 1; done RETVAL=255 while [ $RETVAL -ne 0 ]; do - $RSYNC $OPTS $MINRE --exclude=/ApertureScience.sparsebundle/ /Volumes/Storage/ ${BACKUPHOST}:${SERVERPATH}/Storage/ + $RSYNC $OPTS $MINRE --exclude=/ApertureScience.sparsebundle/ \ + /Volumes/Storage/ ${BACKUPDEST}/Storage/ RETVAL=$? sleep 1; done RETVAL=255 while [ $RETVAL -ne 0 ]; do - $RSYNC $OPTS /Applications/ ${BACKUPHOST}:${SERVERPATH}/Applications/ + $RSYNC $OPTS /Applications/ ${BACKUPDEST}/Applications/ RETVAL=$? sleep 1; done @@ -91,7 +95,8 @@ open /Volumes/Storage/ApertureScience.sparsebundle if [ -e /Volumes/ApertureScience ]; then RETVAL=255 while [ $RETVAL -ne 0 ]; do - $RSYNC $OPTS $MINRE /Volumes/ApertureScience/ ${BACKUPHOST}:${SERVERPATH}/ApertureScience/ + $RSYNC $OPTS $MINRE /Volumes/ApertureScience/ \ + ${BACKUPDEST}/ApertureScience/ RETVAL=$? sleep 1; done @@ -100,4 +105,3 @@ fi # FIXME todo do some error checking on the non-mountability of the # ApertureScience volume -