Skip to content

Instantly share code, notes, and snippets.

View abrkn's full-sized avatar

Andreas Brekken abrkn

View GitHub Profile
var async = require('async');
module.exports = function(config) {
var group = {
name: 'Search Indexer',
tasks: []
};
group.tasks.push(task = {
group: group.name,
describe('post /impressions/add', function() {
it('succeeds', function() {
var inputs = {
link: 'link' + Math.floor(Math.random() * 1000),
user: 'user' + Math.floor(Math.random() * 1000),
seconds: Math.floor(Math.random() * 1000)
};
var impressionsStub = sinon.stub(impressions, 'add', function(db, user, link, facts, callback) {
debug('stub add called');
@abrkn
abrkn / gist:2864350
Created June 3, 2012 17:49
Mocha + Sinon + Expect.js
describe('addHandler', function() {
it('parses request and calls api', function() {
var values = {
link: 'link' + Math.floor(Math.random() * 1000),
user: 'user' + Math.floor(Math.random() * 1000),
seconds: Math.floor(Math.random() * 1000)
};
// setup
var impressionsMock = sinon.mock(impressions);
[root@vidlink ~/apps/striim]# npm install -g forever
npm http GET https://registry.npmjs.org/forever
npm http 304 https://registry.npmjs.org/forever
npm http GET https://registry.npmjs.org/broadway
npm http GET https://registry.npmjs.org/cliff
npm http GET https://github.com/AvianFlu/daemon.node/tarball/master
npm http GET https://registry.npmjs.org/flatiron
npm http GET https://registry.npmjs.org/microtime
npm http GET https://registry.npmjs.org/nconf
npm http GET https://registry.npmjs.org/nssocket
info it worked if it ends with ok
verbose cli [ 'node', '/usr/bin/npm', 'install', '-g', 'daemon' ]
info using npm@1.1.4
info using node@v0.6.17
verbose /usr/local/bin/node node symlink
verbose config file /root/.npmrc
verbose config file /usr/local/etc/npmrc
verbose config file /usr/share/npm/npmrc
silly exec /usr/local/bin/node "/usr/share/npm/bin/npm-get-uid-gid.js" "nobody" 0
silly spawning [ '/usr/local/bin/node',
@abrkn
abrkn / asset-embed.js
Created June 13, 2012 12:47
asset embedding for node.js
var _ = require('underscore');
var fs = require('fs');
var path = require('path');
var debug = require('debug')('asset-embed');
module.exports = function() {
var self = {
loaders: {
less: function(a, callback) {
self.loaders.plain(a, function(err, res) {
@abrkn
abrkn / gist:3755445
Created September 20, 2012 11:44
COFFEE-fied
App.Meta = Backbone.Model.extend(initialize: ->
# Locate tags and find current values.
@$titleTag = $("title")
@$titleTag = $("<title></title>").appendTo($("head")) unless @$titleTag.length
@$descriptionTag = $("meta[name=\"description\"]")
@$descriptionTag = $("<meta name=\"description\" content=\"\" />").appendTo("head") unless @$descriptionTag.length
@attributes.title = window.title or @$titleTag.text()
@attributes.description = @$descriptionTag.attr("content")
@attributes.rendered = false
@abrkn
abrkn / gist:3937698
Created October 23, 2012 08:48
client (browser) side debug logging with socket.io
//not using console.log.apply because of compat *cough*ie*cough* issues)
this.socket.emit = _.wrap(this.socket.emit, function (fn, name, message) {
console.log('-->', name, _.toArray(arguments).slice(2));
return fn.apply(this, _.toArray(arguments).slice(1));
});
this.socket.$emit = _.wrap(this.socket.$emit, function (fn) {
console.log('<--', arguments[1], _.toArray(arguments).slice(2));
return fn.apply(this, _.toArray(arguments).slice(1));
});
this.socket.emit = _.wrap(this.socket.emit, function(fn, name) {
console.log.apply(this, ['-->', socket.id].concat(_.toArray(arguments).slice(1)));
return fn.apply(this, _.toArray(arguments).slice(1));
});