Permalink
Browse files

save configs

  • Loading branch information...
1 parent edf93f8 commit 8c30015b0f7b114ecbc03e2e415236a0d624f0da @linsong committed Dec 18, 2012
Showing with 122 additions and 766 deletions.
  1. +13 −14 .irbrc
  2. +1 −1 .irssi/config
  3. +46 −54 .irssi/scripts/growl.pl
  4. +5 −5 .mailcap.macosx
  5. +18 −11 .offlineimaprc
  6. +21 −2 .tmux.conf
  7. +2 −1 mytools/myrtags
  8. +11 −9 mytools/session.sh
  9. +0 −334 tools/s3-common-functions
  10. +0 −106 tools/s3-delete
  11. +0 −108 tools/s3-get
  12. +0 −119 tools/s3-put
  13. +5 −2 tools/wol
View
27 .irbrc
@@ -5,14 +5,6 @@ require 'rubygems' unless defined? Gem
require 'irb/completion'
require 'irb/ext/save-history'
-require 'irbtools/configure'
-Irbtools.remove_library :wirb
-Irbtools.remove_library :fancy_irb
-Irbtools.remove_library :boson
-Irbtools.add_library :wirb, :thread => -1 do Wirb.start end
-#Irbtools.add_library :fancy_irb, :thread => -1 do FancyIrb.start end # fancy_irb breaks interactive_editor
-Irbtools.start
-
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"
IRB.conf[:PROMPT_MODE] = :SIMPLE
@@ -23,12 +15,12 @@ class Object
(obj.methods - obj.class.superclass.instance_methods).sort
end
- # print documentation
- #
- # ri 'Array#pop'
- # Array.ri
- # Array.ri :pop
- # arr.ri :pop
+ #print documentation
+
+ # ri 'Array#pop'
+ # Array.ri
+ # Array.ri :pop
+ # arr.ri :pop
def ri(method = nil)
unless method && method =~ /^[A-Z]/ # if class isn't specified
klass = self.kind_of?(Class) ? name : self.class.name
@@ -56,3 +48,10 @@ end
load File.dirname(__FILE__) + '/.railsrc' if $0 == 'irb' && ENV['RAILS_ENV']
+require 'irbtools/configure'
+Irbtools.remove_library :wirb
+Irbtools.remove_library :fancy_irb
+Irbtools.remove_library :boson
+Irbtools.add_library :wirb, :thread => -1 do Wirb.start end
+Irbtools.add_library :fancy_irb, :thread => -1 do FancyIrb.start end # fancy_irb breaks interactive_editor
+Irbtools.start
View
2 .irssi/config
@@ -104,7 +104,7 @@ channels = (
{ name = "#ubuntu-cn"; chatnet = "IRCnet"; autojoin = "yes"; },
{ name = "#postgresql"; chatnet = "IRCnet"; autojoin = "yes"; },
{ name = "silc"; chatnet = "silc"; autojoin = "No"; },
- { name = "#archlinux"; chatnet = "IRCnet"; autojoin = "yes"; }
+ { name = "#archlinux"; chatnet = "IRCnet"; autojoin = "yes"; },
{ name = "#qt"; chatnet = "IRCnet"; autojoin = "yes"; }
);
View
100 .irssi/scripts/growl.pl
@@ -45,19 +45,19 @@
# Dev. info ^_^
$VERSION = "0.0";
%IRSSI = (
- authors => "Nate Murray",
- contact => "nate\@natemurray.com",
- name => "Growl",
- description => "Simple script that will growlnotify the messages",
- license => "GPL",
- url => "http://www.xcombinator.com",
- changed => "Mon Sep 22 11:55:07 PDT 2008"
+ authors => "Nate Murray",
+ contact => "nate\@natemurray.com",
+ name => "Growl",
+ description => "Simple script that will growlnotify the messages",
+ license => "GPL",
+ url => "http://www.xcombinator.com",
+ changed => "Mon Sep 22 11:55:07 PDT 2008"
);
# All the works
sub do_growl {
- my ($server, $title, $data) = @_;
- my $icon = growl_locate_icon(Irssi::settings_get_str('growl_icon'));
+ my ($server, $title, $data) = @_;
+ my $icon = growl_locate_icon(Irssi::settings_get_str('growl_icon'));
$data =~ s/["';]//g;
if ($server->{usermode_away}) {
system("growlnotify --sticky --image '$icon' -m '$data' -t '$title' >> /dev/null 2>&1");
@@ -68,92 +68,84 @@ sub do_growl {
}
sub growl_it {
- my ($server, $title, $data, $channel, $nick) = @_;
+ my ($server, $title, $data, $channel, $nick) = @_;
my $filter = Irssi::settings_get_str('growl_on_regex');
my $channel_filter = Irssi::settings_get_str('growl_channel_regex');
my $growl_on_nick = Irssi::settings_get_str('growl_on_nick');
my $current_nick = $server->{nick};
- if($growl_on_nick && $current_nick =~ /$nick/i) {
- $title = $title . " " . $channel;
- do_growl($server, $title, $data);
- return 0;
- }
-
- return 0 if(!$channel_filter && !$filter);
-
- if($channel_filter && $server->ischannel($channel)) {
- return 0 if $channel !~ /$channel_filter/i;
- }
- if($filter) {
- return 0 if $data !~ /$filter/i;
- }
+ if($filter) {
+ return 0 if $data !~ /$filter/;
+ }
+ if($channel_filter && $server->ischannel($channel)) {
+ return 0 if $channel !~ /$channel_filter/;
+ }
$title = $title . " " . $channel;
do_growl($server, $title, $data);
}
# All the works
sub growl_message {
- my ($server, $data, $nick, $mask, $target) = @_;
+ my ($server, $data, $nick, $mask, $target) = @_;
growl_it($server, $nick, $data, $target, $nick);
- Irssi::signal_continue($server, $data, $nick, $mask, $target);
+ Irssi::signal_continue($server, $data, $nick, $mask, $target);
}
sub growl_join {
- my ($server, $channel, $nick, $address) = @_;
+ my ($server, $channel, $nick, $address) = @_;
growl_it($server, "Join", "$nick has joined", $channel, $nick);
- Irssi::signal_continue($server, $channel, $nick, $address);
+ Irssi::signal_continue($server, $channel, $nick, $address);
}
sub growl_part {
- my ($server, $channel, $nick, $address) = @_;
+ my ($server, $channel, $nick, $address) = @_;
growl_it($server, "Part", "$nick has parted", $channel, $nick);
- Irssi::signal_continue($server, $channel, $nick, $address);
+ Irssi::signal_continue($server, $channel, $nick, $address);
}
sub growl_quit {
- my ($server, $nick, $address, $reason) = @_;
+ my ($server, $nick, $address, $reason) = @_;
growl_it($server, "Quit", "$nick has quit: $reason", $server, $nick);
- Irssi::signal_continue($server, $nick, $address, $reason);
+ Irssi::signal_continue($server, $nick, $address, $reason);
}
sub growl_invite {
- my ($server, $channel, $nick, $address) = @_;
+ my ($server, $channel, $nick, $address) = @_;
growl_it($server, "Invite", "$nick has invited you on $channel", $channel, $nick);
- Irssi::signal_continue($server, $channel, $address);
+ Irssi::signal_continue($server, $channel, $address);
}
sub growl_topic {
- my ($server, $channel, $topic, $nick, $address) = @_;
+ my ($server, $channel, $topic, $nick, $address) = @_;
growl_it($server, "Topic: $topic", "$nick has changed the topic to $topic on $channel", $channel, $nick);
- Irssi::signal_continue($server, $channel, $topic, $nick, $address);
+ Irssi::signal_continue($server, $channel, $topic, $nick, $address);
}
sub growl_privmsg {
- # $server = server record where the message came
- # $data = the raw data received from server, with PRIVMSGs it is:
- # "target :text" where target is either your nick or #channel
- # $nick = the nick who sent the message
- # $host = host of the nick who sent the message
- my ($server, $data, $nick, $host) = @_;
+ # $server = server record where the message came
+ # $data = the raw data received from server, with PRIVMSGs it is:
+ # "target :text" where target is either your nick or #channel
+ # $nick = the nick who sent the message
+ # $host = host of the nick who sent the message
+ my ($server, $data, $nick, $host) = @_;
my ($target, $text) = split(/ :/, $data, 2);
# growl_it($server, $nick, $data, $target, $nick); # actually, don't do this.
- Irssi::signal_continue($server, $data, $nick, $host);
+ Irssi::signal_continue($server, $data, $nick, $host);
}
sub growl_locate_icon {
- # $file = the name of the icon file to look for
- my ($file) = @_;
- if (-e "$file") {
- return "$file";
- }
- foreach (@INC) {
- if (-e "$_/$file") {
- return "$_/$file";
- }
- }
+ # $file = the name of the icon file to look for
+ my ($file) = @_;
+ if (-e "$file") {
+ return "$file";
+ }
+ foreach (@INC) {
+ if (-e "$_/$file") {
+ return "$_/$file";
+ }
+ }
}
# Hook me up
@@ -170,4 +162,4 @@ sub growl_locate_icon {
Irssi::signal_add('message quit', 'growl_quit');
Irssi::signal_add('message invite', 'growl_invite');
Irssi::signal_add('message topic', 'growl_topic');
-Irssi::signal_add('event privmsg', 'growl_privmsg');
+Irssi::signal_add('event privmsg', 'growl_privmsg');
View
10 .mailcap.macosx
@@ -1,13 +1,13 @@
# Images
-Image/JPEG; /Users/vincent/tools/mac_tool/view_attachment %s jpeg
-Image/PNG; /Users/vincent/tools/mac_tool/view_attachment %s png
-Image/GIF; /Users/vincent/tools/mac_tool/view_attachment %s gif
+Image/JPEG; /Users/vincent/tools/mac_tool/view_attachment.sh %s jpeg
+Image/PNG; /Users/vincent/tools/mac_tool/view_attachment.sh %s png
+Image/GIF; /Users/vincent/tools/mac_tool/view_attachment.sh %s gif
# UnIdentified.
-Application/octet-stream; /Users/vincent/tools/mac_tool/view_attachment %s "-"
+Application/octet-stream; /Users/vincent/tools/mac_tool/view_attachment.sh %s "-"
# PDF
-Application/PDF; /Users/vincent/tools/mac_tool/view_attachment %s pdf
+Application/PDF; /Users/vincent/tools/mac_tool/view_attachment.sh %s pdf
document/pdf; /Users/vincent/tools/mac_tool/view_attachment.sh %s -
# HTML
View
29 .offlineimaprc
@@ -476,20 +476,27 @@ folderfilter = lambda foldername: foldername in ['INBOX',
'[Gmail]/Sent Mail',
'[Gmail]/Drafts',
'[Gmail]/Starred',
- 'Seravia',
- 'GitNotification',
- '[list]tmux',
- '[list]TopLanguage',
- '[list]mutt',
- '[list]xptemplate',
- '[list]vim_user',
- '[list]mongodb',
- '[list]iTerm2',
- 'GoogleAlert',
- 'DailyRead',
+ 'EasyIO',
+ #'Seravia',
+ #'GitNotification',
+ #'[list]tmux',
+ #'[list]TopLanguage',
+ #'[list]mutt',
+ #'[list]xptemplate',
+ #'[list]vim_user',
+ #'[list]mongodb',
+ #'[list]iTerm2',
+ #'GoogleAlert',
+ #'DailyRead',
'96angel',
'[2010]06_11',
'[2010]01_06',
+ 'CIL',
+ 'CIL/Notification',
]
+# imap.gmail.com fingerprint
+#cert_fingerprint=f3043dd689a2e7dddfbef82703a6c65ea9b634c1
+cert_fingerprint=6d1b5b5ee0180ab493b71d3b94534b5ab937d042
+
# vim: ft=python.conf
View
23 .tmux.conf
@@ -11,6 +11,12 @@ bind o send-prefix
set -g visual-content on
set -g display-panes-time 3000
+
+set -g default-terminal "screen-256color"
+
+# C-m means Enter
+setw -g monitor-activity off
+
# }}}1
# {{{1 key bindings
@@ -120,8 +126,21 @@ set -g status-interval 5
set -g status-left-length 60
set -g status-right-length 1000
set -g status-left ' ❐ #[fg=magenta,bold]#S#[default] ▐ '
-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]'
+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]'
+
+# }}}1
+
+# {{{1 macosx copy/paste wrapper
+# need to compile tmux wrapper script first
+# $ git clone https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard.git
+# $ cd tmux-MacOSX-pasteboard/
+# $ make reattach-to-user-namespace
+# $ sudo mv reattach-to-user-namespace /usr/local/bin
+set -g default-command "reattach-to-user-namespace -l /bin/bash"
+
+#bind C-c run "tmux save-buffer - | reattach-to-user-namespace pbcopy"
+#bind C-v run "tmux set-buffer $(reattach-to-user-namespace pbpaste); tmux paste-buffer"
# }}}1
-source-file '/Users/vincent/.tmux.conf.local'
+#source-file '/Users/vincent/.tmux.conf.local'
View
3 mytools/myrtags
@@ -28,7 +28,8 @@ find $* \
-path '*/doc/*' -or \
-path '*/log/*' -or \
-path '*/tax_chart/*' -or \
- -path '*/coverage/*' \
+ -path '*/coverage/*' -or \
+ -path '.*cache*' \
\) -prune -or \
-type f -print | \
ctags -R --sort=yes -L -
View
20 mytools/session.sh
@@ -1,12 +1,14 @@
-#!/bin/sh -x
+#! /bin/bash
-[ ! -z "$TMUX" ] && exit
+tmux start-server
-monit
+session=${1:-base}
+if ! $(tmux has-session -t $session ); then
+ env TMUX= tmux start-server \; source-file $HOME/.tmux/profiles/$session
+fi
-#TMUX="tmux -udLmain" # for v1.0- version
-TMUX="tmux -u" # use 'default' socket
-
-$TMUX has -t work 2>/dev/null || $TMUX -q start
-#exec $TMUX attach -d -t work
-exec $TMUX attach -t work # don't use '-d' if you want to multiuser can attach to the same session at the same time
+if [ -z $TMUX ]; then
+ tmux -u attach-session -t $session
+else
+ tmux -u switch-client -t $session
+fi
View
334 tools/s3-common-functions
@@ -1,334 +0,0 @@
-#! /usr/bin/env bash
-cat > /dev/null << EndOfLicence
-s3-bash
-Copyright 2007 Raphael James Cohn
-
-Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
-in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed under the License
-is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
-or implied. See the License for the specific language governing permissions and limitations under
-the License.
-EndOfLicence
-
-# Pragmas
-set -u
-set -e
-
-# Constants
-readonly version="0.02"
-readonly userSpecifiedDataErrorExitCode=1
-readonly invalidCommandLineOption=2
-readonly internalErrorExitCode=3
-readonly invalidEnvironmentExitCode=4
-readonly ipadXorByte=0x36
-readonly opadXorByte=0x5c
-
-# Command-like aliases
-readonly sha1="openssl dgst -sha1 -binary"
-readonly base64encode="openssl enc -base64 -e -in"
-readonly base64decode="openssl enc -base64 -d -in"
-
-# Globals
-declare -a temporaryFiles
-
-function base64EncodedMD5
-{
- openssl dgst -md5 -binary "$1" | openssl enc -e -base64
-}
-
-function printErrorMessage
-{
- printf "%s: %s\n" "$1" "$2" 1>&2
-}
-
-function printErrorHelpAndExit
-{
- printErrorMessage "$weAreKnownAs" "$1"
- printHelpAndExit $2
-}
-
-function checkProgramIsInEnvironment
-{
- if [ ! -x "$(which $1)" ]; then
- printErrorHelpAndExit "Environment Error: $1 not found on the path or not executable" $invalidEnvironmentExitCode
- fi
-}
-
-# 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
-function createTemporaryFile
-{
- 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
- local length="${#temporaryFiles[@]}"
- temporaryFiles[$length]="$temporaryFile"
-}
-
-function mostRecentTemporaryFile
-{
- local length="${#temporaryFiles[@]}"
- local lastIndex
- ((lastIndex = --length))
- echo "${temporaryFiles[$lastIndex]}"
-}
-
-function deleteTemporaryFile
-{
- rm -f "$1" || printErrorHelpAndExit "Environment Error: Could not delete a temporary file ($1)." $invalidEnvironmentExitCode
-}
-
-function removeTemporaryFiles
-{
- length="${#temporaryFiles[@]}"
- if [ $length -eq 0 ]; then
- return
- fi
- for temporaryFile in ${temporaryFiles[@]}; do
- deleteTemporaryFile "$temporaryFile"
- done
- temporaryFiles=()
- length="${#temporaryFiles[@]}"
-}
-
-function checkEnvironment
-{
- programs=(openssl curl od dd printf sed awk sort mktemp rm grep cp ls env bash)
- for program in "${programs[@]}"; do
- checkProgramIsInEnvironment "$program"
- done
-
- local temporaryFolder="${TMPDIR:-/tmp}"
- if [ ! -x "$temporaryFolder" ]; then
- printErrorHelpAndExit "Environment Error: The temporary directory ($temporaryFolder) does not exist. Please set the TMPDIR environment variable to your temporary directory" $invalidEnvironmentExitCode
- fi
- readonly temporaryDirectory="$temporaryFolder/s3-bash/$weAreKnownAs"
- 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
-
- #Check we can create and delete temporary files
- createTemporaryFile "check"
- temporaryFileCheck="$(mostRecentTemporaryFile)"
- echo "Checking we can write to temporary files. If this is still here then we could not delete temporary files." > "$temporaryFileCheck"
- removeTemporaryFiles
-}
-
-function setErrorTraps
-{
- trap "removeTemporaryFiles; exit $internalErrorExitCode" INT TERM EXIT
-}
-
-function unsetErrorTraps
-{
- trap - INT TERM EXIT
-}
-
-function verifyUrl
-{
- if [ -z "$url" ]; then
- printErrorHelpAndExit "URL not specified" $userSpecifiedDataErrorExitCode
- elif echo $url | grep -q http://; then
- printErrorHelpAndExit "URL starts with http://" $userSpecifiedDataErrorExitCode
- elif echo $url | grep -q https://; then
- printErrorHelpAndExit "URL starts with https://" $userSpecifiedDataErrorExitCode
- elif echo $url | grep -v ^/; then
- printErrorHelpAndExit "URL does not start with /" $userSpecifiedDataErrorExitCode
- fi
-}
-
-function appendHash
-{
- local fileToHash="$1"
- local fileToWriteTo="$2"
- $sha1 "$fileToHash" >> "$fileToWriteTo"
-}
-
-function writeHash
-{
- local fileToHash="$1"
- local fileToWriteTo="$2"
- $sha1 -out "$fileToWriteTo" "$fileToHash"
-}
-
-function checkAwsKey
-{
- local originalKeyFile="$1"
- local keySize="$(ls -l "$originalKeyFile" | awk '{ print $5 }')"
- if [ ! $keySize -eq 40 ]; then
- 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
- fi
-}
-
-function padDecodedKeyTo
-{
- local originalKeyFile="$1"
- local keyFile="$2"
- cp "$originalKeyFile" "$keyFile"
-
- local keySize=$(ls -l "$keyFile" | awk '{ print $5 }')
- if [ $keySize -lt 64 ]; then
- local zerosToWrite=$((64 - $keySize))
- dd if=/dev/zero of=$keyFile bs=1 count=$zerosToWrite seek=$keySize 2> /dev/null
- elif [ $keySize -gt 64 ]; then
- echo "Warning: Support for hashing keys bigger than the SHA1 block size of 64 bytes is untested" 1>&2
- writeHash "$originalKeyFile" "$keyFile"
- local keySize=$(ls -l "$keyFile" | awk '{ print $5 }')
- if [ $keySize -lt 64 ]; then
- local zerosToWrite=$((64 - $keySize))
- dd if=/dev/zero of=$keyFile bs=1 count=$zerosToWrite seek=$keySize 2> /dev/null
- fi
- exit 1
- else
- :
- fi
-}
-
-function writeLongAsByte
-{
- local byte="$1"
- local file="$2"
- printf "\\$(printf "%o" $byte)" >> "$file"
-}
-
-function readBytesAndXorAndWriteAsBytesTo
-{
- local inputFile="$1"
- local xorByte=$2
- local outputFile="$3"
-
- od -v -A n -t uC "$inputFile" | awk '{ OFS="\n"; for (i = 1; i <= NF; i++) print $i }' |
- while read byte; do
- ((xord = byte ^ xorByte))
- writeLongAsByte $xord "$outputFile"
- done
-}
-
-function writeHexByte
-{
- local byte="$1"
- local file="$2"
- printf "\\$(printf "%o" 0x$byte)" >> "$file"
-}
-
-function writeHexString
-{
- local hexString="$1"
- for byte in $(echo $hexString | sed 's/../& /g'); do
- writeHexByte "$byte" "$2"
- done
-}
-
-function writeStringToSign
-{
- local outputFile="$1"
- echo $verb >> "$outputFile"
- echo "$contentMD5" >> "$outputFile"
- echo "$contentType" >> "$outputFile"
- echo "$currentDateTime" >> "$outputFile"
-
- writeStringToSignAmazonHeaders "$outputFile"
-
- urlPath="$(echo "$url" | awk 'BEGIN { FS="[?]"} { print $1 }')"
- urlQueryString="$(echo "$url" | awk 'BEGIN { FS="[?]"} { print $2 }')"
- printf "$urlPath" >> "$outputFile"
- if [ "$urlQueryString" = "acl" ] || [ "$urlQueryString" = "torrent" ]; then
- printf "?" >> "$outputFile"
- printf "$urlQueryString" >> "$outputFile"
- fi
-}
-
-function writeStringToSignAmazonHeaders()
-{
- local outputFile="$1"
-
- #Convert all headers to lower case
- #sort
- #Strip ": " to ":"
- #Add LF to each header
- awk 'BEGIN { FS=": " } NF == 2 { print tolower($1) ":" $2 }' "$amazonHeaderFile" | sort >> "$outputFile"
- #TODO: RFC 2616, section 4.2 (combine repeated headers' values)
- #TODO: Unfold long lines (not supported elsewhere)
-}
-
-function computeAwsAuthorizationHeader
-{
- checkAwsKey "$awsAccessSecretKeyIdFile"
-
- createTemporaryFile "key"
- local tempKeyFile="$(mostRecentTemporaryFile)"
-
- createTemporaryFile "ipad"
- local ipadHashingFile="$(mostRecentTemporaryFile)"
-
- createTemporaryFile "opad"
- local opadHashingFile="$(mostRecentTemporaryFile)"
-
- createTemporaryFile "HMAC-SHA1"
- local hmacSha1File="$(mostRecentTemporaryFile)"
-
- padDecodedKeyTo "$awsAccessSecretKeyIdFile" "$tempKeyFile"
- readBytesAndXorAndWriteAsBytesTo "$tempKeyFile" ipadXorByte "$ipadHashingFile"
-
- writeStringToSign "$ipadHashingFile"
-
- readBytesAndXorAndWriteAsBytesTo "$tempKeyFile" opadXorByte "$opadHashingFile"
- appendHash "$ipadHashingFile" "$opadHashingFile"
- writeHash "$opadHashingFile" "$hmacSha1File"
-
- local signature="$($base64encode "$hmacSha1File")"
-
- echo "Authorization: AWS $awsAccessKeyId:$signature"
-}
-
-function writeAmazonHeadersForCurl
-{
- if [ ! -e "$amazonHeaderFile" ]; then
- printErrorHelpAndExit "Amazon Header file does not exist" $userSpecifiedDataErrorExitCode
- elif grep -q ^X-Amz-Date: "$amazonHeaderFile"; then
- printErrorHelpAndExit "X-Amz-Date header not allowed" $userSpecifiedDataErrorExitCode
- fi
- # Consider using sed...
- awk 'BEGIN { ORS=" "; FS="\0" } { print "--header \"" $1 "\""}' "$amazonHeaderFile" >> "$1"
-}
-
-function runCurl
-{
- local verbAndAnyData="$1"
- local fullUrl="$protocol://s3.amazonaws.com$url"
- createTemporaryFile "curl"
- local tempCurlCommand="$(mostRecentTemporaryFile)"
- local cleanUpCommand="rm -f "$tempCurlCommand""
-
- echo "#! /usr/bin/env bash" >> "$tempCurlCommand"
- printf "curl %s %s --dump-header \"%s\" " "$verbose" "$verbAndAnyData" "$dumpHeaderFile" >> "$tempCurlCommand"
- writeAmazonHeadersForCurl "$tempCurlCommand"
- printf " --header \"%s\"" "Date: $currentDateTime" >> "$tempCurlCommand"
- printf " --header \"%s\"" "$authorizationHeader" >> "$tempCurlCommand"
- if [ ! -z "$contentType" ]; then
- printf " --header \"Content-Type: %s\"" "$contentType" >> "$tempCurlCommand"
- fi
- if [ ! -z "$contentMD5" ]; then
- printf " --header \"Content-MD5: %s\"" "$contentMD5" >> "$tempCurlCommand"
- fi
- printf " \"%s\"\n" "$fullUrl" >> "$tempCurlCommand"
-
- unsetErrorTraps
- exec env bash "$tempCurlCommand"
-}
-
-function initialise
-{
- setErrorTraps
- checkEnvironment
-}
-
-function main
-{
- initialise
- parseOptions "$@"
- readonly currentDateTime="$(LC_TIME=C date "+%a, %d %h %Y %T %z")"
- prepareToRunCurl
- readonly authorizationHeader="$(computeAwsAuthorizationHeader)"
- runCurl "$verbToPass"
-}
View
106 tools/s3-delete
@@ -1,106 +0,0 @@
-#! /usr/bin/env bash
-cat > /dev/null << EndOfLicence
-s3-bash
-Copyright 2007 Raphael James Cohn
-
-Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
-in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed under the License
-is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
-or implied. See the License for the specific language governing permissions and limitations under
-the License.
-EndOfLicence
-
-# Pragmas
-set -u
-set -e
-
-function printHelpAndExit
-{
- exitCode=$1
- printf "%s: version %s\n" "$weAreKnownAs" "$version"
- printf "Part of s3-bash. Latest version is at %s\n" 'http://code.google.com/p/s3-bash/'
- printf "Usage %s: -h\n" "$weAreKnownAs"
- printf "Usage %s: [-vS] [-H file] [-a file] -k key -s file url\n" "$weAreKnownAs"
- printf " Option\tType\tRequirement\tDescription\n"
- printf " -h\t\tprecedent\tprint this help\n"
- printf " -v\t\toptional\tverbose output\n"
- printf " -k\tstring\tmandatory\tAWS Access Key Id\n"
- printf " -s\tfile\tmandatory\tAWS Secret Access Key Id File\n"
- printf " -S\t\toptional\tUse https\n"
- printf " -H\tfile\toptional\tFile to write response headers to\n"
- printf " -a\tfile\toptional\tFile to read Amazon custom headers from (X-Amz-Date is not allowed)\n"
- printf " \turl\tmandatory\trelative url including bucket name and leading slash, eg /bucket/path/to/object?acl. Assumed to be already encoded\n"
- printf "\n"
- printf "Notes\n"
- printf "Specify proxies using a ~/.curlrc file\n"
- exit $exitCode
-}
-
-function parseOptions
-{
- verbose=""
- url=""
- awsAccessKeyId=""
- awsAccessSecretKeyIdFile=""
- protocol="http"
- dumpHeaderFile="/dev/null"
- amazonHeaderFile="/dev/null"
- while getopts "hvk:s:SH:T:a:" optionName; do
- case "$optionName" in
- h) printHelpAndExit 0;;
- v) verbose="-v";;
- k) awsAccessKeyId="$OPTARG";;
- s) awsAccessSecretKeyIdFile="$OPTARG"
- if [ ! -e "$awsAccessSecretKeyIdFile" ]; then
- printErrorHelpAndExit "AWS Secret Key Id file does not exist" $userSpecifiedDataErrorExitCode
- fi;;
- S) protocol="https";;
- H) dumpHeaderFile="$OPTARG";;
- a) amazonHeaderFile="$OPTARG";;
- [?]) printErrorHelpAndExit "Option not recognised" $userSpecifiedDataErrorExitCode;;
- esac
- done
- if [ 1 -eq $OPTIND ]; then
- printErrorHelpAndExit "Internal Error: parseOptions or a parent method in the call stack was not called with $"@"." $internalErrorExitCode
- fi
- let "toShift = $OPTIND - 1"
- shift $toShift
- if [ $# -eq 0 ]; then
- printErrorHelpAndExit "URL not specified" $userSpecifiedDataErrorExitCode
- fi
- url="$1"
- verifyUrl
-
- if [ -z "$awsAccessSecretKeyIdFile" ]; then
- printErrorHelpAndExit "AWS Secret Access Key file not specified" $userSpecifiedDataErrorExitCode
- elif [ -z "$awsAccessKeyId" ]; then
- printErrorHelpAndExit "AWS Access Key Id not specified" $userSpecifiedDataErrorExitCode
- fi
-}
-
-function prepareToRunCurl
-{
- readonly verb="DELETE"
- readonly verbToPass="-X DELETE"
- readonly contentMD5=""
- readonly contentType=""
-}
-
-readonly weAreKnownAs="$(basename $0)"
-readonly ourPath="$(dirname $0)"
-
-readonly commonFunctions="$ourPath/s3-common-functions"
-if [ -e "$commonFunctions" ]; then
- source "$commonFunctions"
-else
- version="Unknown"
- invalidEnvironmentExitCode=4
- printHelpAndExit "$weAreKnownAs: Could not locate file s3-common-functions" $invalidEnvironmentExitCode
-fi
-
-main "$@"
View
108 tools/s3-get
@@ -1,108 +0,0 @@
-#! /usr/bin/env bash
-cat > /dev/null << EndOfLicence
-s3-bash
-Copyright 2007 Raphael James Cohn
-
-Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
-in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed under the License
-is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
-or implied. See the License for the specific language governing permissions and limitations under
-the License.
-EndOfLicence
-
-# Pragmas
-set -u
-set -e
-
-function printHelpAndExit
-{
- exitCode=$1
- printf "%s: version %s\n" "$weAreKnownAs" "$version"
- printf "Part of s3-bash. Latest version is at %s\n" 'http://code.google.com/p/s3-bash/'
- printf "Usage %s: -h\n" "$weAreKnownAs"
- printf "Usage %s: [-vS] [-H file] [-a file] -k key -s file url\n" "$weAreKnownAs"
- printf " Option\tType\tRequirement\tDescription\n"
- printf " -h\t\tprecedent\tprint this help\n"
- printf " -v\t\toptional\tverbose output\n"
- printf " -k\tstring\tmandatory\tAWS Access Key Id\n"
- printf " -s\tfile\tmandatory\tAWS Secret Access Key Id File\n"
- printf " -S\t\toptional\tUse https\n"
- printf " -H\tfile\toptional\tFile to write response headers to\n"
- printf " -a\tfile\toptional\tFile to read Amazon custom headers from (X-Amz-Date is not allowed)\n"
- printf " \turl\tmandatory\trelative url including bucket name and leading slash, eg /bucket/path/to/object?acl. Assumed to be already encoded\n"
- printf "\n"
- printf "Notes\n"
- printf "Specify proxies using a ~/.curlrc file\n"
- printf "Content is returned on stdout\n"
- exit $exitCode
-}
-
-function parseOptions
-{
- verbose=""
- url=""
- awsAccessKeyId=""
- awsAccessSecretKeyIdFile=""
- protocol="http"
- dumpHeaderFile="/dev/null"
- amazonHeaderFile="/dev/null"
- while getopts "hvk:s:SH:a:" optionName; do
- case "$optionName" in
- h) printHelpAndExit 0;;
- v) verbose="-v";;
- k) awsAccessKeyId="$OPTARG";;
- s) awsAccessSecretKeyIdFile="$OPTARG"
- if [ ! -e "$awsAccessSecretKeyIdFile" ]; then
- printErrorHelpAndExit "AWS Secret Key Id file does not exist" $userSpecifiedDataErrorExitCode
- fi;;
- S) protocol="https";;
- H) dumpHeaderFile="$OPTARG";;
- a) amazonHeaderFile="$OPTARG"
- ;;
- [?]) printErrorHelpAndExit "Option not recognised" $userSpecifiedDataErrorExitCode;;
- esac
- done
- if [ 1 -eq $OPTIND ]; then
- printErrorHelpAndExit "Internal Error: parseOptions or a parent method in the call stack was not called with $"@"." $internalErrorExitCode
- fi
- let "toShift = $OPTIND - 1"
- shift $toShift
- if [ $# -eq 0 ]; then
- printErrorHelpAndExit "URL not specified" $userSpecifiedDataErrorExitCode
- fi
- url="$1"
- verifyUrl
-
- if [ -z "$awsAccessSecretKeyIdFile" ]; then
- printErrorHelpAndExit "AWS Secret Access Key file not specified" $userSpecifiedDataErrorExitCode
- elif [ -z "$awsAccessKeyId" ]; then
- printErrorHelpAndExit "AWS Access Key Id not specified" $userSpecifiedDataErrorExitCode
- fi
-}
-
-function prepareToRunCurl
-{
- readonly verb="GET"
- readonly verbToPass="--get"
- readonly contentMD5=""
- readonly contentType=""
-}
-
-readonly weAreKnownAs="$(basename $0)"
-readonly ourPath="$(dirname $0)"
-
-readonly commonFunctions="$ourPath/s3-common-functions"
-if [ -e "$commonFunctions" ]; then
- source "$commonFunctions"
-else
- version="Unknown"
- invalidEnvironmentExitCode=4
- printErrorHelpAndExit "$weAreKnownAs: Could not locate file s3-common-functions" $invalidEnvironmentExitCode
-fi
-
-main "$@"
View
119 tools/s3-put
@@ -1,119 +0,0 @@
-#! /usr/bin/env bash
-cat > /dev/null << EndOfLicence
-s3-bash
-Copyright 2007 Raphael James Cohn
-
-Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
-in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed under the License
-is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
-or implied. See the License for the specific language governing permissions and limitations under
-the License.
-EndOfLicence
-
-# Pragmas
-set -u
-set -e
-
-function printHelpAndExit
-{
- exitCode=$1
- printf "%s: version %s\n" "$weAreKnownAs" "$version"
- printf "Part of s3-bash. Latest version is at %s\n" 'http://code.google.com/p/s3-bash/'
- printf "Usage %s: -h\n" "$weAreKnownAs"
- printf "Usage %s: [-vS] [-H file] [-a file] -k key -s file -T file url\n" "$weAreKnownAs"
- printf " Option\tType\tRequirement\tDescription\n"
- printf " -h\t\tprecedent\tprint this help\n"
- printf " -v\t\toptional\tverbose output\n"
- printf " -k\tstring\tmandatory\tAWS Access Key Id\n"
- printf " -s\tfile\tmandatory\tAWS Secret Access Key Id File\n"
- printf " -T\tfile\tmandatory\tFile (or stdin with -) to PUT\n"
- printf " -S\t\toptional\tUse https\n"
- printf " -H\tfile\toptional\tFile to write response headers to\n"
- printf " -a\tfile\toptional\tFile to read Amazon custom headers from (X-Amz-Date is not allowed)\n"
- printf " -c\tMIME\toptional\tMIME Content type. Default is text/plain\n"
- printf " \turl\tmandatory\trelative url including bucket name and leading slash, eg /bucket/path/to/object?acl. Assumed to be already encoded\n"
- printf "\n"
- printf "Notes\n"
- printf "Specify proxies using a ~/.curlrc file\n"
- printf "Specify content to PUT using stdin using option -T -\n"
- exit $exitCode
-}
-
-function parseOptions
-{
- verbose=""
- url=""
- awsAccessKeyId=""
- awsAccessSecretKeyIdFile=""
- protocol="http"
- fileToUpload=""
- dumpHeaderFile="/dev/null"
- amazonHeaderFile="/dev/null"
- contentType="text/plain"
- while getopts "hvk:s:SH:T:a:c:" optionName; do
- case "$optionName" in
- h) printHelpAndExit 0;;
- v) verbose="-v";;
- k) awsAccessKeyId="$OPTARG";;
- s) awsAccessSecretKeyIdFile="$OPTARG"
- if [ ! -e "$awsAccessSecretKeyIdFile" ]; then
- printErrorHelpAndExit "AWS Secret Key Id file does not exist" $userSpecifiedDataErrorExitCode
- fi;;
- S) protocol="https";;
- H) dumpHeaderFile="$OPTARG";;
- T) fileToUpload="$OPTARG";;
- a) amazonHeaderFile="$OPTARG";;
- c) contentType="$OPTARG";;
- [?]) printErrorHelpAndExit "Option not recognised" $userSpecifiedDataErrorExitCode;;
- esac
- done
- if [ 1 -eq $OPTIND ]; then
- printErrorHelpAndExit "Internal Error: parseOptions or a parent method in the call stack was not called with $"@"." $internalErrorExitCode
- fi
- let "toShift = $OPTIND - 1"
- shift $toShift
- if [ $# -eq 0 ]; then
- printErrorHelpAndExit "URL not specified" $userSpecifiedDataErrorExitCode
- fi
- url="$1"
- verifyUrl
-
- if [ -z "$awsAccessSecretKeyIdFile" ]; then
- printErrorHelpAndExit "AWS Secret Access Key file not specified" $userSpecifiedDataErrorExitCode
- elif [ -z "$awsAccessKeyId" ]; then
- printErrorHelpAndExit "AWS Access Key Id not specified" $userSpecifiedDataErrorExitCode
- elif [ -z "$fileToUpload" ]; then
- printErrorHelpAndExit "File to upload not specified" $userSpecifiedDataErrorExitCode
- fi
-}
-
-function prepareToRunCurl
-{
- readonly verb="PUT"
- if [ ! "-" = "$fileToUpload" ]; then
- readonly contentMD5="$(base64EncodedMD5 "$fileToUpload")"
- readonly verbToPass="-T \"$fileToUpload\""
- else
- readonly contentMD5=""
- readonly verbToPass="-T -"
- fi
-}
-
-readonly weAreKnownAs="$(basename $0)"
-readonly ourPath="$(dirname $0)"
-
-readonly commonFunctions="$ourPath/s3-common-functions"
-if [ -e "$commonFunctions" ]; then
- source "$commonFunctions"
-else
- version="Unknown"
- invalidEnvironmentExitCode=4
- printErrorHelpAndExit "$weAreKnownAs: Could not locate file s3-common-functions" $invalidEnvironmentExitCode
-fi
-
-main "$@"
View
7 tools/wol
@@ -7,5 +7,8 @@ s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
# wake up a windows box in chengxuan office
# to wake other computer, just replace the mac address
-mac_addr = '\x00\x1a\xa0\xbe\xd1\x56'
-s.sendto('\xff'*6 + mac_addr*16, ("255.255.255.255",9))
+#mac_addr = '\xf4\x6d\x04\x56\x73\xbe'
+mac_addr = '\x00\x11\x32\x16\x7b\x2c'
+s.sendto('\xff'*6 + mac_addr*16, ("255.255.255.255", 7))
+s.close()
+

0 comments on commit 8c30015

Please sign in to comment.