Skip to content

Instantly share code, notes, and snippets.

Shichao An shichao-an

Block or report user

Report or block shichao-an

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View asc-acer-shopt
autocd off
cdable_vars off
cdspell off
checkhash off
checkjobs off
checkwinsize on
cmdhist on
compat31 off
compat32 off
compat40 off
View asc-acer-seto
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 Aug 29, 2015
Extract mp3 from online videos
View youtube-dl-mp3.sh
#!/bin/bash
youtube-dl "$@" --extract-audio --audio-format mp3 --audio-quality 320k
@shichao-an
shichao-an / manga-download.sh
Created Apr 19, 2014
Download manga images
View manga-download.sh
#!/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 Aug 29, 2015
Convert long crappy filenames of MP3 tracks
View misc-files-convert1.sh
#!/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 Apr 25, 2014
Run Bash script on the fly without downloading
View wget_bash.sh
wget -qO - "$1" | bash
@shichao-an
shichao-an / get_int_bits.py
Created May 1, 2014
Get integer bits of current CPython implementation
View get_int_bits.py
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 Aug 29, 2015
Source code printout
View printout.sh
#!/bin/bash
# -r: landscape
# -2: two columns
# --highlight: syntax highlight
enscript -r -2 --highlight --line-numbers -o - $(ls *{.c,.h}) | ps2pdf - printout.pdf
View printout_github.sh
enscript --fancy-header --color=1 -1 --highlight --line-numbers -o - $(find . -mindepth 2 -type f -name *.py) | ps2pdf - printout.pdf
View geticon.sh
#!/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"
You can’t perform that action at this time.