This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These are some Twitter utilities, written directly against their API. | |
Credentials are required. Sign up for a Twitter developer account. | |
To run these scripts, ensure the BEARER_TOKEN is in the environment. E.g., put it in a .env file and run with foreman. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Backbone = require('backbone'); | |
// Flash /////////////////////////////////////////////////////////////////////////////////////////// | |
// The flash is a way for one controller to pass a small amount of information to the next | |
// controller, through a navigation event. | |
// | |
// The flash holds arbitrary parameters, and is cleared by the router after each navigation event. | |
var flash = exports.flash = { | |
params: {}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generates “correct horse battery staple”-style password: xkcd.com/936 | |
// Usage: node pwdgen.js <file> | |
// File should contain common words, one per line. | |
// Params: | |
var minWordLength = 4; | |
var desiredEntropyBits = 30; | |
var fs = require('fs'); | |
var crypto = require('crypto'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var relationEvents = ['add', 'change', 'remove', 'reset', 'sort', 'destroy', 'request', 'sync']; | |
var Model = exports.Model = Backbone.Model.extend({ | |
hasMany: { | |
// Subclasses can override to set relations like this: | |
// | |
// key: function () { return new Collection([], options); }, | |
}, | |
hasOne: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var repl = require('repl') | |
var vm = require('vm'); | |
var _; | |
var server = repl.start({ | |
eval: function (cmd, context, filename, callback) { | |
try { | |
var match = cmd.match(/^\((.*)\n\)$/); | |
var code = match ? match[1] : cmd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
// Workaround for the fact that chai-as-promised isn't working with Mongoose promises: | |
// https://github.com/domenic/chai-as-promised/issues/30 | |
mongoose.Query.prototype.qexec = function () { | |
return Q.npost(this, 'exec', arguments); | |
} | |
mongoose.Model.qcreate = function () { | |
return Q.npost(this, 'create', arguments); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('q-io/http'); | |
var BufferStream = require('q-io/buffer-stream'); | |
// Response | |
function Response(promise) { | |
this.promise = promise; | |
this.status = this.promise.get('status'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var util = require('util'); | |
var extendable = require('./extendable'); | |
// AppError is an error constructor that inherits from Error but is more easily extendable. | |
// You can inherit from it using 'extend' just like with Backbone constructors: | |
// | |
// var SpecialError = AppError.extend({ | |
// name: 'SpecialError', | |
// initialize: function (foo, bar) { | |
// this.message = foo + " " + bar + "!"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var _ = require('underscore'); | |
var csv = require('csv'); | |
var Twitter = require('twitter'); | |
function die(error) { | |
console.error('fatal error'); | |
if (error) console.error('error', error); | |
if (error.stack) console.error('stacktrace', error.stack); | |
process.exit(-1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Verifying that +jasoncrawford is my openname (Bitcoin username). https://onename.io/jasoncrawford |
NewerOlder