Image hosting on GitHub - lmmx/devnotes GitHub Wiki
.bashrc
functions to automate image hosting at github.com/lmmx/shots
function take-shot (){
# Allow take-shot without versioning: create array if one doesn't exist
if [ -z ${shots+x} ]; then shots=(); fi
# would leave array lying around so needs wrapper to clean up: make-shots
shootyear="$(date | awk '{print $6}')";
shootmonth="$(date | awk '{print $2}')";
mkdir -p "/gits/shots/$shootyear/$shootmonth";
shotfile="$(echo "$@")";
cp "$shotfile" "/gits/shots/$shootyear/$shootmonth";
shotfilename=$(basename "$shotfile");
encodedshot="$(python -c 'from urllib import quote; print quote("'"$shotfilename"'").encode("utf-8")')"
shots+=("https://raw.githubusercontent.com/lmmx/shots/master/$shootyear/$shootmonth/$encodedshot");
}
function make-shots (){ for shot in "$@"; do take-shot $shot; done; shots=""; }
function take-shots (){ for shot in "$@"; do take-shot $shot; done; }
function shoot (){
shots=();
take-shots "$@";
cd /gits/shots/;
git add .;
git commit -m "Added $@";
git push origin master;
cd - > /dev/null;
printf '%s\n' "${shots[@]}";
}
take-shots
- Adds one or more images to git-versioned repository,
- Commits and pushes,
- Repeats the URLs to use (percent-encodes characters with Python
urllib.quote
), - Returns to the original directory
make-shots
make-shots
just copies the file(s) into the directory (make a commit when you're ready).
See also: gnews
, which parses the git status --porcelain
output to produce an automated summary message for a git commit. Useful here for adding multiple shots separately (make-shots
) then moving everything to origin master
in a single command
Further
shootlastpic
: combining:- xbel recency check (Py3: last-xbel-to-gimp⇢../xbel_parse/xbel-pic-parse.py)
- but modify subprocess called with an argument
- [requiring keyword i.e. flag to confirm]
- NB potentially destructive action
- use
shoot:
to save, with name provided [required]- Go has nice and simple flag library
- or rather libraries? options for options? arg!
- Go has nice and simple flag library
- [requiring keyword i.e. flag to confirm]
- but modify subprocess called with an argument
-
- shots versioning to quickly version a screenshot [optionally file rename via a single provided arg, enforced if format is Screenshot-0000-0000-etc-etc.png]
- xbel recency check (Py3: last-xbel-to-gimp⇢../xbel_parse/xbel-pic-parse.py)
Learning: machine vision
shoot
will version, but a call to a learning process could provide a sense and reasoning system about images- based on their use within thought libraries at permut.co, @nalogical, carets