Skip to content

Instantly share code, notes, and snippets.

Dave Winer scripting

Block or report user

Report or block scripting

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@scripting
scripting / config.json
Last active Oct 29, 2018
Example config.json file for githubpub
View config.json
{
"port": 1402,
"clients": {
"michigan": {
"id": "w7eonmdnlsnfysqjatl3",
"secret": "7i7h1iotnwzqqm4psjqtmgnvw2ga3rcki5kv52hb",
"urlEditorApp": "http://mysite.com/editor/"
}
},
"defaultNameCommitter": "Lawyer Boyer",
@scripting
scripting / yamlize.js
Last active Sep 23, 2018
Convert between YAML and JSON and vice versa
View yamlize.js
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 Sep 12, 2018
Getting the contents of a GitHub repository using the contents API
View package.json
{
"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 Aug 2, 2018
An example of the data that Twitter gives an app about a user (me)
View userData.json
{
"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 Jul 6, 2018
A config.json for PagePark that sets the default type for files that don't have extensions.
View config.json
{"defaultType": "text/html"}
@scripting
scripting / rpcCall.json
Last active Jun 11, 2018
Egregious hack to add date and base64 types to JSON for XML-RPC
View rpcCall.json
{
"methodCall": {
"methodName": "examples.echoParams",
"params": [
"#dateTime=2018-06-10T19:41:06.199Z",
"#base64=aGVsbG8gd29ybGQ="
]
}
}
@scripting
scripting / config.json
Created Jun 6, 2018
Example of config.json used to redirect a single file in PagePark
View config.json
{
"#pagePark": {
"urlRedirect": "http://scripting.com/"
}
}
@scripting
scripting / s3FolderExists.js
Created Jun 5, 2018
JS code to ask AWS if an S3 path is a folder with files in it
View s3FolderExists.js
function s3FolderExists (s3path, callback) {
var flHaveCalledBack = false;
var splitpath = s3.splitPath (s3path);
var pathToLookFor = splitpath.Key + "/";
s3.listObjects (s3path, function (obj) {
if (obj.flLastObject === undefined) {
if (utils.beginsWith (obj.Key, pathToLookFor)) {
if (!flHaveCalledBack) {
callback (true);
flHaveCalledBack = true;
@scripting
scripting / config.json
Created Jun 4, 2018
An example of a PagePark config.json file that specified a path on S3 to serve from
View config.json
{
"s3ServeFromPath": "/publicfolder.io"
}
@scripting
scripting / iconvLiteExample.js
Last active Apr 18, 2018
Using iconv-lite to do character conversion of HTTP requests
View iconvLiteExample.js
const iconv = require ("iconv-lite");
const request = require ("request");
const utils = require ("daveutils");
var feedUrl = "https://www.presseportal.de/rss/dienststelle_110972.rss2";
function getCharset (httpResponse) {
var contentType = httpResponse.headers ["content-type"];
if (contentType !== undefined) {
var encoding = utils.trimWhitespace (utils.stringNthField (contentType, ";", 2));
You can’t perform that action at this time.