Skip to content

Instantly share code, notes, and snippets.

View scripting's full-sized avatar

Dave Winer scripting

View GitHub Profile
@scripting
scripting / typicalXmlRpcServer.js
Created September 3, 2019 15:35
This is a typical XML-RPC server written in JavaScript as of today. There's still more cleanup to do, for example, you shouldn't have to specify flPostEnabled in config, since XML-RPC calls are only made via POST, it can be handled at the lower level.
const xmlrpc = require ("davexmlrpc");
const utils = require ("daveutils");
const davehttp = require ("davehttp");
const mail = require ("davemail");
const fs = require ("fs");
var config = {
port: 1417,
flPostEnabled: true,
flLogToConsole: true,
HTTP/1.1 200 OK
content-type: text/xml
date: Sun, 01 Sep 2019 19:44:33 GMT
connection: close
transfer-encoding: chunked
1f7
<?xml version="1.0"?>
<methodResponse>
<params>
@scripting
scripting / demoriver.html
Created July 9, 2019 16:16
Template for your river, for testing by Anton.
<html>
<head>
<title>Demo River</title>
<link href="//fonts.googleapis.com/css?family=Ubuntu:400,500i,700" rel="stylesheet">
<link rel="stylesheet" href="//s3.amazonaws.com/scripting.com/code/fontawesome/css/all.css">
<script src="//s3.amazonaws.com/scripting.com/code/includes/jquery-1.9.1.min.js"></script>
<link href="//s3.amazonaws.com/scripting.com/code/includes/bootstrap.css" rel="stylesheet">
<script src="//s3.amazonaws.com/scripting.com/code/includes/bootstrap.min.js"></script>
<script src="//s3.amazonaws.com/scripting.com/code/includes/basic/code.js"></script>
<link href="//s3.amazonaws.com/scripting.com/code/includes/basic/styles.css" rel="stylesheet" type="text/css">
@scripting
scripting / config.json
Last active October 29, 2018 17:05
Example config.json file for githubpub
{
"port": 1402,
"clients": {
"michigan": {
"id": "w7eonmdnlsnfysqjatl3",
"secret": "7i7h1iotnwzqqm4psjqtmgnvw2ga3rcki5kv52hb",
"urlEditorApp": "http://mysite.com/editor/"
}
},
"defaultNameCommitter": "Lawyer Boyer",
@scripting
scripting / yamlize.js
Last active September 23, 2018 00:46
Convert between YAML and JSON and vice versa
const utils = require ("daveutils");
const yaml = require ("js-yaml");
function yamlIze (jsontext) {
var jstruct = JSON.parse (jsontext);
const delimiter = "---\n";
var text = jstruct.text;
delete jstruct.text;
var s = delimiter + yaml.safeDump (jstruct) + delimiter + text;
@scripting
scripting / package.json
Last active September 12, 2018 02:26
Getting the contents of a GitHub repository using the contents API
{
"name": "repocontents",
"description": "Code to get the contents of a respository.",
"author": "Dave Winer <dave@smallpicture.com>",
"version": "0.4.0",
"main": "repocontents.js",
"scripts": {
"start": "node repocontents.js"
},
"dependencies" : {
@scripting
scripting / userData.json
Created August 2, 2018 19:25
An example of the data that Twitter gives an app about a user (me)
{
"id": 3839,
"id_str": "3839",
"name": "scripting.com",
"screen_name": "davewiner",
"location": "New York",
"profile_location": null,
"description": "American software developer, blogger, inventor of new media types.",
"url": "https://t.co/ztgzDGiyOj",
"entities": {
@scripting
scripting / config.json
Created July 6, 2018 14:44
A config.json for PagePark that sets the default type for files that don't have extensions.
{"defaultType": "text/html"}
@scripting
scripting / rpcCall.json
Last active June 11, 2018 18:16
Egregious hack to add date and base64 types to JSON for XML-RPC
{
"methodCall": {
"methodName": "examples.echoParams",
"params": [
"#dateTime=2018-06-10T19:41:06.199Z",
"#base64=aGVsbG8gd29ybGQ="
]
}
}
@scripting
scripting / config.json
Created June 6, 2018 16:13
Example of config.json used to redirect a single file in PagePark
{
"#pagePark": {
"urlRedirect": "http://scripting.com/"
}
}