Skip to content

Instantly share code, notes, and snippets.

View scripting's full-sized avatar

Dave Winer scripting

View GitHub Profile
@scripting
scripting / gist:6165085
Created August 6, 2013 14:39
View text dialog
<html>
<head>
<%systemstyles%>
<script>
function showViewTextDialog () {
$("#idViewTextDialog").modal ("show");
};
</script>
<style>
body {
<html>
<head>
<title>Wordnik demo from JavaScript</title>
<script src="http://static.smallpicture.com/bootstrap/js/jquery-1.9.1.min.js"></script>
<script>
var baseUrl = "http://api.wordnik.com/v4/word.json/";
var apiKey = "a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5"; //demo key from developer.wordnik.com
function getSynonyms (theWord, callback) {
var url = baseUrl + theWord + "/relatedWords?useCanonical=true&relationshipTypes=synonym&limitPerRelationshipType=100&api_key=" + apiKey;
var jxhr = $.ajax ({
@scripting
scripting / canvasImage
Created June 29, 2014 19:43
Why doesn't the image in this example scale to fill the canvas?
<html>
<head>
<title>Canvas Lab</title>
<style>
body {
background-color: whitesmoke;
}
.divPage {
margin-top: 125px;
@scripting
scripting / serverCodeForTwitter
Last active August 29, 2015 14:03
A bit of server code, referenced in a blog post on Scripting News
//see this blog post for background -- http://scripting.com/2014/07/01/twitterApiUpdatewithmedia.html
var buffer = new Buffer (body, "base64");
var params = {
url: "https://api.twitter.com/1.1/statuses/update_with_media.json",
oauth: {
consumer_key: process.env.twitterConsumerKey,
consumer_secret: process.env.twitterConsumerSecret,
token: parsedUrl.query.oauth_token,
token_secret: parsedUrl.query.oauth_token_secret
//referenced in this blog post -- http://scripting.com/2014/07/01/twitterApiUpdatewithmedia.html
function tweetImage (status) {
var theCanvas = document.getElementById ("idCanvas");
var urlImage = theCanvas.toDataURL ();
var imgType = "image/png";
function encode (s) {
return (encodeURIComponent (s));
}
@scripting
scripting / correctedStatusMedia
Created July 1, 2014 14:13
Updated code snippet for a Scripting News blog post, with corrected code
//Goes with this blog post -- http://scripting.com/2014/07/01/twitterApiUpdatewithmedia.html#aIJWTS
var params = {
url: "https://api.twitter.com/1.1/statuses/update_with_media.json",
oauth: {
consumer_key: process.env.twitterConsumerKey,
consumer_secret: process.env.twitterConsumerSecret,
token: parsedUrl.query.oauth_token,
token_secret: parsedUrl.query.oauth_token_secret
@scripting
scripting / RiverReader
Last active August 29, 2015 14:03
Minimal code for reading a river
<html>
<head>
<title>Minimal River Reader</title>
<script src="http://fargo.io/code/jquery-1.9.1.min.js"></script>
</head>
<body>
<script>
var theRiver;
function onGetRiverStream (updatedFeeds) {
theRiver = updatedFeeds;
@scripting
scripting / gist:828144d4a9dda203164c
Created August 19, 2014 22:22
A routine that updates a Facebook post.
function fbUpdatePost (idPost, thePostText) {
FB.api (idPost, "post", {message: thePostText}, function (response) {
console.log ("fbUpdatePost: response == " + JSON.stringify (response, undefined, 4));
});
}
@scripting
scripting / gist:f289b2d36316964bf399
Created September 13, 2014 19:37
Example of JSON test that is sent by Radio3 to a server that's hooked in
{
"guid": {
"flPermalink": true,
"value": "http://thefuturebuzz.com/2013/08/15/the-slow-inevitable-death-of-cable-tv/"
},
"text": "The Slow, Inevitable Death Of Cable TV.",
"title": "",
"link": "http://thefuturebuzz.com/2013/08/15/the-slow-inevitable-death-of-cable-tv/",
"linkShort": "http://bit.ly/1q1p56Y",
"whenLastEdit": "2014-09-13T19:35:48.808Z",
@scripting
scripting / gist:24a97569e8103799d942
Created September 19, 2014 12:50
An example of the metadata Twitter keeps about an individual tweet.
{
"created_at": "Fri Sep 19 12:20:23 +0000 2014",
"id": 512939257850511360,
"id_str": "512939257850511360",
"text": "\"I never used the Blackberry again.\" https://t.co/CYsbbBDtOh",
"source": "<a href=\"http://radio3.io/\" rel=\"nofollow\">radio3.io</a>",
"truncated": false,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,