Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

save configs

  • Loading branch information...
commit 8c30015b0f7b114ecbc03e2e415236a0d624f0da 1 parent edf93f8
Vincent Wang authored
27 .irbrc
@@ -5,14 +5,6 @@ require 'rubygems' unless defined? Gem
5 5 require 'irb/completion'
6 6 require 'irb/ext/save-history'
7 7
8   -require 'irbtools/configure'
9   -Irbtools.remove_library :wirb
10   -Irbtools.remove_library :fancy_irb
11   -Irbtools.remove_library :boson
12   -Irbtools.add_library :wirb, :thread => -1 do Wirb.start end
13   -#Irbtools.add_library :fancy_irb, :thread => -1 do FancyIrb.start end # fancy_irb breaks interactive_editor
14   -Irbtools.start
15   -
16 8 IRB.conf[:SAVE_HISTORY] = 1000
17 9 IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"
18 10 IRB.conf[:PROMPT_MODE] = :SIMPLE
@@ -23,12 +15,12 @@ class Object
23 15 (obj.methods - obj.class.superclass.instance_methods).sort
24 16 end
25 17
26   - # print documentation
27   - #
28   - # ri 'Array#pop'
29   - # Array.ri
30   - # Array.ri :pop
31   - # arr.ri :pop
  18 + #print documentation
  19 +
  20 + # ri 'Array#pop'
  21 + # Array.ri
  22 + # Array.ri :pop
  23 + # arr.ri :pop
32 24 def ri(method = nil)
33 25 unless method && method =~ /^[A-Z]/ # if class isn't specified
34 26 klass = self.kind_of?(Class) ? name : self.class.name
@@ -56,3 +48,10 @@ end
56 48
57 49 load File.dirname(__FILE__) + '/.railsrc' if $0 == 'irb' && ENV['RAILS_ENV']
58 50
  51 +require 'irbtools/configure'
  52 +Irbtools.remove_library :wirb
  53 +Irbtools.remove_library :fancy_irb
  54 +Irbtools.remove_library :boson
  55 +Irbtools.add_library :wirb, :thread => -1 do Wirb.start end
  56 +Irbtools.add_library :fancy_irb, :thread => -1 do FancyIrb.start end # fancy_irb breaks interactive_editor
  57 +Irbtools.start
