Skip to content

Instantly share code, notes, and snippets.

View tanepiper's full-sized avatar

Tane Piper tanepiper

View GitHub Profile
@tanepiper
tanepiper / twitter_oauth_getter.js
Created September 11, 2010 16:14
A small command line nodejs script for doing Twitter OAuth.
#!/usr/bin/env node
var argv = require('optimist')
.usage('Usage: --key=[consumer key] -secret=[consumer secret]')
.demand(['key', 'secret'])
.argv
;
var OAuth = require('oauth').OAuth;
var Step = require('step');
#!/usr/bin/env node
var fs = require("fs")
, path = require("path")
, npm = require("npm")
, readJSON = require("npm/utils/read-json");
npm.load(function(){
readJSON(process.argv[2], function(err, data){
if(err) throw err;
@troufster
troufster / Zone.js
Created January 12, 2011 18:49
Draft of js spatial hash
/**
* Module dependencies
*/
var Vector = require('../public/lib/vector'),
_floor = Math.floor;
@TooTallNate
TooTallNate / starttls.js
Created March 1, 2011 01:40
Upgrade a regular `net.Stream` connection to a secure `tls` connection.
// Target API:
//
// var s = require('net').createStream(25, 'smtp.example.com');
// s.on('connect', function() {
// require('starttls')(s, options, function() {
// if (!s.authorized) {
// s.destroy();
// return;
// }
//
require.extensions[".json"] = function (module, filename) {
module.exports = JSON.parse(require("fs").readFileSync(filename, "utf8"))
}
loadSpecs = (paths...) ->
# expand all spec paths to full cache busted file paths
paths = for path in paths
"spec/#{path}_spec.js?#{new Date().getTime()}"
# Load the specs with head.js, and start a spec run 1 second after they load.
head.js paths..., ->
setTimeout ->
jasmine.getEnv().addReporter(new jasmine.TrivialReporter())
jasmine.getEnv().execute()
@jimeh
jimeh / jquery.myplugin.coffee
Created April 7, 2011 23:44
Example jQuery plugin written in CoffeeScript, and the resulting compiled JavaScript file.
$.fn.extend
myplugin: (options) ->
self = $.fn.myplugin
opts = $.extend {}, self.default_options, options
$(this).each (i, el) ->
self.init el, opts
self.log el if opts.log
$.extend $.fn.myplugin,
default_options:
@Floby
Floby / editor.js
Created April 19, 2011 09:18
open the default editor from node
var fs = require('fs');
var child_process = require('child_process');
var spawn = child_process.spawn;
function openEditor(file) {
var cp = spawn(process.env.EDITOR, [file], {
customFds: [
process.stdin,
process.stdout,
process.stderr
@catalogchoice
catalogchoice / gist:934418
Created April 21, 2011 12:49
coffeescript name space
namespace = (target, name, block) ->
[target, name, block] = [(if typeof exports isnt 'undefined' then exports else window), arguments...] if arguments.length < 3
top = target
target = target[item] or= {} for item in name.split '.'
block target, top
@bergie
bergie / README.md
Created May 18, 2011 11:33
Falsy Values tutorials