Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
if [ ! -e "data.txt" ]; then
cat > data.txt <<EOF
**************************
*S* * *
* * * * ************* *
* * * ************ *
* * *
************** ***********
#
# zsh script to show how long a command took to run
# put in your .zshrc
#
BG_BLUE='\e[0;44m'
OCOLOR='\e[0m'
BOLD='\e[1;39m'
prompt_command_start=0
show_time_threash=5
@ryo1kato
ryo1kato / gist:831171
Created February 17, 2011 06:45
mkcdir
mkcdir(){
mkdir "$@"
if [ "$1" = "-p" ]; then
cd "$2"
else
cd "$1"
fi
}
@ryo1kato
ryo1kato / maked
Created September 16, 2011 10:31
monitor fs changes with inotify-tools and invoke make automatically
#!/bin/bash
interval=2
file_ignore='\.(swp|orig|old[0-9]*|bak[0-9]*)$|^core$|.*~$'
dir_ignore='(\.git|\.hg)'
make='make'
#####################################################
progname='maked'
i=0
while :;do echo $((i++)); sleep .3; done | bash -c 'while read L1; do echo L1=$L1; while read -t 0 L2; do echo L2=$L2; break; done; sleep .5; done'
# わかりやすくインデントすると
while :;
do
echo $((i++))
sleep .3
done | bash -c 'while read L1;
@ryo1kato
ryo1kato / gist:1241794
Created September 26, 2011 07:35
allow special chars to be used in proxy-auth for Cabal
$ diff -u ./Distribution/Client/HttpUtils.hs.orig ./Distribution/Client/HttpUtils.hs
--- ./Distribution/Client/HttpUtils.hs.orig 2011-09-26 15:59:04.368889933 +0900
+++ ./Distribution/Client/HttpUtils.hs 2011-09-26 16:31:17.142379016 +0900
@@ -12,6 +12,7 @@
import Network.HTTP
( Request (..), Response (..), RequestMethod (..)
, Header(..), HeaderName(..) )
+import qualified Network.HTTP.Base
import Network.URI
( URI (..), URIAuth (..), parseAbsoluteURI )
@ryo1kato
ryo1kato / .bash_profile
Created October 6, 2011 01:28
bash prompt with current working directory, shorten the if it's long.
# .bash_profile
pwd_prompt () {
maxlen=50
if (( ${#PWD} > maxlen ))
then
(( offset = ${#PWD} - maxlen ))
echo "...${PWD:offset}"
else
echo "${PWD}"
fi
@ryo1kato
ryo1kato / runme.sh
Created November 14, 2011 12:23
Linux/MacOSX version of "Easy rooting toolkit"
#!/bin/sh
#
# Linux/MacOSX Version of "Easy rooting toolkit (v2.0)" script.
# http://forum.xda-developers.com/showthread.php?t=1320350
# You need Linux/MacOSX version of 'adb' binary copied into 'files'
# directory
#
alias adb='./files/adb'
cat<<EOF
---------------------------------------------------------------
@ryo1kato
ryo1kato / gist:1407796
Created November 30, 2011 03:05
useful shell functions
mkcdir(){
mkdir -p "$@"
if [ "$1" = "-p" ]; then
cd "$2"
else
cd "$1"
fi
}
mvcd () {
err () { echo "mvcd: ERROR: $*" >&2 }
@ryo1kato
ryo1kato / gist:1949096
Created March 1, 2012 11:00
SSH key fingerprint
require 'base64'
require 'digest/md5'
ssh_pubkey='AAAAB3NzaC1yc2EAAAABIwAAAQEAxCw2nrIcdQ+7/tKy+6fk1qmICpl2qa8jxCLoG3pnGniDUUIOtRdEfnpHNHYWfwBVYIdGD5bmcFnXEfoxRjR2VpLXNeY/8PlCG5lARuQqkc720ZfoxsEQo3m+ixV4ylbuQfo8eDrELrn+MWiPluh699lWyvgZ/6oTW1nf2gsKabG+nV8uLvr7Znr230S8o8vhgo6O3cmfLGcfApUnG9kce1YOlz1D9F2x6vzDSO2W3s5/UTBmDvLj3Cza+yzmLp2fzAw97FL6LLwS2cLaVUayc6pZKqN+4Gu9LDPXFl4jkD2xzPTp7cuKdrJFaDsIa0OHzG+yVlDvWi8FkdU9O+xiuw=='
fingerprint = Digest::MD5.hexdigest(Base64.decode64(ssh_pubkey)).scan(/../).join(':')
puts fingerprint