Skip to content

Instantly share code, notes, and snippets.

View scripting's full-sized avatar

Dave Winer scripting

View GitHub Profile
function nukeDisabledMenuItems () {
$(".dropdown-menu li").each (function () {
if ($(this).hasClass ("disabled")) {
$(this).children ().first ().attr ("onclick", ""); //nuke the command
}
});
}
@scripting
scripting / config.json
Last active November 1, 2016 15:55
An example config.json file that specifies a set of panels on your River5 installation's home page.
{
"maxRiverItems": 300,
"flAddItemsFromNewSubs": false,
"homePage": {
"panels": [
{
"title": "Dave",
"river": "iowa.js"
},
{

I need a way to write WebSocket client code that runs on a server in Node.js.

What it must do: Exactly what this browser-based app does, only running on a server, without the UI stuff.

https://github.com/scripting/1999client/blob/master/code.js#L133

It would make so much sense if Node implemented exactly the browser API for WebSockets, native. So much of Node works that way. But this is one of those times when it doesn't.

There are a few toolkits that do WebSockets on the server. But there isn't simple clean sample code that I've been able to convert to this application. I tried! :-)

@scripting
scripting / fsDeleteDirectory.js
Created March 25, 2016 13:53
Recursively delete a directory and all its subs and files it contains.
function fsDeleteDirectory (folderpath, callback) { //3/25/16 by DW
if (folderpath [folderpath.length - 1] != "/") {
folderpath += "/";
}
fs.readdir (folderpath, function (err, list) {
if (err) {
console.log ("fsDeleteDirectory: err.message == " + err.message);
}
else {
function doListItem (ix) {
@scripting
scripting / config.json
Last active March 27, 2016 21:12
Example of a config.json file for nodeStorage that sets up a 1999.io server
{
"myPort": 1999,
"websocketPort": 2000,
"myDomain": "1999.bullmancuso.io:1999",
"where": {
"flUseLocalFilesystem": true,
"publicPath": "publicFiles/",
"privatePath": "privateFiles/"
},
"twitterConsumerKey": "anm3unkb1mof7isav0bkxigby",
@scripting
scripting / config.json
Created March 29, 2016 21:34
Example of a config.json file for nodeStorage that specified a whitelist.
{
"myPort": 1999,
"websocketPort": 2000,
"myDomain": "1999.bullmancuso.io:1999",
"urlUserWhitelist": "http://1999.io/docs/examplewhitelist.json",
"where": {
"flUseLocalFilesystem": true,
"publicPath": "publicFiles/",
"privatePath": "privateFiles/"
},
@scripting
scripting / config.json
Last active March 30, 2016 16:03
Example of a config.json file for nodeStorage that has an updates object and automatically restarts when there's a change to the main JavaScript file.
{
"myPort": 1999,
"websocketPort": 2000,
"myDomain": "1999.bullmancuso.io:1999",
"urlUserWhitelist": "http://1999.io/docs/examplewhitelist.json",
"flWatchAppDateChange": true,
"fnameApp": "storage.js",
"updates": {
"enabled": true,
"fnameStorageJs": "storage.js",
@scripting
scripting / config.json
Created March 30, 2016 16:18
Example of a config.json file that specifies the whitelist as an array.
{
"myPort": 1999,
"websocketPort": 2000,
"myDomain": "1999.bullmancuso.io:1999",
"userWhitelist": ["bullmancuso", "lawyerboyer"],
"where": {
"flUseLocalFilesystem": true,
"publicPath": "publicFiles/",
"privatePath": "privateFiles/"
},
@scripting
scripting / myPublishCallback.js
Created April 2, 2016 21:34
Example of a callback script for nodeStorage, used to mirror all files published by a user in another location
if (screenName == "bullmancuso") {
s3.newObject ("/bullman.io/mirror/" + relpath, body, type);
}
@scripting
scripting / pagetable.json
Last active April 13, 2016 03:19
An example of a pagetable used when rendering a page in 1999.io.
{
"productname": "bloatWare",
"productnameForDisplay": "BloatWare",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."",
"urlTwitterServer": "http://localhost:1229/",
"urlPageTemplate": "/template.html",
"urlChatLogSocket": "ws://localhost:1230/",
"domain": "1999.io",
"nameChatLog": "davewiner",
"version": "0.88j",