From 6fae25b305d714b3ab7608fa003f1af9bf024545 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 14 Feb 2023 13:33:23 +0800 Subject: Rename tools into bin --- Makefile | 4 +- README.md | 4 +- X11/openbox/rc.xml | 2 +- alias | 2 +- bin/cron/task.cron | 2 + bin/csv/csv.2geojson | 46 ++++++++ bin/csv/csv.move_column | 18 +++ bin/csv/csv.reorder | 17 +++ bin/desktop/password-store.sh | 51 ++++++++ bin/desktop/takeshot | 78 +++++++++++++ bin/docker/dktags | 29 +++++ bin/gis/match-road.sh | 148 +++++++++++++++++++++++ bin/git/check-repos.sh | 48 ++++++++ bin/git/swap-protocol.bash | 25 ++++ bin/github/github-release.sh | 154 ++++++++++++++++++++++++ bin/gpx/footer | 1 + bin/gpx/gpx.check.py | 85 ++++++++++++++ bin/gpx/gpx.merge_gpx.sh | 5 + bin/gpx/gpx.merge_trk.sh | 4 + bin/gpx/gpx2geojson.sh | 48 ++++++++ bin/gpx/header | 10 ++ bin/init/check_upstream | 24 ++++ bin/init/exit.sh | 5 + bin/init/load-settings.sh | 70 +++++++++++ bin/init/sync.sh | 37 ++++++ bin/install.sh | 30 +++++ bin/markdown/reveal | 45 +++++++ bin/misc/brightness.sh | 10 ++ bin/misc/diff-highlight | 213 ++++++++++++++++++++++++++++++++++ bin/misc/flash.sh | 39 +++++++ bin/misc/mvt_decode.py | 11 ++ bin/misc/ocr | 16 +++ bin/misc/refresh-todo.sh | 5 + bin/misc/simple_cors_server.py | 18 +++ bin/misc/sync-gist.sh | 21 ++++ bin/misc/transfer | 22 ++++ bin/osm/josm_install.sh | 8 ++ bin/osm/note | 1 + bin/osm/osm | 18 +++ bin/osm/osm.api.changeset.add | 10 ++ bin/osm/osm.api.changeset.close | 3 + bin/osm/osm.api.changeset.commit | 80 +++++++++++++ bin/osm/osm.api.changeset.create | 25 ++++ bin/osm/osm.api.changeset.update | 9 ++ bin/osm/osm.api.changeset.upload | 6 + bin/osm/osm.api.fetch | 6 + bin/osm/osm.api.fetch.full | 5 + bin/osm/osm.api.fetch.history | 6 + bin/osm/osm.api.member.relation | 4 + bin/osm/osm.api.referenced.relation | 6 + bin/osm/osm.api.referenced.way | 5 + bin/osm/osm.api.upload.to | 12 ++ bin/osm/osm.file.get | 4 + bin/osm/osm.file.get.full | 4 + bin/osm/osm.file.query | 4 + bin/osm/osm.goto | 3 + bin/osm/osm.help | 33 ++++++ bin/osm/osm.list.ids | 3 + bin/osm/osm.list.tag | 10 ++ bin/osm/osm.list.tags | 15 +++ bin/osm/osm.member.relation | 8 ++ bin/osm/osm.osc.by_member | 31 +++++ bin/osm/osm.osc.by_tag | 45 +++++++ bin/osm/osm.osm.remove | 9 ++ bin/osm/osm.pbf.update | 41 +++++++ bin/osm/osm.query | 3 + bin/osm/sequence_number.sh | 22 ++++ bin/sns/mastodon.sh | 17 +++ bin/task/tkk | 7 ++ bin/unix/fdswap | 41 +++++++ bin/wiki/diary | 49 ++++++++ bin/wiki/log.sh | 31 +++++ bin/wiki/notify | 7 ++ tools/cron/task.cron | 2 - tools/csv/csv.2geojson | 46 -------- tools/csv/csv.move_column | 18 --- tools/csv/csv.reorder | 17 --- tools/desktop/password-store.sh | 51 -------- tools/desktop/takeshot | 78 ------------- tools/docker/dktags | 29 ----- tools/gis/match-road.sh | 148 ----------------------- tools/git/check-repos.sh | 48 -------- tools/git/swap-protocol.bash | 25 ---- tools/github/github-release.sh | 154 ------------------------ tools/gpx/footer | 1 - tools/gpx/gpx.check.py | 85 -------------- tools/gpx/gpx.merge_gpx.sh | 5 - tools/gpx/gpx.merge_trk.sh | 4 - tools/gpx/gpx2geojson.sh | 48 -------- tools/gpx/header | 10 -- tools/init/check_upstream | 24 ---- tools/init/exit.sh | 5 - tools/init/load-settings.sh | 70 ----------- tools/init/sync.sh | 37 ------ tools/install.sh | 30 ----- tools/markdown/reveal | 45 ------- tools/misc/brightness.sh | 10 -- tools/misc/diff-highlight | 213 ---------------------------------- tools/misc/flash.sh | 39 ------- tools/misc/mvt_decode.py | 11 -- tools/misc/ocr | 16 --- tools/misc/refresh-todo.sh | 5 - tools/misc/simple_cors_server.py | 18 --- tools/misc/sync-gist.sh | 21 ---- tools/misc/transfer | 22 ---- tools/osm/josm_install.sh | 8 -- tools/osm/note | 1 - tools/osm/osm | 18 --- tools/osm/osm.api.changeset.add | 10 -- tools/osm/osm.api.changeset.close | 3 - tools/osm/osm.api.changeset.commit | 80 ------------- tools/osm/osm.api.changeset.create | 25 ---- tools/osm/osm.api.changeset.update | 9 -- tools/osm/osm.api.changeset.upload | 6 - tools/osm/osm.api.fetch | 6 - tools/osm/osm.api.fetch.full | 5 - tools/osm/osm.api.fetch.history | 6 - tools/osm/osm.api.member.relation | 4 - tools/osm/osm.api.referenced.relation | 6 - tools/osm/osm.api.referenced.way | 5 - tools/osm/osm.api.upload.to | 12 -- tools/osm/osm.file.get | 4 - tools/osm/osm.file.get.full | 4 - tools/osm/osm.file.query | 4 - tools/osm/osm.goto | 3 - tools/osm/osm.help | 33 ------ tools/osm/osm.list.ids | 3 - tools/osm/osm.list.tag | 10 -- tools/osm/osm.list.tags | 15 --- tools/osm/osm.member.relation | 8 -- tools/osm/osm.osc.by_member | 31 ----- tools/osm/osm.osc.by_tag | 45 ------- tools/osm/osm.osm.remove | 9 -- tools/osm/osm.pbf.update | 41 ------- tools/osm/osm.query | 3 - tools/osm/sequence_number.sh | 22 ---- tools/sns/mastodon.sh | 17 --- tools/task/tkk | 7 -- tools/unix/fdswap | 41 ------- tools/wiki/diary | 49 -------- tools/wiki/log.sh | 31 ----- tools/wiki/notify | 7 -- vimrc.bak | 2 +- zsh/zshrc | 4 +- 144 files changed, 1935 insertions(+), 1935 deletions(-) create mode 100644 bin/cron/task.cron create mode 100755 bin/csv/csv.2geojson create mode 100755 bin/csv/csv.move_column create mode 100755 bin/csv/csv.reorder create mode 100755 bin/desktop/password-store.sh create mode 100755 bin/desktop/takeshot create mode 100755 bin/docker/dktags create mode 100755 bin/gis/match-road.sh create mode 100755 bin/git/check-repos.sh create mode 100755 bin/git/swap-protocol.bash create mode 100755 bin/github/github-release.sh create mode 100644 bin/gpx/footer create mode 100755 bin/gpx/gpx.check.py create mode 100755 bin/gpx/gpx.merge_gpx.sh create mode 100755 bin/gpx/gpx.merge_trk.sh create mode 100755 bin/gpx/gpx2geojson.sh create mode 100644 bin/gpx/header create mode 100755 bin/init/check_upstream create mode 100755 bin/init/exit.sh create mode 100755 bin/init/load-settings.sh create mode 100755 bin/init/sync.sh create mode 100755 bin/install.sh create mode 100755 bin/markdown/reveal create mode 100755 bin/misc/brightness.sh create mode 100755 bin/misc/diff-highlight create mode 100755 bin/misc/flash.sh create mode 100755 bin/misc/mvt_decode.py create mode 100755 bin/misc/ocr create mode 100755 bin/misc/refresh-todo.sh create mode 100755 bin/misc/simple_cors_server.py create mode 100755 bin/misc/sync-gist.sh create mode 100755 bin/misc/transfer create mode 100755 bin/osm/josm_install.sh create mode 100644 bin/osm/note create mode 100644 bin/osm/osm create mode 100755 bin/osm/osm.api.changeset.add create mode 100755 bin/osm/osm.api.changeset.close create mode 100755 bin/osm/osm.api.changeset.commit create mode 100755 bin/osm/osm.api.changeset.create create mode 100755 bin/osm/osm.api.changeset.update create mode 100755 bin/osm/osm.api.changeset.upload create mode 100755 bin/osm/osm.api.fetch create mode 100755 bin/osm/osm.api.fetch.full create mode 100755 bin/osm/osm.api.fetch.history create mode 100755 bin/osm/osm.api.member.relation create mode 100755 bin/osm/osm.api.referenced.relation create mode 100755 bin/osm/osm.api.referenced.way create mode 100755 bin/osm/osm.api.upload.to create mode 100755 bin/osm/osm.file.get create mode 100755 bin/osm/osm.file.get.full create mode 100755 bin/osm/osm.file.query create mode 100755 bin/osm/osm.goto create mode 100755 bin/osm/osm.help create mode 100755 bin/osm/osm.list.ids create mode 100755 bin/osm/osm.list.tag create mode 100755 bin/osm/osm.list.tags create mode 100755 bin/osm/osm.member.relation create mode 100755 bin/osm/osm.osc.by_member create mode 100755 bin/osm/osm.osc.by_tag create mode 100755 bin/osm/osm.osm.remove create mode 100755 bin/osm/osm.pbf.update create mode 100755 bin/osm/osm.query create mode 100755 bin/osm/sequence_number.sh create mode 100755 bin/sns/mastodon.sh create mode 100755 bin/task/tkk create mode 100755 bin/unix/fdswap create mode 100755 bin/wiki/diary create mode 100755 bin/wiki/log.sh create mode 100755 bin/wiki/notify delete mode 100644 tools/cron/task.cron delete mode 100755 tools/csv/csv.2geojson delete mode 100755 tools/csv/csv.move_column delete mode 100755 tools/csv/csv.reorder delete mode 100755 tools/desktop/password-store.sh delete mode 100755 tools/desktop/takeshot delete mode 100755 tools/docker/dktags delete mode 100755 tools/gis/match-road.sh delete mode 100755 tools/git/check-repos.sh delete mode 100755 tools/git/swap-protocol.bash delete mode 100755 tools/github/github-release.sh delete mode 100644 tools/gpx/footer delete mode 100755 tools/gpx/gpx.check.py delete mode 100755 tools/gpx/gpx.merge_gpx.sh delete mode 100755 tools/gpx/gpx.merge_trk.sh delete mode 100755 tools/gpx/gpx2geojson.sh delete mode 100644 tools/gpx/header delete mode 100755 tools/init/check_upstream delete mode 100755 tools/init/exit.sh delete mode 100755 tools/init/load-settings.sh delete mode 100755 tools/init/sync.sh delete mode 100755 tools/install.sh delete mode 100755 tools/markdown/reveal delete mode 100755 tools/misc/brightness.sh delete mode 100755 tools/misc/diff-highlight delete mode 100755 tools/misc/flash.sh delete mode 100755 tools/misc/mvt_decode.py delete mode 100755 tools/misc/ocr delete mode 100755 tools/misc/refresh-todo.sh delete mode 100755 tools/misc/simple_cors_server.py delete mode 100755 tools/misc/sync-gist.sh delete mode 100755 tools/misc/transfer delete mode 100755 tools/osm/josm_install.sh delete mode 100644 tools/osm/note delete mode 100644 tools/osm/osm delete mode 100755 tools/osm/osm.api.changeset.add delete mode 100755 tools/osm/osm.api.changeset.close delete mode 100755 tools/osm/osm.api.changeset.commit delete mode 100755 tools/osm/osm.api.changeset.create delete mode 100755 tools/osm/osm.api.changeset.update delete mode 100755 tools/osm/osm.api.changeset.upload delete mode 100755 tools/osm/osm.api.fetch delete mode 100755 tools/osm/osm.api.fetch.full delete mode 100755 tools/osm/osm.api.fetch.history delete mode 100755 tools/osm/osm.api.member.relation delete mode 100755 tools/osm/osm.api.referenced.relation delete mode 100755 tools/osm/osm.api.referenced.way delete mode 100755 tools/osm/osm.api.upload.to delete mode 100755 tools/osm/osm.file.get delete mode 100755 tools/osm/osm.file.get.full delete mode 100755 tools/osm/osm.file.query delete mode 100755 tools/osm/osm.goto delete mode 100755 tools/osm/osm.help delete mode 100755 tools/osm/osm.list.ids delete mode 100755 tools/osm/osm.list.tag delete mode 100755 tools/osm/osm.list.tags delete mode 100755 tools/osm/osm.member.relation delete mode 100755 tools/osm/osm.osc.by_member delete mode 100755 tools/osm/osm.osc.by_tag delete mode 100755 tools/osm/osm.osm.remove delete mode 100755 tools/osm/osm.pbf.update delete mode 100755 tools/osm/osm.query delete mode 100755 tools/osm/sequence_number.sh delete mode 100755 tools/sns/mastodon.sh delete mode 100755 tools/task/tkk delete mode 100755 tools/unix/fdswap delete mode 100755 tools/wiki/diary delete mode 100755 tools/wiki/log.sh delete mode 100755 tools/wiki/notify diff --git a/Makefile b/Makefile index 6291f22..25e8f27 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ tmux: ln -sf `pwd`/misc/tmux.conf ~/.tmux.conf crontab: - (crontab -l 2>/dev/null; cat tools/cron/* | sed '/^#/ d') | crontab - + (crontab -l 2>/dev/null; cat bin/cron/* | sed '/^#/ d') | crontab - libinput: sudo ln -sf `pwd`/misc/libinput/* /etc/X11/xorg.conf.d/ @@ -87,7 +87,7 @@ rofi: ln -sf `pwd`/X11/rofi/config.rasi ~/.config/rofi/config.rasi archcraft: - ls -sf `pwd`/tools/desktop/takeshot /usr/local/bin/takeshot + ls -sf `pwd`/bin/desktop/takeshot /usr/local/bin/takeshot urlview: ln -sf `pwd`/misc/urlview ~/.urlview diff --git a/README.md b/README.md index 03e277f..8843333 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ ## Getting Started **via curl** ``` -curl -fsS https://raw.githubusercontent.com/typebrook/helper/dev/tools/install.sh | bash +curl -fsS https://raw.githubusercontent.com/typebrook/helper/dev/bin/install.sh | bash # Or shorter curl -fsSL https://git.io/JUnU7 | bash ``` **via wget** ``` -wget -O- https://raw.githubusercontent.com/typebrook/helper/dev/tools/install.sh | bash +wget -O- https://raw.githubusercontent.com/typebrook/helper/dev/bin/install.sh | bash ``` diff --git a/X11/openbox/rc.xml b/X11/openbox/rc.xml index 75406ff..c69e378 100644 --- a/X11/openbox/rc.xml +++ b/X11/openbox/rc.xml @@ -612,7 +612,7 @@ -o "window.padding.y=70" -o "window.dimensions.columns=64" -o "window.dimensions.lines=15" - -e ~/helper/tools/misc/flash.sh + -e ~/helper/bin/misc/flash.sh diff --git a/alias b/alias index 17338ea..2b3fa20 100644 --- a/alias +++ b/alias @@ -236,7 +236,7 @@ alias gls='git log -S' alias cdgg='cd $(git rev-parse --show-toplevel)' alias cdgw='cdgg && cd .github/workflows' alias cdgs='cd $(git submodule status | sed "s/^.//" | cut -d" " -f2)' # cd to first submodule -alias ch="/home/pham/helper/tools/git/check-repos.sh" +alias ch="/home/pham/helper/bin/git/check-repos.sh" # github export GITHUB_API='https://api.github.com' diff --git a/bin/cron/task.cron b/bin/cron/task.cron new file mode 100644 index 0000000..7521cca --- /dev/null +++ b/bin/cron/task.cron @@ -0,0 +1,2 @@ +# Push changes on ~/.task +*/20 * * * * cd ~/.task && git add * && git commit -am update && git push origin 2>&1 diff --git a/bin/csv/csv.2geojson b/bin/csv/csv.2geojson new file mode 100755 index 0000000..e742be6 --- /dev/null +++ b/bin/csv/csv.2geojson @@ -0,0 +1,46 @@ +#! /bin/bash + +# -s to skip specify columns of longitude and latitude +for i in "$@" +do +case $i in + -s) + lon_col=0; lat_col=1 + shift;; + + *) + csv=$i + shift;; +esac +done + +# if no -s option, just read from input +if [ "$lon_col" != "0" ]; then + # show each field with index in csv + echo -------------- > /dev/tty + head -1 < $csv | tr ',' '\n' | nl > /dev/tty + echo -------------- > /dev/tty + echo > /dev/tty + + # get index of lon/lat column + read -p "Number of longitude column: " lon_col + read -p "Number of latitude column: " lat_col +fi + +(which dos2unix &>/dev/null && dos2unix <$csv || cat $csv) |\ +# move lon and lat to the first and second column +awk -F',' -v lon_th=$lon_col -v lat_th=$lat_col '\ + BEGIN{OFS=","}\ + {printf $lon_th "," $lat_th; for (i=1; i<= NF; i++) if (i != lat_th && i != lon_th) printf "," $i; print ""}\ + ' |\ +# change csv into array format, like [lon, lat, "field1", field2...] +sed 's/[^,]*/"\0"/g; s/.*/[\0]/g' |\ +# wrap other fields as a json object, like [lon, lat, {...}] +jq -s '.[0][2:] as $fields | .[1:][] | [.[0], .[1], ([$fields, .[2:]] | transpose | map({(.[0]): .[1]}) | add)]' |\ +# create array of geojson point features +jq '{"type": "Feature", "properties": .[2], "geometry":{ "type": "Point", "coordinates": [(.[0] | tonumber), (.[1] | tonumber)] } }' |\ +# wrap features as geojson format +jq -s '{"type": "FeatureCollection", "features": .}' |\ +tee /tmp/geojson + +echo stored into /tmp/geojson > /dev/tty diff --git a/bin/csv/csv.move_column b/bin/csv/csv.move_column new file mode 100755 index 0000000..a62701f --- /dev/null +++ b/bin/csv/csv.move_column @@ -0,0 +1,18 @@ +#! /bin/bash + +# show each field with index in csv +echo -------------- > /dev/tty +head -1 < $1 | sed 's/,/ /g' | awk '{for (i=1; i<=NF; i++) printf $i "_" i " "; print ""}' > /dev/tty +echo -------------- > /dev/tty +echo > /dev/tty + +# get index of lon/lat column +read -p "Move which column? " origin_col +read -p "To which index? " new_col + +cat $1 | +# move lon and lat to the first and second column +awk -F',' -v OFS="," -v origin_th=$origin_col -v new_th=$new_col '\ + {for (i=1; i<= NF; i++) if (i == new_th) printf $origin_th OFS $i OFS; else if (i == origin_th); else printf $i OFS; print ""}\ + ' |\ +sed 's/,$//g' diff --git a/bin/csv/csv.reorder b/bin/csv/csv.reorder new file mode 100755 index 0000000..8a64239 --- /dev/null +++ b/bin/csv/csv.reorder @@ -0,0 +1,17 @@ +#! /bin/bash + +# show each field with index in csv +echo -------------- > /dev/tty +head -1 < $1 | awk -F',' '{for (i=1; i<=NF; i++) printf $i "_" i " "; print ""}' > /dev/tty +echo -------------- > /dev/tty +echo > /dev/tty + +read -p "type column numbers by new order, like 3 2 1: " order + +arrange=$(echo $order | sed -r 's/([^ ]+)/$\1/g' | tr ' ' ',') + +cat $1 |\ +awk -F',' "BEGIN{OFS=\",\"}{print $arrange}" |\ +tee /tmp/csv + +echo "Also copied to /tmp/csv" > /dev/tty diff --git a/bin/desktop/password-store.sh b/bin/desktop/password-store.sh new file mode 100755 index 0000000..1de3148 --- /dev/null +++ b/bin/desktop/password-store.sh @@ -0,0 +1,51 @@ +#! /bin/bash + +# Use rofi to quickly access password by command 'pass' +# xsel needed !! + +ROFI_ARGS=( "-font" "Hack 22" ) + +find ~/.password-store -name '*gpg' -printf %P\\n | \ +sed 's/.gpg$//' | \ +rofi -dmenu "${ROFI_ARGS[@]}" | { + # Get arguments for command 'pass' + read ARG1 ARG2 + + if [[ -z $ARG1 ]]; then + exit 1 + elif [[ $ARG1 == edit ]]; then + # Edit an existing password + alacritty --hold -e pass edit $ARG2 && \ + rofi -e Password Edited: $ARG2 + else + # If pass fails, then it means password doesn't exists + set pipefail + + pass $ARG1 | { + # If command fails, just fail directly + read PASSWORD; [[ -z $PASSWORD ]] && exit 1 + + # Simply copy password into system clipboard + echo $PASSWORD | xsel -ib + + # Show success message, and display extra contents + rofi "${ROFI_ARGS[@]}" \ + -e "Copied: $ARG1 $(echo; echo; cat | sed '1{/^$/d}')" + } || { + # Make sure user want to create a new password + return_code=$(alacritty -e sh -c ' + dialog --yesno "Password does not exist, Generate a new one?" 8 30; + echo "$?" + ') + [[ $return_code == 1 ]] && exit 1 + + # Generate a new password by ARG1 + alacritty -e pass generate $ARG1 --clip && \ + + # Show success message + rofi "${ROFI_ARGS[@]}" -e "Password Created and Copied: $ARG1" + } + + # TODO: if return code is 2, it means gpg password is not cached + fi +} diff --git a/bin/desktop/takeshot b/bin/desktop/takeshot new file mode 100755 index 0000000..09252f3 --- /dev/null +++ b/bin/desktop/takeshot @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +## Copyright (C) 2020-2022 Aditya Shakya +## Everyone is permitted to copy and distribute copies of this file under GNU-GPL3 + +## Script to take screenshots with maim + +time=`date +%Y-%m-%d-%H-%M-%S` +geometry=`xrandr | head -n1 | cut -d',' -f2 | tr -d '[:blank:],current'` +dir="`xdg-user-dir PICTURES`" +file="Screenshot_${time}_${geometry}.png" + +# notify and view screenshot +notify_view () { + dunstify -u low --replace=699 -i /usr/share/archcraft/icons/dunst/picture.png "Copied to clipboard." + viewnior ${dir}/"$file" + if [[ -e "$dir/$file" ]]; then + dunstify -u low --replace=699 -i /usr/share/archcraft/icons/dunst/picture.png "Screenshot Saved." + else + dunstify -u low --replace=699 -i /usr/share/archcraft/icons/dunst/picture.png "Screenshot Deleted." + fi +} + +# countdown +countdown () { + for sec in `seq $1 -1 1`; do + dunstify -t 1000 --replace=699 -i /usr/share/archcraft/icons/dunst/timer.png "Taking shot in : $sec" + sleep 1 + done +} + +# take shots +shotnow () { + cd ${dir} && maim -u -f png | tee "$file" | xclip -selection clipboard -t image/png + notify_view +} + +shot5 () { + countdown '5' + sleep 1 && cd ${dir} && maim -u -f png | tee "$file" | xclip -selection clipboard -t image/png + notify_view +} + +shot10 () { + countdown '10' + sleep 1 && cd ${dir} && maim -u -f png | tee "$file" | xclip -selection clipboard -t image/png + notify_view +} + +shotwin () { + cd ${dir} && maim -u -f png -i `xdotool getactivewindow` | tee "$file" | xclip -selection clipboard -t image/png + notify_view +} + +shotarea () { + cd ${dir} && maim -u -f png -s -b 2 -c 0.35,0.55,0.855 | tee "$file" | xclip -selection clipboard -t image/png + notify_view +} + +if [[ ! -d "$dir" ]]; then + mkdir -p "$dir" +fi + +if [[ "$1" == "--now" ]]; then + shotnow +elif [[ "$1" == "--in5" ]]; then + shot5 +elif [[ "$1" == "--in10" ]]; then + shot10 +elif [[ "$1" == "--win" ]]; then + shotwin +elif [[ "$1" == "--area" ]]; then + shotarea +else + echo -e "Available Options : --now --in5 --in10 --win --area" +fi + +exit 0 diff --git a/bin/docker/dktags b/bin/docker/dktags new file mode 100755 index 0000000..5a91434 --- /dev/null +++ b/bin/docker/dktags @@ -0,0 +1,29 @@ +#!/bin/bash + +# Orignally copied from https://stackoverflow.com/a/39454426/7051075 + +if [ $# -lt 1 ] +then +cat << HELP + +dktags -- list all tags for a Docker image on a remote registry. + +EXAMPLE: + - list all tags for ubuntu: + dktags ubuntu + + - list all php tags containing apache: + dktags php apache + +HELP +fi + +image="$1" +tags=`wget -q https://registry.hub.docker.com/v1/repositories/${image}/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}'` + +if [ -n "$2" ] +then + tags=` echo "${tags}" | grep "$2" ` +fi + +echo "${tags}" diff --git a/bin/gis/match-road.sh b/bin/gis/match-road.sh new file mode 100755 index 0000000..d9beaae --- /dev/null +++ b/bin/gis/match-road.sh @@ -0,0 +1,148 @@ +#!/usr/bin/env bash +# +# Author: Pham +# +# This script accepts a single GPX file as parameter and +# output the processed GPX body to STDOUT, using Mapbox Map Matching API v4. +# read doc at: https://docs.mapbox.com/api/legacy/map-matching-v4/ +# +# Example: +# +# match-road.sh raw.gpx > new.gpx +# +# Hint: +# +# Remember to put Mapbox Access Token at the top! + +#set -x +set -e + +# put yout Mapbox token here +ACCESS_TOKEN=$(cat ~/settings/tokens/mapbox) +# number of coordinates for each Mapbox Map Matching API request, Maximum value is 100 +LIMIT=100 +# define the lowest confidence of accepted matched points +THRESHOLD=0.0001 + +if [[ -z $1 ]]; then echo "You need to give a gpx file!"; exit 1; fi +ORIGIN_DATA=/tmp/$(basename $1).origin +RESPONSES=/tmp/$(basename $1).responses && true > $RESPONSES +MATCHED=/tmp/$(basename $1).matched + +# extract data from the given gpx file +# only keep first point and remove the rest which in the same "second" +# input: [gpx format] +# output: [121.0179739,14.5515336] 1984-01-01T08:00:46 +get_data() { + sed -nr '// {H; /<\/trkpt>/ {x; s/\n/ /g; p; s/.*//; x}}' $1 | + sed -nr 'h; s/.*lon="([^"]+).*/\1/; H; g + s/.*lat="([^"]+).*/\1/; H; g + # If trkpt has no time, leave it blank + /time/ { + s/.*