Skip to content

Instantly share code, notes, and snippets.

@peterhartree
Created January 30, 2016 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterhartree/cdf6b0c698434d21e2ff to your computer and use it in GitHub Desktop.
Save peterhartree/cdf6b0c698434d21e2ff to your computer and use it in GitHub Desktop.
Create a new Beeminder datapoint if current system time is within a given window.
# Create a new Beeminder datapoint if current system time is within a
# given window.
#
# Possible use case: if you're on OS X, you can trigger this script with
# the free ControlPlane app. This means you can automatically Beemind
# yourself to a given location before a given time.
#
# Originally made by @peterhartree in order to Beemind his way to the
# office bright and early. Check up on him at
# https://www.beeminder.com/peterhartree/goals/rcu :P
#######################################
# Config
#######################################
username="REPLACE"
authToken="REPLACE"
goalSlug="REPLACE"
datapointValue="1"
datapointComment="Good+morning+everybody"
startTime="500" # 5am
endTime="745" # 7.45am
# If you want to specify e.g. 9.30pm, use the number "2145".
#######################################
# No need to edit below here.
#######################################
currentTime=`date +%k%M`
if [ $currentTime -gt $startTime -a $currentTime -lt $endTime ]; then
echo "Current time is within the specified window."
echo "Sending Beeminder datapoint."
curl --data "auth_token=$authToken&value=$datapointValue&comment=$datapointComment" https://www.beeminder.com/api/v1/users/$username/goals/$goalSlug/datapoints.json
exit 0
else
echo "Nothing to do."
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment