Skip to content

Instantly share code, notes, and snippets.

View scripting's full-sized avatar

Dave Winer scripting

View GitHub Profile
@scripting
scripting / xmlQuestion.js
Last active August 29, 2015 14:16
Question about serializing XML structures in JavaScript. See comment below for explanation.
function xmlVisit (adrx, callback, level, path) {
if (level === undefined) {
level = 0;
}
if (path === undefined) {
path = "";
}
$(adrx).children ("outline").each (function () {
var flvisitsubs = true, name = xmlGetNodeName (this);
@scripting
scripting / opGetMywordJstruct.js
Last active August 29, 2015 14:16
A code fragment that gets the myword.io compatible JSON from the bar cursor outline
function opGetBarCursor () { //11/12/14 by DW
return ($(getActiveOutliner ()).concord ().op.getCursorRef ());
}
function dateToNumber (theDate) { //2/15/15 by DW
return (Number (new Date (theDate)));
}
function opGetMywordJstruct (theNode) { //2/15/15 by DW
if (theNode == undefined) {
theNode = opGetBarCursor ();
}
@scripting
scripting / koreanCharFiles.txt
Last active August 29, 2015 14:17
Why do these random files keep showing up in my repos??
I'm using the Mac GitHub client, and these weird files keep showing up and I have to delete them before anything will work.
Here's a screen shot.
http://scripting.com/2015/03/21/koreanchars.png
As far as I know I'm not doing anything to create them.
Any clues would be much appreciated.
@scripting
scripting / MP3 download snippet
Last active August 29, 2015 14:18
This code doesn't work. Trying to figure out why! :-)
var requestSettings = {
method: 'GET',
url: theEnclosure.url,
encoding: null
};
request (requestSettings, function (error, response, body) {
if (!error && (response.statusCode == 200)) {
fs.writeFile ("podcast.mp3", body, function (err) {
console.log (body.length + " bytes written to file.");
@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">
@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 / 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 / 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 / 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 / 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,