<commit_before>#!/bin/bash
#title			:bitcoin-status..sh
#description	:This scripts continuously displays bitcoin price from Bitstamp.net market (value of one BTC in USD) and the latest block height and age from BlockChain.info.
#author			:<NAME>
#date			:20140211
#version		:1.1.0
#usage:			:bash bitcoin-status.sh
#notes:			:Install cURL and Jshon to use the script. Press Ctrl+C to exit script.
#bash_version:	:4.2-5ubuntu3

#TODO:
#* colours

TIME_FORMAT="%H:%M %e.%d.%Y"
# Public API URLs
BITSTAMP_API_URL="https://www.bitstamp.net/api/ticker/"
BLOCKCHAIN_API_URL="https://blockchain.info/latestblock"
INTERVAL=60 # in seconds

s
echo "Current BTC price from Bitstamp.net."
echo "Lastest block info from Blockchain.info."
echo -e "Update interval: "$INTERVAL" seconds."

# don't want to use 'watch', because it runs in full screen mode
while true; do
	TIME_CURRENT_UTC=`TZ='UTC' date +%s`
	PRICE=`curl --get --silent $BITSTAMP_API_URL | jshon -e last -u`
	BLOCKCHAIN_OUTPUT=`curl --get --silent $BLOCKCHAIN_API_URL`
	HEIGHT=`echo $BLOCKCHAIN_OUTPUT | jshon -e height -u`
	TIME=`echo $BLOCKCHAIN_OUTPUT | jshon -e time -u`
	TIME_DELTA=`echo "$TIME_CURRENT_UTC-$TIME" | bc`
	TIME_DELTA_HUMAN="$(($TIME_DELTA / 60))m $(($TIME_DELTA % 60))s"

	echo -ne "\n[" && echo -n `date +"$TIME_FORMAT"` && echo -ne "] LAST PRICE: $"$PRICE"\tHEIGHT: "$HEIGHT"\tAGE: "$TIME_DELTA_HUMAN
	sleep $INTERVAL
done
<commit_msg>Set in how many intervals to skip requests.<commit_after>#!/bin/bash
#title			:bitcoin-status..sh
#description	:This scripts continuously displays bitcoin price from Bitstamp.net market (value of one BTC in USD) and the latest block height and age from BlockChain.info.
#author			:<NAME>
#date			:20140211
#version		:1.2.0
#usage:			:bash bitcoin-status.sh
#notes:			:Install cURL and Jshon to use the script. Press Ctrl+C to exit script.
#bash_version:	:4.2-5ubuntu3

#TODO:
#* colours

# Check those variables and make your modifications if necessary:

# Public API URLs
BITSTAMP_API_URL="https://www.bitstamp.net/api/ticker/"
BLOCKCHAIN_API_URL="https://blockchain.info/latestblock"

TIME_FORMAT="%H:%M %e.%d.%Y" # format in what you want timestamp to be, check for variables: http://www.linuxmanpages.com/man1/date.1.php
INTERVAL=60 # in seconds, set it by checking API request limits
SKIP_BLOCKCHAIN_INVERVALS=4 # How many invevals skip blockchain request. E.g. if 0, then every interval (default 60s) is blockchain request made; if 1, then every other interval (skip one interval) and so on. May be necessary, because difference in API request limits.
SKIP_BITSTAMP_INTERVALS=1 # Same as 'SKIP_BLOCKCHAIN_INVERVAlS', but for Bitstamp requests.

# Don't modify code beneath this comment unless you know what you're doing ;).

echo "Current BTC price from Bitstamp.net."
echo "Lastest block info from Blockchain.info."
echo -e "Update interval: "$INTERVAL" seconds."

COUNTER=0

# don't want to use 'watch', because it runs in full screen mode
while true; do
	if [ "$SKIP_BITSTAMP_INTERVALS" -eq 0 ] || [ "$(($COUNTER % ($SKIP_BITSTAMP_INTERVALS + 1)))" -eq 0 ] ; then
		PRICE=`curl --get --silent $BITSTAMP_API_URL | jshon -e last -u`
	fi
	if [ "$SKIP_BLOCKCHAIN_INVERVALS" -eq 0 ] || [ "$(($COUNTER % ($SKIP_BLOCKCHAIN_INVERVALS + 1)))" -eq 0 ] ; then
		BLOCKCHAIN_OUTPUT=`curl --get --silent $BLOCKCHAIN_API_URL`
		HEIGHT=`echo $BLOCKCHAIN_OUTPUT | jshon -e height -u`
		TIME=`echo $BLOCKCHAIN_OUTPUT | jshon -e time -u`
	fi
	
	TIME_CURRENT_UTC=`TZ='UTC' date +%s`
	TIME_DELTA=`echo "$TIME_CURRENT_UTC-$TIME" | bc`
	TIME_DELTA_HUMAN="$(($TIME_DELTA / 60))m $(($TIME_DELTA % 60))s"
	
	echo -ne "\n[" && echo -n `date +"$TIME_FORMAT"` && echo -ne "] LAST PRICE: $"$PRICE"\tHEIGHT: "$HEIGHT"\tAGE: "$TIME_DELTA_HUMAN
	
	sleep $INTERVAL
	
	let COUNTER++
done

{'fraction_non_alphanumeric': 0.13421750663129972, 'fraction_numerical': 0.015119363395225464, 'mean_word_length': 4.611607142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '759777', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1357, 'n_words': 419}