Skip to content

Instantly share code, notes, and snippets.

autocd off
cdable_vars off
cdspell off
checkhash off
checkjobs off
checkwinsize on
cmdhist on
compat31 off
compat32 off
compat40 off
allexport off
braceexpand on
emacs on
errexit off
errtrace off
functrace off
hashall on
histexpand on
history on
ignoreeof off
@shichao-an
shichao-an / youtube-dl-mp3.sh
Last active August 29, 2015 14:00
Extract mp3 from online videos
#!/bin/bash
youtube-dl "$@" --extract-audio --audio-format mp3 --audio-quality 320k
@shichao-an
shichao-an / manga-download.sh
Created April 19, 2014 21:30
Download manga images
#!/bin/bash
# Brynhildr in the Darkness (Chinese ver.)
usage="./batch.sh chapter pages"
[ "$#" -lt 2 ] && { echo "$usage"; exit 1; }
declare -i chapter="$1"
declare -i pages="$2"
_page='$$'
printf -v _chapter "%.2d" "$chapter"
raw_url="http://imgfast.dmzj.com/j/%E6%9E%81%E9%BB%91%E7%9A%84%E5%B8%83%E4%BC%A6%E5%B8%8C%E5%B0%94%E7%89%B9/${_chapter}/%E7%AC%AC1%E8%AF%9D_00${_page}.jpg"
@shichao-an
shichao-an / misc-files-convert1.sh
Last active August 29, 2015 14:00
Convert long crappy filenames of MP3 tracks
#!/bin/bash
for f in *; do ff="$(echo "$f" | sed 's/\(^.*\)\((320K)MP3\)\(.*mp3\)/\3/g')"; mv "$f" "$ff"; done
files=(*.mp3)
while read line; do lines+=("$line"); done < tracks
for i in $(seq 1 1 ${#files[@]}); do mv "${files[$i]}" "${lines[$i]}.mp3"; done
@shichao-an
shichao-an / wget_bash.sh
Created April 25, 2014 22:08
Run Bash script on the fly without downloading
wget -qO - "$1" | bash
@shichao-an
shichao-an / get_int_bits.py
Created May 1, 2014 07:27
Get integer bits of current CPython implementation
import sys
def get_int_bits():
if hasattr(sys, 'maxsize'):
max_int = getattr(sys, 'maxsize')
else:
max_int = getattr(sys, 'maxint')
if max_int >> 62 == 0:
return 32
@shichao-an
shichao-an / printout.sh
Last active August 29, 2015 14:01
Source code printout
#!/bin/bash
# -r: landscape
# -2: two columns
# --highlight: syntax highlight
enscript -r -2 --highlight --line-numbers -o - $(ls *{.c,.h}) | ps2pdf - printout.pdf
@shichao-an
shichao-an / printout_github.sh
Created July 20, 2014 05:55
GitHub code printout
enscript --fancy-header --color=1 -1 --highlight --line-numbers -o - $(find . -mindepth 2 -type f -name *.py) | ps2pdf - printout.pdf
@shichao-an
shichao-an / geticon.sh
Created August 14, 2014 02:36
Get icon
#!/bin/bash
pattern="http://dcbdluf1ahqio.cloudfront.net/%s/%s.png"
service="$1"
width=${2:-42}
size="${width}x${width}"
url=$(printf "$pattern" "$service" "$size")
wget $url -O "${service}_icon.png"