Skip to content

Instantly share code, notes, and snippets.

@miy4
miy4 / manga_list.sh
Created May 5, 2013 20:59
まんが王倶楽部のコミックリストをダウンロードして、GoogleカレンダーのQuick Addで追加しやすい形式に変換
#!/bin/sh
show_usage() {
echo "Usage: $this_command [YEAR MONTH]" 1>&2
echo "Example: $this_command 2012 03 <- 2012 March" 1>&2
echo " $this_command <- Next month" 1>&2
}
# 引数解析
this_command=$(basename $0)
@miy4
miy4 / get_tsubomi_webcomic.sh
Created May 5, 2013 21:07
つぼみWEBコミックのダウンロードして、無圧縮ZIPにまとめる。 ImageMagickが必要。
#!/bin/sh
show_usage() {
echo "Usage: $this_command PREFIX NUM_OF_PAGES" 1>&2
}
this_command=$(basename $0)
prefix=$1
num_of_pages=$2
@miy4
miy4 / create-custom-css.bash
Last active December 19, 2023 05:48
Pandoc HTML Template (Github Style)
#!/usr/bin/env bash
usage() {
cat << HEREDOC 1>&2
Usage: create-custom-css.bash [OPTION]
-d, --debug enable debug mode
-h, --help display this help and exit
HEREDOC
exit 1
@miy4
miy4 / describe_number
Last active April 3, 2016 13:22
Conversion between binary, octal, decimal, and hexadecimal numbers
#!/usr/bin/env bash
as_binary() {
[[ $1 =~ ^([0#]?b)?([0-1]+)$ ]] || return
local bin=${BASH_REMATCH[2]}
local dec=$(bc -l <<< "ibase=2; $bin")
printf '[\033[34m#b%d\033[m #o%o %d #x%X]\n' $bin $dec $dec $dec
}
as_octal() {
@miy4
miy4 / tomato
Last active April 3, 2016 13:19
cheap pomodoro timer
#!/usr/bin/env bash
__die() { printf "%s\n" "$@" 1>&2; exit 1; }
__tomato_timer() {
local timer_minutes
local notification_bg
timer_minutes=$1; shift
notification_bg=$1; shift
@miy4
miy4 / date_cat
Last active April 1, 2016 01:29
display date and time in several forms
#!/usr/bin/env bash
source_user_defined() {
readonly catalogue=(
'date +%Y/%m/%d'
'date +"%Y/%m/%d %T"'
'date +"%Y/%-m/%-d(%a)"'
'LANG=C date +"%Y/%-m/%-d(%a)"'
'echo 平成$(($(date +%y) + 12))年'
'date --iso-8601'
@miy4
miy4 / longman
Last active April 10, 2016 12:51
retrieves word definitions from Longman English Dictionary Online
#!/usr/bin/env bash
die() {
local message="$1"
printf "%s\n" "$message" >&2
exit 1
}
check_deps() {
hash jq 2>/dev/null || die "command not found: jq"
@miy4
miy4 / termcolor16
Last active April 7, 2016 09:13
displays the ANSI escape codes for colored characters on terminal
#!/usr/bin/env bash
termcolor() {
local words="$*"
local esc="$(printf '\e')"
readonly intensity=( "" "1" )
readonly underline=( "" "4" )
readonly fg16=( "" "30" "31" "32" "33" "34" "35" "36" "37" )
local bg16=( "" "40" "41" "42" "44" "44" "45" "46" "47" )
local sgr
@miy4
miy4 / wordnet
Last active April 11, 2016 15:28
wrapper of wn (CLI to WordNet lexical database)
#!/usr/bin/env bash
wn_wrapper() {
local keyword="$1"
keyword=$(sed 's/ /_/g' <<< "$keyword")
local editor
if hash gsed 2>/dev/null; then
editor=gsed
else
@miy4
miy4 / unshorten
Created February 5, 2017 11:55
expands a short URL
#!/usr/bin/env bash
die() {
IFS=' ' printf "%s\n" "$*" 1>&2
exit 1
}
unshorten() {
curl --silent --output /dev/null --head --write-out "%{url_effective}\n" --location "$1"
}