This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$#" -ne 1 ]; then | |
echo "Usage: $0 your-service-prefix" >&2 | |
exit 1 | |
fi | |
fleetctl list-units | grep $1@ | cut -f1 -d. | while read -r unit ; do | |
unit_index=`echo $unit | cut -f2 -d@` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/nodejs | |
var http = require('http'); | |
var latestCaptchaJson = JSON.stringify({ | |
'q':'Is ice hot or cold?', | |
'a':['75e52a0ecfafeda17a34fc60111c1f0b'] }); | |
var apiUrl = 'http://api.textcaptcha.com/mirror.json'; | |
var refreshCaptchaEveryXSeconds = 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$salt = 'MySecretSalt'; | |
// ... [snip] ... | |
// output hidden form fields | |
foreach ($captcha['answers'] as $checksum) { | |
$salted = md5($checksum.$salt); | |
echo '<input type="hidden" name="ans[]" value="'.$salted.'" />'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
$ans = $_POST['captcha']; // .. or whatever! | |
$checksum = md5(strtolower(trim($ans))); | |
if (in_array($checksum,$_SESSION['captcha_ans'])) { | |
// passed..! | |
} else { | |
// error: redisplay form, etc. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
$url = 'http://api.textcaptcha.com/example.json'; | |
$captcha = json_decode(file_get_contents($url),true); | |
if (!$captcha) { | |
$captcha = array( // fallback challenge | |
'question'=>'Is ice hot or cold?', | |
'answers'=>array(md5('cold')) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ { | |
"uuid":"dd172c56-5c99-4cc9-b334-49973e6c406e", | |
"time":1353605834, | |
"author":"Phil Dean", | |
"text":"Did this in river racers at around 0.65 and it was a decent level. scraped the tail a couple of times but nothing major." | |
} ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"status":202, | |
"meta": { | |
"mediatype":"vnd.rainchasers-ack" | |
}, | |
"data": { | |
"geocode":"Llangollen", | |
"ack":"ACTION:GEOCODE", | |
"message":"the snippet 'Llangollen' must be geocoded and replaced with <lat>,<lng>" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rivers = []; | |
function parseUrl(url){ | |
var parsed = require('url').parse(url); | |
return { | |
host: parsed.host, | |
path: parsed.pathname+(parsed.search||'') | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"uuid":"c28497e9-b662-4df1-8698-c8ffc4f57817", | |
"url":"http:\/\/rainchasers.com\/river\/colwyn\/hafod-ruffydd-isaf-beddgelert", | |
"river":"Colwyn", | |
"section":"Hafod Ruffydd Isaf to Beddgelert", | |
"km":"4", | |
"grade": { | |
"text":"4 (5)", | |
"value":"4", | |
"max":"5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$rivers = array(); | |
$next = 'http://api.rainchasers.com/v1/river'; | |
while ($next) { | |
$chunk = json_decode(file_get_contents($next),true); | |
if (!$chunk || $chunk['status']!=200) exit("resync fail at $next"); | |
$rivers = array_merge($rivers,$chunk['data']); | |
fwrite(STDOUT,'.'); | |
$requests[] = $next = isset($chunk['meta']['link']['next']) ? $chunk['meta']['link']['next'] : false; | |
} |