Skip to content

Instantly share code, notes, and snippets.

View scripting's full-sized avatar

Dave Winer scripting

View GitHub Profile
@scripting
scripting / localStorageSnapshot.json
Created June 21, 2015 05:21
A snapshot of the localStorage.json file after running the demo callback script inside River4 for a few hours.
{
"feeds": {
"http://www.nytimes.com/services/xml/rss/nyt/Travel.xml": {
"ctAdds": 1,
"whenFirstAdd": "2015-06-21T03:02:55.237Z",
"whenLastAdd": "2015-06-21T03:02:55.237Z",
"stories": [
"Frugal Traveler: Exploring Franche-Comté, France’s Well-Kept Secret"
]
},
@scripting
scripting / exampleRiver4Callback.js
Last active August 29, 2015 14:23
An example of a callback script that runs when a new item is added to the river.
var now = new Date ();
if (localStorage.feeds === undefined) {
localStorage.feeds = new Object ();
}
if (localStorage.feeds [urlfeed] === undefined) {
localStorage.feeds [urlfeed] = {
ctAdds: 0,
whenFirstAdd: now
};
}
@scripting
scripting / testRssCloud.js
Last active August 9, 2016 18:14
A simple app that tests Andrew's implementation of an rssCloud server.
var myVersion = "0.40", myProductName = "testRssCloud", myPort = 2222, myDomain = "yourserver.io";
//Test app for Andrew Shell's rssCloud server
//https://github.com/andrewshell/rsscloud-server
var request = require ("request");
var http = require ("http");
var urlpack = require ("url");
var dns = require ("dns");
var qs = require ("querystring");
@scripting
scripting / sendToSlack.js
Last active July 9, 2022 13:03
A tiny JavaScript app that sends a message to your default Slack channel. Can be customized with a name, icon, emoji or sent to a different channel. Runs in Node.js.
var request = require ("request");
var urlWebHook = "https://hooks.slack.com/services/abcdef"; //the URL you get on your "incoming web hooks" page.
function sendToSlack (s, theUsername, theIconUrl, theIconEmoji, theChannel) {
var payload = {
text: s
};
if (theUsername !== undefined) {
payload.username = theUsername;
@scripting
scripting / prefs.json
Created May 23, 2015 23:30
An example prefs.json file for PagePark that includes a domainMap section.
{
"myPort": 80,
"indexFilename": "index",
"flProcessScriptFiles": true,
"extScriptFiles": "js",
"flProcessMarkdownFiles": true,
"extMarkdownFiles": "md",
"domainMap": {
"judgment.club": 5351,
"twitter.radio3.io": 5342,
@scripting
scripting / readOpml.js
Last active August 29, 2015 14:21
A little Node.js app that reads an OPML file into an outline structure, and displays the structure on the console.
var request = require ("request");
var opmlParser = require ("opmlparser");
function stringMid (s, ix, len) { //8/12/14 by DW
return (s.substr (ix-1, len));
}
function filledString (ch, ct) { //6/4/14 by DW
var s = "";
for (var i = 0; i < ct; i++) {
s += ch;
}
@scripting
scripting / copyRiverFiles.js
Last active August 29, 2015 14:21
I run this JavaScript every minute to copy files from a private folder to a public-facing server.
//By Dave Winer, May 12, 2015.
//I use this script to copy the only files that River4 produces that have to be publicly accessible.
//It only copies if the dest file doesn't exist or if the content of the files has changed.
//I use Noderunner to run it once every minute: https://github.com/scripting/noderunner
var sourcefolder = "/root/river4data/rivers/";
@scripting
scripting / wp.js
Created May 9, 2015 15:29
I wrote this app to convert an entire WordPress site to OPML. I thought it might go somewhere, but it didn't. Maybe the code will be of use to someone else someday, so here it is.
var myVersion = "0.43";
//last build 4/17/2014; 1:03:26 PM
var http = require ("http");
var AWS = require ("aws-sdk");
var s3 = new AWS.S3 ();
var urlpack = require ("url");
var xmlrpc = require ("xmlrpc");
@scripting
scripting / config.json
Last active August 29, 2015 14:19
An example file for v0.55 of PagePark.
{
"urlSiteContents": "https://dl.dropboxusercontent.com/u/36518280/pageParkDemo"
}
@scripting
scripting / mweHomeDemo.js
Created April 11, 2015 18:42
This is a demo of an idea for a home page for MyWord Editor.
<html>
<head>
<title>Dave's MyWord Blog Home</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="alternate" type="application/rss+xml" href="http://myword.io/users/davewiner/rss.xml" />
<script src="http://fargo.io/code/jquery-1.9.1.min.js"></script>
<link href="http://fargo.io/code/bootstrap.css" rel="stylesheet">