2  .irssi/config
@@ -104,7 +104,7 @@ channels = (
104 104 { name = "#ubuntu-cn"; chatnet = "IRCnet"; autojoin = "yes"; },
105 105 { name = "#postgresql"; chatnet = "IRCnet"; autojoin = "yes"; },
106 106 { name = "silc"; chatnet = "silc"; autojoin = "No"; },
107   - { name = "#archlinux"; chatnet = "IRCnet"; autojoin = "yes"; }
  107 + { name = "#archlinux"; chatnet = "IRCnet"; autojoin = "yes"; },
108 108 { name = "#qt"; chatnet = "IRCnet"; autojoin = "yes"; }
109 109 );
110 110
100 .irssi/scripts/growl.pl
@@ -45,19 +45,19 @@
45 45 # Dev. info ^_^
46 46 $VERSION = "0.0";
47 47 %IRSSI = (
48   - authors => "Nate Murray",
49   - contact => "nate\@natemurray.com",
50   - name => "Growl",
51   - description => "Simple script that will growlnotify the messages",
52   - license => "GPL",
53   - url => "http://www.xcombinator.com",
54   - changed => "Mon Sep 22 11:55:07 PDT 2008"
  48 + authors => "Nate Murray",
  49 + contact => "nate\@natemurray.com",
  50 + name => "Growl",
  51 + description => "Simple script that will growlnotify the messages",
  52 + license => "GPL",
  53 + url => "http://www.xcombinator.com",
  54 + changed => "Mon Sep 22 11:55:07 PDT 2008"
55 55 );
56 56
57 57 # All the works
58 58 sub do_growl {
59   - my ($server, $title, $data) = @_;
60   - my $icon = growl_locate_icon(Irssi::settings_get_str('growl_icon'));
  59 + my ($server, $title, $data) = @_;
  60 + my $icon = growl_locate_icon(Irssi::settings_get_str('growl_icon'));
61 61 $data =~ s/["';]//g;
62 62 if ($server->{usermode_away}) {
63 63 system("growlnotify --sticky --image '$icon' -m '$data' -t '$title' >> /dev/null 2>&1");
@@ -68,27 +68,19 @@ sub do_growl {
68 68 }
69 69
70 70 sub growl_it {
71   - my ($server, $title, $data, $channel, $nick) = @_;
  71 + my ($server, $title, $data, $channel, $nick) = @_;
72 72
73 73 my $filter = Irssi::settings_get_str('growl_on_regex');
74 74 my $channel_filter = Irssi::settings_get_str('growl_channel_regex');
75 75 my $growl_on_nick = Irssi::settings_get_str('growl_on_nick');
76 76
77 77 my $current_nick = $server->{nick};
78   - if($growl_on_nick && $current_nick =~ /$nick/i) {
79   - $title = $title . " " . $channel;
80   - do_growl($server, $title, $data);
81   - return 0;
82   - }
83   -
84   - return 0 if(!$channel_filter && !$filter);
85   -
86   - if($channel_filter && $server->ischannel($channel)) {
87   - return 0 if $channel !~ /$channel_filter/i;
88   - }
89   - if($filter) {
90   - return 0 if $data !~ /$filter/i;
91   - }
  78 + if($filter) {
  79 + return 0 if $data !~ /$filter/;
  80 + }
  81 + if($channel_filter && $server->ischannel($channel)) {
  82 + return 0 if $channel !~ /$channel_filter/;
  83 + }
92 84
93 85 $title = $title . " " . $channel;
94 86 do_growl($server, $title, $data);
@@ -96,64 +88,64 @@ sub growl_it {
96 88
97 89 # All the works
98 90 sub growl_message {
99   - my ($server, $data, $nick, $mask, $target) = @_;
  91 + my ($server, $data, $nick, $mask, $target) = @_;
100 92 growl_it($server, $nick, $data, $target, $nick);
101   - Irssi::signal_continue($server, $data, $nick, $mask, $target);
  93 + Irssi::signal_continue($server, $data, $nick, $mask, $target);
102 94 }
103 95
104 96 sub growl_join {
105   - my ($server, $channel, $nick, $address) = @_;
  97 + my ($server, $channel, $nick, $address) = @_;
106 98 growl_it($server, "Join", "$nick has joined", $channel, $nick);
107   - Irssi::signal_continue($server, $channel, $nick, $address);
  99 + Irssi::signal_continue($server, $channel, $nick, $address);
108 100 }
109 101
110 102 sub growl_part {
111   - my ($server, $channel, $nick, $address) = @_;
  103 + my ($server, $channel, $nick, $address) = @_;
112 104 growl_it($server, "Part", "$nick has parted", $channel, $nick);
113   - Irssi::signal_continue($server, $channel, $nick, $address);
  105 + Irssi::signal_continue($server, $channel, $nick, $address);
114 106 }
115 107
116 108 sub growl_quit {
117   - my ($server, $nick, $address, $reason) = @_;
  109 + my ($server, $nick, $address, $reason) = @_;
118 110 growl_it($server, "Quit", "$nick has quit: $reason", $server, $nick);
119   - Irssi::signal_continue($server, $nick, $address, $reason);
  111 + Irssi::signal_continue($server, $nick, $address, $reason);
120 112 }
121 113
122 114 sub growl_invite {
123   - my ($server, $channel, $nick, $address) = @_;
  115 + my ($server, $channel, $nick, $address) = @_;
124 116 growl_it($server, "Invite", "$nick has invited you on $channel", $channel, $nick);
125   - Irssi::signal_continue($server, $channel, $address);
  117 + Irssi::signal_continue($server, $channel, $address);
126 118 }
127 119
128 120 sub growl_topic {
129   - my ($server, $channel, $topic, $nick, $address) = @_;
  121 + my ($server, $channel, $topic, $nick, $address) = @_;
130 122 growl_it($server, "Topic: $topic", "$nick has changed the topic to $topic on $channel", $channel, $nick);
131   - Irssi::signal_continue($server, $channel, $topic, $nick, $address);
  123 + Irssi::signal_continue($server, $channel, $topic, $nick, $address);
132 124 }
133 125
134 126 sub growl_privmsg {
135   - # $server = server record where the message came
136   - # $data = the raw data received from server, with PRIVMSGs it is:
137   - # "target :text" where target is either your nick or #channel
138   - # $nick = the nick who sent the message
139   - # $host = host of the nick who sent the message
140   - my ($server, $data, $nick, $host) = @_;
  127 + # $server = server record where the message came
  128 + # $data = the raw data received from server, with PRIVMSGs it is:
  129 + # "target :text" where target is either your nick or #channel
  130 + # $nick = the nick who sent the message
  131 + # $host = host of the nick who sent the message
  132 + my ($server, $data, $nick, $host) = @_;
141 133 my ($target, $text) = split(/ :/, $data, 2);
142 134 # growl_it($server, $nick, $data, $target, $nick); # actually, don't do this.
143   - Irssi::signal_continue($server, $data, $nick, $host);
  135 + Irssi::signal_continue($server, $data, $nick, $host);
144 136 }
145 137
146 138 sub growl_locate_icon {
147   - # $file = the name of the icon file to look for
148   - my ($file) = @_;
149   - if (-e "$file") {
150   - return "$file";
151   - }
152   - foreach (@INC) {
153   - if (-e "$_/$file") {
154   - return "$_/$file";
155   - }
156   - }
  139 + # $file = the name of the icon file to look for
  140 + my ($file) = @_;
  141 + if (-e "$file") {
  142 + return "$file";
  143 + }
  144 + foreach (@INC) {
  145 + if (-e "$_/$file") {
  146 + return "$_/$file";
  147 + }
  148 + }
157 149 }
158 150
159 151 # Hook me up
@@ -170,4 +162,4 @@ sub growl_locate_icon {
170 162 Irssi::signal_add('message quit', 'growl_quit');
171 163 Irssi::signal_add('message invite', 'growl_invite');
172 164 Irssi::signal_add('message topic', 'growl_topic');
173   -Irssi::signal_add('event privmsg', 'growl_privmsg');
  165 +Irssi::signal_add('event privmsg', 'growl_privmsg');
10 .mailcap.macosx
... ... @@ -1,13 +1,13 @@
1 1 # Images
2   -Image/JPEG; /Users/vincent/tools/mac_tool/view_attachment %s jpeg
3   -Image/PNG; /Users/vincent/tools/mac_tool/view_attachment %s png
4   -Image/GIF; /Users/vincent/tools/mac_tool/view_attachment %s gif
  2 +Image/JPEG; /Users/vincent/tools/mac_tool/view_attachment.sh %s jpeg
  3 +Image/PNG; /Users/vincent/tools/mac_tool/view_attachment.sh %s png
  4 +Image/GIF; /Users/vincent/tools/mac_tool/view_attachment.sh %s gif
5 5
6 6 # UnIdentified.
7   -Application/octet-stream; /Users/vincent/tools/mac_tool/view_attachment %s "-"
  7 +Application/octet-stream; /Users/vincent/tools/mac_tool/view_attachment.sh %s "-"
8 8
9 9 # PDF
10   -Application/PDF; /Users/vincent/tools/mac_tool/view_attachment %s pdf
  10 +Application/PDF; /Users/vincent/tools/mac_tool/view_attachment.sh %s pdf
11 11 document/pdf; /Users/vincent/tools/mac_tool/view_attachment.sh %s -
12 12
13 13 # HTML
29 .offlineimaprc
@@ -476,20 +476,27 @@ folderfilter = lambda foldername: foldername in ['INBOX',
476 476 '[Gmail]/Sent Mail',
477 477 '[Gmail]/Drafts',
478 478 '[Gmail]/Starred',
479   - 'Seravia',
480   - 'GitNotification',
481   - '[list]tmux',
482   - '[list]TopLanguage',
483   - '[list]mutt',
484   - '[list]xptemplate',
485   - '[list]vim_user',
486   - '[list]mongodb',
487   - '[list]iTerm2',
488   - 'GoogleAlert',
489   - 'DailyRead',
  479 + 'EasyIO',
  480 + #'Seravia',
  481 + #'GitNotification',
  482 + #'[list]tmux',
  483 + #'[list]TopLanguage',
  484 + #'[list]mutt',
  485 + #'[list]xptemplate',
  486 + #'[list]vim_user',
  487 + #'[list]mongodb',
  488 + #'[list]iTerm2',
  489 + #'GoogleAlert',
  490 + #'DailyRead',
490 491 '96angel',
491 492 '[2010]06_11',
492 493 '[2010]01_06',
  494 + 'CIL',
  495 + 'CIL/Notification',
493 496 ]
494 497
  498 +# imap.gmail.com fingerprint
  499 +#cert_fingerprint=f3043dd689a2e7dddfbef82703a6c65ea9b634c1
  500 +cert_fingerprint=6d1b5b5ee0180ab493b71d3b94534b5ab937d042
  501 +
495 502 # vim: ft=python.conf
23 .tmux.conf
@@ -11,6 +11,12 @@ bind o send-prefix
11 11
12 12 set -g visual-content on
13 13 set -g display-panes-time 3000
  14 +
  15 +set -g default-terminal "screen-256color"
  16 +
  17 +# C-m means Enter
  18 +setw -g monitor-activity off
  19 +
14 20 # }}}1
15 21
16 22 # {{{1 key bindings
@@ -120,8 +126,21 @@ set -g status-interval 5
120 126 set -g status-left-length 60
121 127 set -g status-right-length 1000
122 128 set -g status-left ' ❐ #[fg=magenta,bold]#S#[default] ▐ '
123   -set -g status-right '▐ ♫ #[fg=green]#(mpc current)#[default]▐ ❖ #[fg=magenta,bold]#(load.sh)#[default]▐ ⌚ #[fg=yellow,bold]%a %m/%d %H:%M#[default]▐ #[fg=green]@#H#[default]'
  129 +set -g status-right '▐ ⓔ #[fg=magenta,bold]#(~/mytools/new_mail.sh)#[default]▐ ♫ #[fg=green]#(mpc current)#[default]▐ ❖ #[fg=magenta,bold]#(load.sh)#[default]▐ ⌚ #[fg=yellow,bold]%a %m/%d %H:%M#[default]▐ #[fg=green]@#H#[default]'
  130 +
  131 +# }}}1
  132 +
  133 +# {{{1 macosx copy/paste wrapper
  134 +# need to compile tmux wrapper script first
  135 +# $ git clone https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard.git
  136 +# $ cd tmux-MacOSX-pasteboard/
  137 +# $ make reattach-to-user-namespace
  138 +# $ sudo mv reattach-to-user-namespace /usr/local/bin
  139 +set -g default-command "reattach-to-user-namespace -l /bin/bash"
  140 +
  141 +#bind C-c run "tmux save-buffer - | reattach-to-user-namespace pbcopy"
  142 +#bind C-v run "tmux set-buffer $(reattach-to-user-namespace pbpaste); tmux paste-buffer"
124 143
125 144 # }}}1
126 145
127   -source-file '/Users/vincent/.tmux.conf.local'
  146 +#source-file '/Users/vincent/.tmux.conf.local'
3  mytools/myrtags
@@ -28,7 +28,8 @@ find $* \
28 28 -path '*/doc/*' -or \
29 29 -path '*/log/*' -or \
30 30 -path '*/tax_chart/*' -or \
31   - -path '*/coverage/*' \
  31 + -path '*/coverage/*' -or \
  32 + -path '.*cache*' \
32 33 \) -prune -or \
33 34 -type f -print | \
34 35 ctags -R --sort=yes -L -
20 mytools/session.sh
... ... @@ -1,12 +1,14 @@
1   -#!/bin/sh -x
  1 +#! /bin/bash
2 2
3   -[ ! -z "$TMUX" ] && exit
  3 +tmux start-server
4 4
5   -monit
  5 +session=${1:-base}
  6 +if ! $(tmux has-session -t $session ); then
  7 + env TMUX= tmux start-server \; source-file $HOME/.tmux/profiles/$session
  8 +fi
6 9
7   -#TMUX="tmux -udLmain" # for v1.0- version
8   -TMUX="tmux -u" # use 'default' socket
9   -
10   -$TMUX has -t work 2>/dev/null || $TMUX -q start
11   -#exec $TMUX attach -d -t work
12   -exec $TMUX attach -t work # don't use '-d' if you want to multiuser can attach to the same session at the same time
  10 +if [ -z $TMUX ]; then
  11 + tmux -u attach-session -t $session
  12 +else
  13 + tmux -u switch-client -t $session
  14 +fi
334 tools/s3-common-functions
... ... @@ -1,334 +0,0 @@
1   -#! /usr/bin/env bash
2   -cat > /dev/null << EndOfLicence
3   -s3-bash
4   -Copyright 2007 Raphael James Cohn
5   -
6   -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7   -in compliance with the License.
8   -You may obtain a copy of the License at
9   -
10   - http://www.apache.org/licenses/LICENSE-2.0
11   -
12   -Unless required by applicable law or agreed to in writing, software distributed under the License
13   -is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14   -or implied. See the License for the specific language governing permissions and limitations under
15   -the License.
16   -EndOfLicence
17   -
18   -# Pragmas
19   -set -u
20   -set -e
21   -
22   -# Constants
23   -readonly version="0.02"
24   -readonly userSpecifiedDataErrorExitCode=1
25   -readonly invalidCommandLineOption=2
26   -readonly internalErrorExitCode=3
27   -readonly invalidEnvironmentExitCode=4
28   -readonly ipadXorByte=0x36
29   -readonly opadXorByte=0x5c
30   -
31   -# Command-like aliases
32   -readonly sha1="openssl dgst -sha1 -binary"
33   -readonly base64encode="openssl enc -base64 -e -in"
34   -readonly base64decode="openssl enc -base64 -d -in"
35   -
36   -# Globals
37   -declare -a temporaryFiles
38   -
39   -function base64EncodedMD5
40   -{
41   - openssl dgst -md5 -binary "$1" | openssl enc -e -base64
42   -}
43   -
44   -function printErrorMessage
45   -{
46   - printf "%s: %s\n" "$1" "$2" 1>&2
47   -}
48   -
49   -function printErrorHelpAndExit
50   -{
51   - printErrorMessage "$weAreKnownAs" "$1"
52   - printHelpAndExit $2
53   -}
54   -
55   -function checkProgramIsInEnvironment
56   -{
57   - if [ ! -x "$(which $1)" ]; then
58   - printErrorHelpAndExit "Environment Error: $1 not found on the path or not executable" $invalidEnvironmentExitCode
59   - fi
60   -}
61   -
62   -# Do not use this from directly. Due to a bug in bash, array assignments do not work when the function is used with command substitution
63   -function createTemporaryFile
64   -{
65   - local temporaryFile="$(mktemp "$temporaryDirectory/$$.$1.XXXXXXXX")" || printErrorHelpAndExit "Environment Error: Could not create a temporary file. Please check you /tmp folder permissions allow files and folders to be created and disc space." $invalidEnvironmentExitCode
66   - local length="${#temporaryFiles[@]}"
67   - temporaryFiles[$length]="$temporaryFile"
68   -}
69   -
70   -function mostRecentTemporaryFile
71   -{
72   - local length="${#temporaryFiles[@]}"
73   - local lastIndex
74   - ((lastIndex = --length))
75   - echo "${temporaryFiles[$lastIndex]}"
76   -}
77   -
78   -function deleteTemporaryFile
79   -{
80   - rm -f "$1" || printErrorHelpAndExit "Environment Error: Could not delete a temporary file ($1)." $invalidEnvironmentExitCode
81   -}
82   -
83   -function removeTemporaryFiles
84   -{
85   - length="${#temporaryFiles[@]}"
86   - if [ $length -eq 0 ]; then
87   - return
88   - fi
89   - for temporaryFile in ${temporaryFiles[@]}; do
90   - deleteTemporaryFile "$temporaryFile"
91   - done
92   - temporaryFiles=()
93   - length="${#temporaryFiles[@]}"
94   -}
95   -
96   -function checkEnvironment
97   -{
98   - programs=(openssl curl od dd printf sed awk sort mktemp rm grep cp ls env bash)
99   - for program in "${programs[@]}"; do
100   - checkProgramIsInEnvironment "$program"
101   - done
102   -
103   - local temporaryFolder="${TMPDIR:-/tmp}"
104   - if [ ! -x "$temporaryFolder" ]; then
105   - printErrorHelpAndExit "Environment Error: The temporary directory ($temporaryFolder) does not exist. Please set the TMPDIR environment variable to your temporary directory" $invalidEnvironmentExitCode
106   - fi
107   - readonly temporaryDirectory="$temporaryFolder/s3-bash/$weAreKnownAs"
108   - mkdir -p "$temporaryDirectory" || printErrorHelpAndExit "Environment Error: Could not create a temporary directory ($temporaryDiectory). Please check you /tmp folder permissions allow files and folders to be created and you have sufficient disc space" $invalidEnvironmentExitCode
109   -
110   - #Check we can create and delete temporary files
111   - createTemporaryFile "check"
112   - temporaryFileCheck="$(mostRecentTemporaryFile)"
113   - echo "Checking we can write to temporary files. If this is still here then we could not delete temporary files." > "$temporaryFileCheck"
114   - removeTemporaryFiles
115   -}
116   -
117   -function setErrorTraps
118   -{
119   - trap "removeTemporaryFiles; exit $internalErrorExitCode" INT TERM EXIT
120   -}
121   -
122   -function unsetErrorTraps
123   -{
124   - trap - INT TERM EXIT
125   -}
126   -
127   -function verifyUrl
128   -{
129   - if [ -z "$url" ]; then
130   - printErrorHelpAndExit "URL not specified" $userSpecifiedDataErrorExitCode
131   - elif echo $url | grep -q http://; then
132   - printErrorHelpAndExit "URL starts with http://" $userSpecifiedDataErrorExitCode
133   - elif echo $url | grep -q https://; then
134   - printErrorHelpAndExit "URL starts with https://" $userSpecifiedDataErrorExitCode
135   - elif echo $url | grep -v ^/; then
136   - printErrorHelpAndExit "URL does not start with /" $userSpecifiedDataErrorExitCode
137   - fi
138   -}
139   -
140   -function appendHash
141   -{
142   - local fileToHash="$1"
143   - local fileToWriteTo="$2"
144   - $sha1 "$fileToHash" >> "$fileToWriteTo"
145   -}
146   -
147   -function writeHash
148   -{
149   - local fileToHash="$1"
150   - local fileToWriteTo="$2"
151   - $sha1 -out "$fileToWriteTo" "$fileToHash"
152   -}
153   -
154   -function checkAwsKey
155   -{
156   - local originalKeyFile="$1"
157   - local keySize="$(ls -l "$originalKeyFile" | awk '{ print $5 }')"
158   - if [ ! $keySize -eq 40 ]; then
159   - printErrorHelpAndExit "We do not understand Amazon AWS secret keys which are not 40 bytes long. Have you included a carriage return or line feed by mistake at the end of the secret key file?" $userSpecifiedDataErrorExitCode
160   - fi
161   -}
162   -
163   -function padDecodedKeyTo
164   -{
165   - local originalKeyFile="$1"
166   - local keyFile="$2"
167   - cp "$originalKeyFile" "$keyFile"
168   -
169   - local keySize=$(ls -l "$keyFile" | awk '{ print $5 }')
170   - if [ $keySize -lt 64 ]; then
171   - local zerosToWrite=$((64 - $keySize))
172   - dd if=/dev/zero of=$keyFile bs=1 count=$zerosToWrite seek=$keySize 2> /dev/null
173   - elif [ $keySize -gt 64 ]; then
174   - echo "Warning: Support for hashing keys bigger than the SHA1 block size of 64 bytes is untested" 1>&2
175   - writeHash "$originalKeyFile" "$keyFile"
176   - local keySize=$(ls -l "$keyFile" | awk '{ print $5 }')
177   - if [ $keySize -lt 64 ]; then
178   - local zerosToWrite=$((64 - $keySize))
179   - dd if=/dev/zero of=$keyFile bs=1 count=$zerosToWrite seek=$keySize 2> /dev/null
180   - fi
181   - exit 1
182   - else
183   - :
184   - fi
185   -}
186   -
187   -function writeLongAsByte
188   -{
189   - local byte="$1"
190   - local file="$2"
191   - printf "\\$(printf "%o" $byte)" >> "$file"
192   -}
193   -
194   -function readBytesAndXorAndWriteAsBytesTo
195   -{
196   - local inputFile="$1"
197   - local xorByte=$2
198   - local outputFile="$3"
199   -
200   - od -v -A n -t uC "$inputFile" | awk '{ OFS="\n"; for (i = 1; i <= NF; i++) print $i }' |
201   - while read byte; do
202   - ((xord = byte ^ xorByte))
203   - writeLongAsByte $xord "$outputFile"
204   - done
205   -}
206   -
207   -function writeHexByte
208   -{
209   - local byte="$1"
210   - local file="$2"
211   - printf "\\$(printf "%o" 0x$byte)" >> "$file"
212   -}
213   -
214   -function writeHexString
215   -{
216   - local hexString="$1"
217   - for byte in $(echo $hexString | sed 's/../& /g'); do
218   - writeHexByte "$byte" "$2"
219   - done
220   -}
221   -
222   -function writeStringToSign
223   -{
224   - local outputFile="$1"
225   - echo $verb >> "$outputFile"
226   - echo "$contentMD5" >> "$outputFile"
227   - echo "$contentType" >> "$outputFile"
228   - echo "$currentDateTime" >> "$outputFile"
229   -
230   - writeStringToSignAmazonHeaders "$outputFile"
231   -
232   - urlPath="$(echo "$url" | awk 'BEGIN { FS="[?]"} { print $1 }')"
233   - urlQueryString="$(echo "$url" | awk 'BEGIN { FS="[?]"} { print $2 }')"
234   - printf "$urlPath" >> "$outputFile"
235   - if [ "$urlQueryString" = "acl" ] || [ "$urlQueryString" = "torrent" ]; then
236   - printf "?" >> "$outputFile"
237   - printf "$urlQueryString" >> "$outputFile"
238   - fi
239   -}
240   -
241   -function writeStringToSignAmazonHeaders()
242   -{
243   - local outputFile="$1"
244   -
245   - #Convert all headers to lower case
246   - #sort
247   - #Strip ": " to ":"
248   - #Add LF to each header
249   - awk 'BEGIN { FS=": " } NF == 2 { print tolower($1) ":" $2 }' "$amazonHeaderFile" | sort >> "$outputFile"
250   - #TODO: RFC 2616, section 4.2 (combine repeated headers' values)
251   - #TODO: Unfold long lines (not supported elsewhere)
252   -}
253   -
254   -function computeAwsAuthorizationHeader
255   -{
256   - checkAwsKey "$awsAccessSecretKeyIdFile"
257   -
258   - createTemporaryFile "key"
259   - local tempKeyFile="$(mostRecentTemporaryFile)"
260   -
261   - createTemporaryFile "ipad"
262   - local ipadHashingFile="$(mostRecentTemporaryFile)"
263   -
264   - createTemporaryFile "opad"
265   - local opadHashingFile="$(mostRecentTemporaryFile)"
266   -
267   - createTemporaryFile "HMAC-SHA1"
268   - local hmacSha1File="$(mostRecentTemporaryFile)"
269   -
270   - padDecodedKeyTo "$awsAccessSecretKeyIdFile" "$tempKeyFile"
271   - readBytesAndXorAndWriteAsBytesTo "$tempKeyFile" ipadXorByte "$ipadHashingFile"
272   -
273   - writeStringToSign "$ipadHashingFile"
274   -
275   - readBytesAndXorAndWriteAsBytesTo "$tempKeyFile" opadXorByte "$opadHashingFile"
276   - appendHash "$ipadHashingFile" "$opadHashingFile"
277   - writeHash "$opadHashingFile" "$hmacSha1File"
278   -
279   - local signature="$($base64encode "$hmacSha1File")"
280   -
281   - echo "Authorization: AWS $awsAccessKeyId:$signature"
282   -}
283   -
284   -function writeAmazonHeadersForCurl
285   -{
286   - if [ ! -e "$amazonHeaderFile" ]; then
287   - printErrorHelpAndExit "Amazon Header file does not exist" $userSpecifiedDataErrorExitCode
288   - elif grep -q ^X-Amz-Date: "$amazonHeaderFile"; then
289   - printErrorHelpAndExit "X-Amz-Date header not allowed" $userSpecifiedDataErrorExitCode
290   - fi
291   - # Consider using sed...
292   - awk 'BEGIN { ORS=" "; FS="\0" } { print "--header \"" $1 "\""}' "$amazonHeaderFile" >> "$1"
293   -}
294   -
295   -function runCurl
296   -{
297   - local verbAndAnyData="$1"
298   - local fullUrl="$protocol://s3.amazonaws.com$url"
299   - createTemporaryFile "curl"
300   - local tempCurlCommand="$(mostRecentTemporaryFile)"
301   - local cleanUpCommand="rm -f "$tempCurlCommand""
302   -
303   - echo "#! /usr/bin/env bash" >> "$tempCurlCommand"
304   - printf "curl %s %s --dump-header \"%s\" " "$verbose" "$verbAndAnyData" "$dumpHeaderFile" >> "$tempCurlCommand"
305   - writeAmazonHeadersForCurl "$tempCurlCommand"
306   - printf " --header \"%s\"" "Date: $currentDateTime" >> "$tempCurlCommand"
307   - printf " --header \"%s\"" "$authorizationHeader" >> "$tempCurlCommand"
308   - if [ ! -z "$contentType" ]; then
309   - printf " --header \"Content-Type: %s\"" "$contentType" >> "$tempCurlCommand"
310   - fi
311   - if [ ! -z "$contentMD5" ]; then
312   - printf " --header \"Content-MD5: %s\"" "$contentMD5" >> "$tempCurlCommand"
313   - fi
314   - printf " \"%s\"\n" "$fullUrl" >> "$tempCurlCommand"
315   -
316   - unsetErrorTraps
317   - exec env bash "$tempCurlCommand"
318   -}
319   -
320   -function initialise
321   -{
322   - setErrorTraps
323   - checkEnvironment
324   -}
325   -
326   -function main
327   -{
328   - initialise
329   - parseOptions "$@"
330   - readonly currentDateTime="$(LC_TIME=C date "+%a, %d %h %Y %T %z")"
331   - prepareToRunCurl
332   - readonly authorizationHeader="$(computeAwsAuthorizationHeader)"
333   - runCurl "$verbToPass"
334   -}
106 tools/s3-delete
... ... @@ -1,106 +0,0 @@
1   -#! /usr/bin/env bash
2   -cat > /dev/null << EndOfLicence
3   -s3-bash
4   -Copyright 2007 Raphael James Cohn
5   -
6   -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7   -in compliance with the License.
8   -You may obtain a copy of the License at
9   -
10   - http://www.apache.org/licenses/LICENSE-2.0
11   -
12   -Unless required by applicable law or agreed to in writing, software distributed under the License
13   -is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14   -or implied. See the License for the specific language governing permissions and limitations under
15   -the License.
16   -EndOfLicence
17   -
18   -# Pragmas
19   -set -u
20   -set -e
21   -
22   -function printHelpAndExit
23   -{
24   - exitCode=$1
25   - printf "%s: version %s\n" "$weAreKnownAs" "$version"
26   - printf "Part of s3-bash. Latest version is at %s\n" 'http://code.google.com/p/s3-bash/'
27   - printf "Usage %s: -h\n" "$weAreKnownAs"
28   - printf "Usage %s: [-vS] [-H file] [-a file] -k key -s file url\n" "$weAreKnownAs"
29   - printf " Option\tType\tRequirement\tDescription\n"
30   - printf " -h\t\tprecedent\tprint this help\n"
31   - printf " -v\t\toptional\tverbose output\n"
32   - printf " -k\tstring\tmandatory\tAWS Access Key Id\n"
33   - printf " -s\tfile\tmandatory\tAWS Secret Access Key Id File\n"
34   - printf " -S\t\toptional\tUse https\n"
35   - printf " -H\tfile\toptional\tFile to write response headers to\n"
36   - printf " -a\tfile\toptional\tFile to read Amazon custom headers from (X-Amz-Date is not allowed)\n"
37   - printf " \turl\tmandatory\trelative url including bucket name and leading slash, eg /bucket/path/to/object?acl. Assumed to be already encoded\n"
38   - printf "\n"
39   - printf "Notes\n"
40   - printf "Specify proxies using a ~/.curlrc file\n"
41   - exit $exitCode
42   -}
43   -
44   -function parseOptions
45   -{
46   - verbose=""
47   - url=""
48   - awsAccessKeyId=""
49   - awsAccessSecretKeyIdFile=""
50   - protocol="http"
51   - dumpHeaderFile="/dev/null"
52   - amazonHeaderFile="/dev/null"
53   - while getopts "hvk:s:SH:T:a:" optionName; do
54   - case "$optionName" in
55   - h) printHelpAndExit 0;;
56   - v) verbose="-v";;
57   - k) awsAccessKeyId="$OPTARG";;
58   - s) awsAccessSecretKeyIdFile="$OPTARG"
59   - if [ ! -e "$awsAccessSecretKeyIdFile" ]; then
60   - printErrorHelpAndExit "AWS Secret Key Id file does not exist" $userSpecifiedDataErrorExitCode
61   - fi;;
62   - S) protocol="https";;
63   - H) dumpHeaderFile="$OPTARG";;
64   - a) amazonHeaderFile="$OPTARG";;
65   - [?]) printErrorHelpAndExit "Option not recognised" $userSpecifiedDataErrorExitCode;;
66   - esac
67   - done
68   - if [ 1 -eq $OPTIND ]; then
69   - printErrorHelpAndExit "Internal Error: parseOptions or a parent method in the call stack was not called with $"@"." $internalErrorExitCode
70   - fi
71   - let "toShift = $OPTIND - 1"
72   - shift $toShift
73   - if [ $# -eq 0 ]; then
74   - printErrorHelpAndExit "URL not specified" $userSpecifiedDataErrorExitCode
75   - fi
76   - url="$1"
77   - verifyUrl
78   -
79   - if [ -z "$awsAccessSecretKeyIdFile" ]; then
80   - printErrorHelpAndExit "AWS Secret Access Key file not specified" $userSpecifiedDataErrorExitCode
81   - elif [ -z "$awsAccessKeyId" ]; then
82   - printErrorHelpAndExit "AWS Access Key Id not specified" $userSpecifiedDataErrorExitCode
83   - fi
84   -}
85   -
86   -function prepareToRunCurl
87   -{
88   - readonly verb="DELETE"
89   - readonly verbToPass="-X DELETE"
90   - readonly contentMD5=""
91   - readonly contentType=""
92   -}
93   -
94   -readonly weAreKnownAs="$(basename $0)"
95   -readonly ourPath="$(dirname $0)"
96   -
97   -readonly commonFunctions="$ourPath/s3-common-functions"
98   -if [ -e "$commonFunctions" ]; then
99   - source "$commonFunctions"
100   -else
101   - version="Unknown"
102   - invalidEnvironmentExitCode=4
103   - printHelpAndExit "$weAreKnownAs: Could not locate file s3-common-functions" $invalidEnvironmentExitCode
104   -fi
105   -
106   -main "$@"
108 tools/s3-get
... ... @@ -1,108 +0,0 @@
1   -#! /usr/bin/env bash
2   -cat > /dev/null << EndOfLicence
3   -s3-bash
4   -Copyright 2007 Raphael James Cohn
5   -
6   -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7   -in compliance with the License.
8   -You may obtain a copy of the License at
9   -
10   - http://www.apache.org/licenses/LICENSE-2.0
11   -
12   -Unless required by applicable law or agreed to in writing, software distributed under the License
13   -is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14   -or implied. See the License for the specific language governing permissions and limitations under
15   -the License.
16   -EndOfLicence
17   -
18   -# Pragmas
19   -set -u
20   -set -e
21   -
22   -function printHelpAndExit
23   -{
24   - exitCode=$1
25   - printf "%s: version %s\n" "$weAreKnownAs" "$version"
26   - printf "Part of s3-bash. Latest version is at %s\n" 'http://code.google.com/p/s3-bash/'
27   - printf "Usage %s: -h\n" "$weAreKnownAs"
28   - printf "Usage %s: [-vS] [-H file] [-a file] -k key -s file url\n" "$weAreKnownAs"
29   - printf " Option\tType\tRequirement\tDescription\n"
30   - printf " -h\t\tprecedent\tprint this help\n"
31   - printf " -v\t\toptional\tverbose output\n"
32   - printf " -k\tstring\tmandatory\tAWS Access Key Id\n"
33   - printf " -s\tfile\tmandatory\tAWS Secret Access Key Id File\n"
34   - printf " -S\t\toptional\tUse https\n"
35   - printf " -H\tfile\toptional\tFile to write response headers to\n"
36   - printf " -a\tfile\toptional\tFile to read Amazon custom headers from (X-Amz-Date is not allowed)\n"
37   - printf " \turl\tmandatory\trelative url including bucket name and leading slash, eg /bucket/path/to/object?acl. Assumed to be already encoded\n"
38   - printf "\n"
39   - printf "Notes\n"
40   - printf "Specify proxies using a ~/.curlrc file\n"
41   - printf "Content is returned on stdout\n"
42   - exit $exitCode
43   -}
44   -
45   -function parseOptions
46   -{
47   - verbose=""
48   - url=""
49   - awsAccessKeyId=""
50   - awsAccessSecretKeyIdFile=""
51   - protocol="http"
52   - dumpHeaderFile="/dev/null"
53   - amazonHeaderFile="/dev/null"
54   - while getopts "hvk:s:SH:a:" optionName; do
55   - case "$optionName" in
56   - h) printHelpAndExit 0;;
57   - v) verbose="-v";;
58   - k) awsAccessKeyId="$OPTARG";;
59   - s) awsAccessSecretKeyIdFile="$OPTARG"
60   - if [ ! -e "$awsAccessSecretKeyIdFile" ]; then
61   - printErrorHelpAndExit "AWS Secret Key Id file does not exist" $userSpecifiedDataErrorExitCode
62   - fi;;
63   - S) protocol="https";;
64   - H) dumpHeaderFile="$OPTARG";;
65   - a) amazonHeaderFile="$OPTARG"
66   - ;;
67   - [?]) printErrorHelpAndExit "Option not recognised" $userSpecifiedDataErrorExitCode;;
68   - esac
69   - done
70   - if [ 1 -eq $OPTIND ]; then
71   - printErrorHelpAndExit "Internal Error: parseOptions or a parent method in the call stack was not called with $"@"." $internalErrorExitCode
72   - fi
73   - let "toShift = $OPTIND - 1"
74   - shift $toShift
75   - if [ $# -eq 0 ]; then
76   - printErrorHelpAndExit "URL not specified" $userSpecifiedDataErrorExitCode
77   - fi
78   - url="$1"
79   - verifyUrl
80   -
81   - if [ -z "$awsAccessSecretKeyIdFile" ]; then
82   - printErrorHelpAndExit "AWS Secret Access Key file not specified" $userSpecifiedDataErrorExitCode
83   - elif [ -z "$awsAccessKeyId" ]; then
84   - printErrorHelpAndExit "AWS Access Key Id not specified" $userSpecifiedDataErrorExitCode
85   - fi
86   -}
87   -
88   -function prepareToRunCurl
89   -{
90   - readonly verb="GET"
91   - readonly verbToPass="--get"
92   - readonly contentMD5=""
93   - readonly contentType=""
94   -}
95   -
96   -readonly weAreKnownAs="$(basename $0)"
97   -readonly ourPath="$(dirname $0)"
98   -
99   -readonly commonFunctions="$ourPath/s3-common-functions"
100   -if [ -e "$commonFunctions" ]; then
101   - source "$commonFunctions"
102   -else
103   - version="Unknown"
104   - invalidEnvironmentExitCode=4
105   - printErrorHelpAndExit "$weAreKnownAs: Could not locate file s3-common-functions" $invalidEnvironmentExitCode
106   -fi
107   -
108   -main "$@"
119 tools/s3-put
... ... @@ -1,119 +0,0 @@
1   -#! /usr/bin/env bash
2   -cat > /dev/null << EndOfLicence
3   -s3-bash
4   -Copyright 2007 Raphael James Cohn
5   -
6   -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7   -in compliance with the License.
8   -You may obtain a copy of the License at
9   -
10   - http://www.apache.org/licenses/LICENSE-2.0
11   -
12   -Unless required by applicable law or agreed to in writing, software distributed under the License
13   -is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14   -or implied. See the License for the specific language governing permissions and limitations under
15   -the License.
16   -EndOfLicence
17   -
18   -# Pragmas
19   -set -u
20   -set -e
21   -
22   -function printHelpAndExit
23   -{
24   - exitCode=$1
25   - printf "%s: version %s\n" "$weAreKnownAs" "$version"
26   - printf "Part of s3-bash. Latest version is at %s\n" 'http://code.google.com/p/s3-bash/'
27   - printf "Usage %s: -h\n" "$weAreKnownAs"
28   - printf "Usage %s: [-vS] [-H file] [-a file] -k key -s file -T file url\n" "$weAreKnownAs"
29   - printf " Option\tType\tRequirement\tDescription\n"
30   - printf " -h\t\tprecedent\tprint this help\n"
31   - printf " -v\t\toptional\tverbose output\n"
32   - printf " -k\tstring\tmandatory\tAWS Access Key Id\n"
33   - printf " -s\tfile\tmandatory\tAWS Secret Access Key Id File\n"
34   - printf " -T\tfile\tmandatory\tFile (or stdin with -) to PUT\n"
35   - printf " -S\t\toptional\tUse https\n"
36   - printf " -H\tfile\toptional\tFile to write response headers to\n"
37   - printf " -a\tfile\toptional\tFile to read Amazon custom headers from (X-Amz-Date is not allowed)\n"
38   - printf " -c\tMIME\toptional\tMIME Content type. Default is text/plain\n"
39   - printf " \turl\tmandatory\trelative url including bucket name and leading slash, eg /bucket/path/to/object?acl. Assumed to be already encoded\n"
40   - printf "\n"
41   - printf "Notes\n"
42   - printf "Specify proxies using a ~/.curlrc file\n"
43   - printf "Specify content to PUT using stdin using option -T -\n"
44   - exit $exitCode
45   -}
46   -
47   -function parseOptions
48   -{
49   - verbose=""
50   - url=""
51   - awsAccessKeyId=""
52   - awsAccessSecretKeyIdFile=""
53   - protocol="http"
54   - fileToUpload=""
55   - dumpHeaderFile="/dev/null"
56   - amazonHeaderFile="/dev/null"
57   - contentType="text/plain"
58   - while getopts "hvk:s:SH:T:a:c:" optionName; do
59   - case "$optionName" in
60   - h) printHelpAndExit 0;;
61   - v) verbose="-v";;
62   - k) awsAccessKeyId="$OPTARG";;
63   - s) awsAccessSecretKeyIdFile="$OPTARG"
64   - if [ ! -e "$awsAccessSecretKeyIdFile" ]; then
65   - printErrorHelpAndExit "AWS Secret Key Id file does not exist" $userSpecifiedDataErrorExitCode
66   - fi;;
67   - S) protocol="https";;
68   - H) dumpHeaderFile="$OPTARG";;
69   - T) fileToUpload="$OPTARG";;
70   - a) amazonHeaderFile="$OPTARG";;
71   - c) contentType="$OPTARG";;
72   - [?]) printErrorHelpAndExit "Option not recognised" $userSpecifiedDataErrorExitCode;;
73   - esac
74   - done
75   - if [ 1 -eq $OPTIND ]; then
76   - printErrorHelpAndExit "Internal Error: parseOptions or a parent method in the call stack was not called with $"@"." $internalErrorExitCode
77   - fi
78   - let "toShift = $OPTIND - 1"
79   - shift $toShift
80   - if [ $# -eq 0 ]; then
81   - printErrorHelpAndExit "URL not specified" $userSpecifiedDataErrorExitCode
82   - fi
83   - url="$1"
84   - verifyUrl
85   -
86   - if [ -z "$awsAccessSecretKeyIdFile" ]; then
87   - printErrorHelpAndExit "AWS Secret Access Key file not specified" $userSpecifiedDataErrorExitCode
88   - elif [ -z "$awsAccessKeyId" ]; then
89   - printErrorHelpAndExit "AWS Access Key Id not specified" $userSpecifiedDataErrorExitCode
90   - elif [ -z "$fileToUpload" ]; then
91   - printErrorHelpAndExit "File to upload not specified" $userSpecifiedDataErrorExitCode
92   - fi
93   -}
94   -
95   -function prepareToRunCurl
96   -{
97   - readonly verb="PUT"
98   - if [ ! "-" = "$fileToUpload" ]; then
99   - readonly contentMD5="$(base64EncodedMD5 "$fileToUpload")"
100   - readonly verbToPass="-T \"$fileToUpload\""
101   - else
102   - readonly contentMD5=""
103   - readonly verbToPass="-T -"
104   - fi
105   -}
106   -
107   -readonly weAreKnownAs="$(basename $0)"
108   -readonly ourPath="$(dirname $0)"
109   -
110   -readonly commonFunctions="$ourPath/s3-common-functions"
111   -if [ -e "$commonFunctions" ]; then
112   - source "$commonFunctions"
113   -else
114   - version="Unknown"
115   - invalidEnvironmentExitCode=4
116   - printErrorHelpAndExit "$weAreKnownAs: Could not locate file s3-common-functions" $invalidEnvironmentExitCode
117   -fi
118   -
119   -main "$@"
7 tools/wol
@@ -7,5 +7,8 @@ s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
7 7
8 8 # wake up a windows box in chengxuan office
9 9 # to wake other computer, just replace the mac address
10   -mac_addr = '\x00\x1a\xa0\xbe\xd1\x56'
11   -s.sendto('\xff'*6 + mac_addr*16, ("255.255.255.255",9))
  10 +#mac_addr = '\xf4\x6d\x04\x56\x73\xbe'
  11 +mac_addr = '\x00\x11\x32\x16\x7b\x2c'
  12 +s.sendto('\xff'*6 + mac_addr*16, ("255.255.255.255", 7))
  13 +s.close()
  14 +

0 comments on commit 8c30015

Please sign in to comment.
Something went wrong with that request. Please try again.