Skip to content

Instantly share code, notes, and snippets.

View tanepiper's full-sized avatar

Tane Piper tanepiper

View GitHub Profile
/Users/tanepiper/work/pebblecode/ad-platform/node_modules/primus/transformer.js:115
res.setHeader('Content-Type', 'text/javascript; charset=utf-8');
^
TypeError: Object #<Object> has no method 'setHeader'
at serve (/Users/tanepiper/work/pebblecode/ad-platform/node_modules/primus/transformer.js:115:9)
at EventEmitter.emit (events.js:98:17)
at request (/Users/tanepiper/work/pebblecode/ad-platform/node_modules/primus/transformer.js:136:55)
at EventEmitter.emit (events.js:106:17)
at internals.Request.log (/Users/tanepiper/work/pebblecode/ad-platform/node_modules/hapi/lib/request.js:218:17)
at new module.exports.internals.Request (/Users/tanepiper/work/pebblecode/ad-platform/node_modules/hapi/lib/request.js:151:10)
@tanepiper
tanepiper / Doesn't Work.js
Created February 28, 2014 11:02
Any ideas?
Listener.prototype.getPeakFrequency = function() {
// Find where to start.
var start = this.freqToIndex(this.options.codec.options.minFreq);
// TODO: use first derivative to find the peaks, and then find the largest peak.
// Just do a max over the set. However this doesn't seem to be reliable
var max = _.max(this.frequencies);
if (max > this.options.peakThreshold) {
return this.indexToFreq(_.indexOf(this.frequencies, max));
}
Instance.db.User = Instance.db.sequelize.define('user', {
email: {
type: Sequelize.STRING,
allowNull: false,
validate: {
isEmail: true
}
},
password: {
type: Sequelize.STRING,
var LocalStrategy = require('passport-local').Strategy;
var Bcrypt = require('bcrypt');
module.exports = function(Instance) {
var plugins = {
yar: {
cookieOptions: {
password: 'adon-platform', // cookie secret
isSecure: false // required for non-https applications
Executing (default): CREATE TABLE IF NOT EXISTS "clients" ("id" SERIAL , "name" VARCHAR(255) NOT NULL, "slug" VARCHAR(20) DEFAULT '', "description" TEXT DEFAULT '', "isActive" BOOLEAN NOT NULL DEFAULT true, "userId" INTEGER REFERENCES "users" ("id") ON DELETE CASCADE, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, PRIMARY KEY ("id"));
Executing (default): CREATE TABLE IF NOT EXISTS "projects" ("id" SERIAL , "name" VARCHAR(255) NOT NULL, "clientId" INTEGER REFERENCES "clients" ("id") ON DELETE CASCADE, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, PRIMARY KEY ("id"));
Executing (default): CREATE TABLE IF NOT EXISTS "campaigns" ("id" SERIAL , "name" VARCHAR(255) NOT NULL, "shortcode" VARCHAR(255), "url" VARCHAR(255), "projectId" INTEGER REFERENCES "projects" ("id") ON DELETE CASCADE, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, "clientId" INTEGER, PRIMARY KEY ("id
var Sequelize = require('sequelize');
var HashID = require('hashids');
module.exports = function(Instance) {
Instance.db.Campaign = Instance.db.sequelize.define('campaign', {
name: {
type: Sequelize.STRING,
allowNull: false
},
> adon-platform@0.0.1 sync /Users/tanepiper/work/pebblecode/adon-platform
> node scripts/sync.js
done
done
done
done
done
done
done
Instance.db.User.sync(function() {
Instance.db.Client.sync(function() {
Instance.db.Project.sync(function() {
Instance.db.Campaign.sync();
})
})
});
Instance.db.Client.find({where: {id: request.params.cid}})
.success(function(client) {
client.updateAttributes(request.payload)
.success(function(client) {
reply(client);
})
.error(function(error) {
reply(error);
});
})
<html>
<head>
<title><%= title %></title>
</head>
<body>
<div class="blog">
<h1><%= title%></h1>
<% blogItems.forEach(function(item) { %>