summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2018-06-20 15:03:09 +1200
committerDavid Phillips <david@sighup.nz>2018-06-20 15:03:09 +1200
commitddd2824971147e2259be3abe71a93f60d252824d (patch)
treed29b374c0adc5dbb9a710d7ecca7197de8aef131
parent56f0f53647576216a5ef3632756c2715e862bdcd (diff)
downloaddotfiles-ddd2824971147e2259be3abe71a93f60d252824d.tar.xz
Remove grab-spot
-rwxr-xr-xlocal/bin/grab-spot32
1 files changed, 0 insertions, 32 deletions
diff --git a/local/bin/grab-spot b/local/bin/grab-spot
deleted file mode 100755
index a4974f4..0000000
--- a/local/bin/grab-spot
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-# Warning: uses a non-existant currency API
-
-# Grabs a spot price for a currency and stores it in ~/.cache
-# Useful to run as a cron job and use its cached output in motds or status
-# lines
-#
-# syntax: grab-spot TO FROM
-# for example, to get the value of USD in NZD:
-# grab-spot USD NZD
-# would place a file at ~/.cache/USDNZD containing the value of the USD in NZD,
-# to 4 decimal places, and a label for the conversion
-
-if [ -z $1 ]; then
- logger "$0: blank FROM currency"
- exit
-fi
-if [ -z $2 ]; then
- logger "$0: blank TO currency"
- exit
-fi
-
-# Only bother downloading if it's more than 1 hour old
-if ([ ! -f ~/.cache/currency/"$1$2" ] || [ $(find ~/.cache/currency/"$1$2" -mmin +60) ]) ; then
- rate=$(curl -L "https://finance.yahoo.com/d/quotes.csv?e=.csv&f=c4l1&s=$1$2=X" | cut -d ',' -f 2)
- if [ $? -ne 0 ] ; then
- logger "$0: curl error"
- exit
- fi
- printf "$1$2: %.4f" $rate > ~/.cache/currency/"$1$2"
-fi