Skip to content

Instantly share code, notes, and snippets.

View scripting's full-sized avatar

Dave Winer scripting

View GitHub Profile
@scripting
scripting / hello.js
Created June 23, 2017 13:56
Hello World for githubpub
const githubpub = require ("githubpub");
var config = {
port: 5376,
domains: {
"githubpub.scripting.com": {
username: "scripting",
repository: "Scripting-News",
path: "githubpub"
}
<html>
<head>
<title>GitHub API: Get repo directory</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="http://fargo.io/code/jquery-1.9.1.min.js"></script>
<link href="http://fargo.io/code/bootstrap.css" rel="stylesheet">
<script src="http://fargo.io/code/bootstrap.min.js"></script>
<link href="http://fargo.io/code/ubuntuFont.css" rel="stylesheet" type="text/css">
<script>
<html>
<head>
<title>GitHub API: Get repo directory</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="http://fargo.io/code/jquery-1.9.1.min.js"></script>
<link href="http://fargo.io/code/bootstrap.css" rel="stylesheet">
<script src="http://fargo.io/code/bootstrap.min.js"></script>
<link href="http://fargo.io/code/ubuntuFont.css" rel="stylesheet" type="text/css">
<script>
@scripting
scripting / mylist.opml
Last active July 8, 2017 07:29
An example of an OPML subscription list that includes another list.
<?xml version="1.0"?>
<opml version="2.0">
<head>
<title>mylist.opml</title>
</head>
<body>
<outline text="Feeds" type="include" url="https://dl.dropboxusercontent.com/u/36518280/river5/includedTestList2.opml"/>
</body>
</opml>
@scripting
scripting / radioLinkblog.json
Created May 23, 2017 00:59
Since JSON feeds are in the air, it got me thinking. Radio3, my latest linkblogging tool, stores the data that's turned into RSS as (drum roll please) JavaScript structs. I added a little debugging code to list those structs in JSON. It's in two parts, the header elements and the history array. I had never looked at this before. It's kind of int…
{
"title": "Dave Winer",
"link": "http://scripting.com/",
"description": "I started up blogging, podcasting, RSS 2.0, and software for all of that. I love outliners, JavaScript. I love to make new media. Read my blog! :-)",
"language": "en-us",
"generator": "Radio3 v0.76d",
"docs": "http://cyber.law.harvard.edu/rss/rss.html",
"twitterScreenName": "davewiner",
"maxFeedItems": 25,
"appDomain": "radio3.io",
@scripting
scripting / xmlToJson.js
Last active June 8, 2017 21:09
An 8-line Node.js script to convert the XML version of Scripting News's feed to JSON.
const xml2js = require ("xml2js"), request = require ("request");
request ("http://scripting.com/rss.xml", function (error, response, data) {
if (!error && (response.statusCode == 200)) {
xml2js.parseString (data, function (err, result) {
console.log (JSON.stringify (result, undefined, 4));
});
}
});
@scripting
scripting / river5socketdemo.html
Last active October 16, 2025 10:58
This is a simple WebSockets application that hooks up to my River5 server, which is constantly scanning for new items in the feeds it follows. When a new story comes in, a JSON representation of the story goes out instantaneously over the socket.
<html>
<head>
<title>River5 websockets demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- app is live here: http://rss2.io/code/socketdemo/ -->
<script src="http://fargo.io/code/jquery-1.9.1.min.js"></script>
<link href="http://fargo.io/code/bootstrap.css" rel="stylesheet">
@scripting
scripting / buildRiverCallbackExample.js
Last active April 23, 2017 21:44
An example of a River5 callback script that's called whenever a river is built
//two globals are set up by River5 for buildRiver callbacks, fname and jsontext.
//this example creates a copy of the river in a folder on another disk, named Montreal.
var f = "/Volumes/Montreal/tmp/rivers/" + fname;
fsSureFilePath (f, function () {
fs.writeFile (f, jsontext);
});
@scripting
scripting / dummyPodcastFeed.xml
Last active April 18, 2017 03:23
I use this feed for testing apps that have to process enclosures. Have your app subscribe to the feed. Just change the value of the long number to generate a new item.
<?xml version="1.0"?>
<!-- RSS generated by OPML Editor v0.75 on 4/17/17; 11:19:01 PM -->
<rss version="2.0">
<channel>
<title>Test podcast feed</title>
<link>http://scripting.com/</link>
<description>This feed contains one item that has an enclosure. I have a script that rebuilds the feed with a fresh url on the enclosure making it useful for testing podcatcher apps.</description>
<language>en-US</language>
<lastBuildDate>Tue, 18 Apr 2017 03:19:01 GMT</lastBuildDate>
<docs>http://cyber.law.harvard.edu/rss/rss.html</docs>
@scripting
scripting / example2.js
Created March 17, 2017 21:02
Simpler version of Electron code to create a new window with an icon.
app.on ("ready", function () {
mainWindow = new BrowserWindow ({
width: 1100,
height: 1000,
icon: __dirname + "/" + "pork.png"
});
mainWindow.loadURL('file://' + __dirname + '/index.html');
});