aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Bynens <mathias@qiwi.be>2012-03-22 13:32:14 +0100
committerMathias Bynens <mathias@qiwi.be>2012-03-22 13:32:14 +0100
commit36666d6b7214ef4537ed336ac6513ea80c15aa70 (patch)
tree3afdb34237f103016b64a55d82b5ce22f896a1c6
parent1c94b9b3802a2af987ff3ef03c8f1730368cba7e (diff)
downloaddotfiles-36666d6b7214ef4537ed336ac6513ea80c15aa70.tar.gz
dotfiles-36666d6b7214ef4537ed336ac6513ea80c15aa70.tar.bz2
dotfiles-36666d6b7214ef4537ed336ac6513ea80c15aa70.zip
.functions: Add `dataurl` function
Based on @lri’s http://lri.me/profile.
-rw-r--r--.functions5
1 files changed, 5 insertions, 0 deletions
diff --git a/.functions b/.functions
index 97b0fca..4c7f6e7 100644
--- a/.functions
+++ b/.functions
@@ -3,6 +3,11 @@ function md() {
mkdir -p "$@" && cd "$@"
}
+# Create a data URL from an image (works for other file types too, if you tweak the Content-Type afterwards)
+dataurl() {
+ echo "data:image/${1##*.};base64,$(openssl base64 -in "$1")" | tr -d '\n'
+}
+
# Start an HTTP server from a directory, optionally specifying the port
function server() {
local port="${1:-8000}"