Skip to content

Instantly share code, notes, and snippets.

View AdrianRossouw's full-sized avatar

Adrian Rossouw AdrianRossouw

View GitHub Profile
function jm_purl_modifiers($values = FALSE) {
$values['jm'] = array(
array('value' => 'sa', 'id' => 'sa'),
array('value' => 'cpt', 'id' => 'cpt'),
array('value' => 'jhb', 'id' => 'jhb'),
);
return $values;
}
relevant section of curl manpage :
-d/--data <data>
(HTTP) Sends the specified data in a POST request to the HTTP
server, in the same way that a browser does when a user has
filled in an HTML form and presses the submit button. This will
cause curl to pass the data to the server using the content-type
application/x-www-form-urlencoded. Compare to -F/--form.
-d/--data is the same as --data-ascii. To post data purely
binary, you should instead use the --data-binary option. To URL-
var events = require('events'),
sys = require('sys');
var jobQueue = function(opts) {
var opts = opts || {}
this.jobs = [];
this.queue = [];
this.active = [];
var events = require('events'),
sys = require('sys');
// constructor for job queue
var JobQueue = function(opts) {
var that = this;
this.opts = opts || {}
this.jobs = [];
this.queue = [];
require.paths.unshift(__dirname + '/modules', __dirname + '/lib/node', __dirname);
var connect = require('connect'),
express = require('express'),
sys = require('sys');
var app = new express.Server();
// expectation : will be run after the more general app.all().
app.get('/foo', function(req, res, next) {
var app = require('common').app,
common = require('common'),
db = require('common').db,
io = require('common').socket,
//form = require('common').form;
formidable = require('formidable'),
util = require('util'),
fs = require('fs');
// Underscore mixing for partial functions and async calls.
// Based on this microsoft post: http://msdn.microsoft.com/en-us/scriptjunkie/gg575560
_.mixin({
// Turn a normal function into an asynchronous version.
// It will return a function that expect's the last argument
// to be a callback expecting (err, result) as arguments.
wrapAsync: function(fn) {
return function() {
var args = _(arguments).toArray();
@AdrianRossouw
AdrianRossouw / async.rm.js
Created January 17, 2012 23:32
side-by-side of async versus step recursive file delete
function rmTree(filepath, next) {
function _joinPath(f) { return path.join(filepath, f); }
var recurseFns = [
async.apply(fs.readdir, filepath),
function(files, next) { next(null, _(files).toArray()); },
function(files, next) { next(null, _(files).map(_joinPath)); },
function(files, next) { async.forEachSeries(files, rmTree, next); },
async.apply(fs.rmdir, filepath)
// global var for illustration
var models = window.models = {};
// create a new model for tweets
models.Tweets = Backbone.Collection.extend({
// fetches from twitter.com
url: 'http://twitter.com/status/user_timeline/AdrianRossouw.json',
});
For those folks not already hanging out in #documentcloud... here's the log of this afternoon's Ember/Backbone politics discussion.
12:21 PM <wycats> jashkenas: hey
12:21 PM <wycats> jashkenas: I'm sorry
12:21 PM <wycats> how would you like me to describe backbone?
12:21 PM <wycats> let's work this out for once and for all :)
12:21 PM <wycats> I'm definitely not intentionally saying incorrect things about backbone
12:22 PM • knowtheory gets out popcorn
12:24 PM <jashkenas> don't worry about it too much -- I'm just not terribly pleased with backbone being continued to be used as the strawman...
12:24 PM <wycats> jashkenas: I am worried about it a lot