Skip to content

Instantly share code, notes, and snippets.

@sebastianrothbucher
Last active August 29, 2015 14:22
Show Gist options
  • Save sebastianrothbucher/a61ce7c5e7a003d4b9d0 to your computer and use it in GitHub Desktop.
Save sebastianrothbucher/a61ce7c5e7a003d4b9d0 to your computer and use it in GitHub Desktop.
_changes Hacks on Windows (MINGW32)
Some hacks to demonstrate _changes
1-3: display an MsgBox for each change (with more content)
4: Write to the Windows Event Log on each change
5: Create an asana task on each change
jq.exe
apikey.txt
since.txt
msgbox.vbs
#!bash
echo 'msgbox WScript.Arguments(0)' > msgbox.vbs
echo 0 > since.txt
while true
do
echo "http://localhost:5984/couchday/_changes?feed=longpoll&since=$(cat since.txt)"
curl "http://localhost:5984/couchday/_changes?feed=longpoll&since=$(cat since.txt)" | grep '"id"' | while read i
do
wscript msgbox.vbs $i
echo $i | sed -e 's/,$//' | jq .seq > since.txt
cat since.txt
done
done
#!bash
if [ ! -f jq.exe ]; then
curl -X GET -O http://stedolan.github.io/jq/download/win64/jq.exe
fi
echo 'msgbox WScript.Arguments(0)' > msgbox.vbs
echo 0 > since.txt
while true
do
echo "http://localhost:5984/couchday/_changes?feed=longpoll&since=$(cat since.txt)"
curl "http://localhost:5984/couchday/_changes?feed=longpoll&since=$(cat since.txt)" | grep '"id"' | while read i
do
wscript msgbox.vbs "Breaking: change in $(echo $i | sed -e 's/,$//' | jq .id | sed -e 's/\"//g')"
echo $i | sed -e 's/,$//' | jq .seq > since.txt
cat since.txt
done
done
#!bash
if [ ! -f jq.exe ]; then
curl -X GET -O http://stedolan.github.io/jq/download/win64/jq.exe
fi
echo 'msgbox WScript.Arguments(0)' > msgbox.vbs
echo 0 > since.txt
while true
do
echo "http://localhost:5984/couchday/_changes?include_docs=true&feed=longpoll&since=$(cat since.txt)"
curl "http://localhost:5984/couchday/_changes?include_docs=true&feed=longpoll&since=$(cat since.txt)" | grep '"id"' | while read i
do
wscript msgbox.vbs "Breaking: change in $(echo $i | sed -e 's/,$//' | jq .id | sed -e 's/\"//g') - News: $(echo $i | sed -e 's/,$//' | jq .doc.nachricht | sed -e 's/\"//g')"
echo $i | sed -e 's/,$//' | jq .seq > since.txt
cat since.txt
done
done
#!bash
if [ ! -f jq.exe ]; then
curl -X GET -O http://stedolan.github.io/jq/download/win64/jq.exe
fi
echo 0 > since.txt
while true
do
echo "http://localhost:5984/couchday/_changes?include_docs=true&feed=longpoll&since=$(cat since.txt)"
curl "http://localhost:5984/couchday/_changes?include_docs=true&feed=longpoll&since=$(cat since.txt)" | grep '"id"' | while read i
do
eventcreate //ID 1 //T INFORMATION //L APPLICATION //SO "Couch" //D "Breaking: change in $(echo $i | sed -e 's/,$//' | jq .id | sed -e 's/\"//g') - News: $(echo $i | sed -e 's/,$//' | jq .doc.nachricht | sed -e 's/\"//g')"
echo $i | sed -e 's/,$//' | jq .seq > since.txt
cat since.txt
done
done
#!bash
if [ ! -f apikey.txt ]; then
echo "Pls. put your API key into apikey.txt' and try again"
exit 1
fi
if [ ! -f jq.exe ]; then
curl -X GET -O http://stedolan.github.io/jq/download/win64/jq.exe
fi
echo 0 > since.txt
while true
do
echo "http://localhost:5984/couchday/_changes?include_docs=true&feed=longpoll&since=$(cat since.txt)"
curl "http://localhost:5984/couchday/_changes?include_docs=true&feed=longpoll&since=$(cat since.txt)" | grep '"id"' | while read i
do
curl -X POST -u $(cat apikey.txt): "https://app.asana.com/api/1.0/tasks/37666435599365/subtasks" -d "name=Breaking: change in $(echo $i | sed -e 's/,$//' | jq .id | sed -e 's/\"//g')" -d "notes=News: $(echo $i | sed -e 's/,$//' | jq .doc.nachricht | sed -e 's/\"//g')"
echo $i | sed -e 's/,$//' | jq .seq > since.txt
cat since.txt
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment