Last active
October 31, 2015 14:42
-
-
Save billymoon/c0c6f6f834d1e0ba51e0 to your computer and use it in GitHub Desktop.
there were 0.17658892646431923 green bottles
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
there were 0.6299692264292389 green bottles..! |
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
<!-- http://bl.ocks.org/billymoon/c0c6f6f834d1e0ba51e0 --> | |
<html><head> | |
<title>the thing</title> | |
<script data-require="jquery@*" data-semver="2.1.3" src="http://code.jquery.com/jquery-2.1.3.min.js"></script> | |
<script> | |
function gist(data){ | |
var username = $('#username').val(); | |
var password = $('#password').val(); | |
var opts = { | |
url: 'https://api.github.com/gists/c0c6f6f834d1e0ba51e0', | |
method: data ? 'PATCH' : 'GET', | |
beforeSend: function(xhr) { | |
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password)); | |
} | |
} | |
if(data){ opts.data = JSON.stringify(data) } | |
return $.ajax(opts); | |
} | |
$(function(){ | |
$("#password").focus(); | |
$("#button").on("click", function(){ | |
gist().done(function(data){ | |
gist({ | |
"files": { | |
"file1.txt": { | |
"content": data.files["file1.txt"].content + "." | |
} | |
} | |
}).done(function(){ | |
gist().done(function(){ | |
console.log(arguments); | |
}); | |
}); | |
}); | |
}); | |
}); | |
</script> | |
</head><body> | |
<input name="username" id="username" type="text" value="billymoon" /> | |
<input name="password" id="password" type="password" /> | |
<button type="button" id="button">do the thing...</button> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment