Skip to content

Instantly share code, notes, and snippets.

Avatar

Dave Winer scripting

View GitHub Profile
@scripting
scripting / earlyTwitterUsers.js
Created Apr 9, 2021
A script that runs in the Drummer environment, and uses the Twitter verbs to find the names of the earliest Twitter users, starting with @jack.
View earlyTwitterUsers.js
var flfirst = true;
op.insert ("Early Twitter signups", down);
for (var i = 12; i < 25; i++) {
op.insert (twitter.getScreenname (i), (flfirst) ? "right" : "down");
flfirst = false;
}
op.go (left, 1);
View gluescript.js
makeFilePublic: function (path) {
return new Promise (function (resolve, reject) {
servercall ("makefilepublic", {relpath: path}, true, function (err, data) {
if (err) {
reject (err);
}
else {
resolve (data.url);
}
});
@scripting
scripting / listChangedProjects.ftsc
Last active Jan 17, 2021
I needed a script to loop over a calendar-structured folder to generate a list of the most recent updates to a set of projects that are backed up in these folders. I used Frontier. Here's the script.
View listChangedProjects.ftsc
on listChangedProjects (whenStart, whenEnd) {
«Changes
«1/16/21; 10:36:01 AM by DW
«Created. Generates a table with the names of the most recent version of each of the projects that
were edited in the period we're looking at. whenStart is the day we start our search, whenEnd is
when we stop searching. We go back in time, so whenStart must be more recent than whenEnd.
local (basefolder = nodeEditorSuite.getFolder () + "backups:");
local (destfolder = "Marin:changedProjects:");
local (when = whenStart, adrtable = @scratchpad.changedProjects);
new (tabletype, adrtable);
@scripting
scripting / demoblog.opml
Last active Nov 11, 2020
An OPML file for use with Old School, that shows how to include an About page.
View demoblog.opml
<?xml version="1.0"?>
<opml version="2.0">
<head>
<title>demoblog.opml</title>
<dateCreated>Wed, 11 Nov 2020 17:14:44 GMT</dateCreated>
<dateModified>Wed, 11 Nov 2020 17:20:45 GMT</dateModified>
<flPublic>true</flPublic>
<expansionState>1,2,4,14,15</expansionState>
<lastCursor>14</lastCursor>
<ownerId>https://twitter.com/davewiner/</ownerId>
@scripting
scripting / oldSchoolGeneratedHtml.html
Created Nov 4, 2020
An example of one day's HTML, generated by Old School, for discussion purposes.
View oldSchoolGeneratedHtml.html
<div class="divDayContainer" id="idDayContainer">
<div class="divDayTitle">
<a href="http://scripting.com/2020/10/30.html">Friday, October 30, 2020</a>
</div>
<div class="divSingularItem" data-type="outline" data-commentsetup="true">
<a name="a143253"></a>
<a href="http://this.how/frontier/nodeEditorExample.opml">A new doc</a> explains, through an example, how my Frontier-based code-writing system for JavaScript works. I started this suite about seven years ago, and have been using it ever since. It allows me to edit my code in an outliner, and use Frontier's scripting ability to distribute the results to S3, GitHub, NPM and pretty much anywhere else I want.
<span class="spPermaLink">
<a href="http://scripting.com/2020/10/30.html#a143253" title="Direct link to this item.">#</a>
</span>
View filter.js
const folder = "/root/Dropbox/Miami/littleoutliner/publicFiles/users/";
var url = options.httpRequest.url;
var splits = url.split ("?");
url = splits [0];
splits = url.split ("/");
var username = splits [1], fname = splits [2];
if ((username === undefined) || (fname === undefined)) { //tell pagePark we're not handling it
callback (undefined, {flNotHandled: true});
}
View filter.js
const folder = "/root/Dropbox/Miami/littleoutliner/publicFiles/users/";
var url = options.httpRequest.url;
var splits = url.split ("?");
url = splits [0];
splits = url.split ("/");
var username = splits [1], fname = splits [2];
if ((username === undefined) || (fname === undefined)) { //tell pagePark we're not handling it
callback (undefined, {flNotHandled: true});
}
@scripting
scripting / code.js
Created Sep 5, 2020
Reading BingeWorthy's RSS feed
View code.js
const urlfeed = "http://bingeworthy.io/rss.xml";
function httpRequest (url, timeout, headers, callback) {
timeout = (timeout === undefined) ? 30000 : timeout;
var jxhr = $.ajax ({
url: url,
dataType: "text",
headers,
timeout
})
@scripting
scripting / gist:60669da00b3b49d49ce3f23543fd99d6
Created Jul 3, 2020
Les Orchard's low-level S3 code in Frontier, been running constantly since '06.
View gist:60669da00b3b49d49ce3f23543fd99d6
on httpClient(method="GET", resource="/", adrParams=nil, content=nil, adrMeta=nil, acl=nil, content_type="", idaccount="default", debug=false, flHttpMessages=false) {
«Changes
«8/24/13; 10:50:08 AM by DW
«If the metadata key is website-redirect-location, then we special-case the addition of the header so as not to add the string "meta-" -- which causes it to break. Not sure if the setting metadata feature ever worked, but this is the most conservative approach to avoiding breakage.
«7/10/06; 8:38:52 PM by DW
«Added flHttpMessages optional param, default false. Determines if HTTP calls display messages in the About window.
«4/11/06; 7:11:53 AM by DW
«Changed name of the compiled xml structure to xstruct. It's generally not a good idea to use the names of built-in tables in naming data or code, although this naming couldn't have hurt anything because it's in a table.
«Fixed the error-handling code. If the server returns an error, we throw a scriptError, but before doing that, we set various