Skip to content

Instantly share code, notes, and snippets.

@distracteddev
distracteddev / trace.txt
Created July 18, 2012 22:12
jitsu databases list error
/usr/local/lib/node_modules/jitsu/lib/jitsu/commands/databases.js:181
results.forEach(function (database) {
^
TypeError: Object #<Object> has no method 'forEach'
at /usr/local/lib/node_modules/jitsu/lib/jitsu/commands/databases.js:181:15
at /usr/local/lib/node_modules/jitsu/node_modules/nodejitsu-api/lib/client/databases.js:56:5
at Request._callback (/usr/local/lib/node_modules/jitsu/node_modules/nodejitsu-api/lib/client/client.js:109:5)
at Request.callback (/usr/local/lib/node_modules/jitsu/node_modules/nodejitsu-api/node_modules/request/main.js:104:22)
at Request.<anonymous> (/usr/local/lib/node_modules/jitsu/node_modules/nodejitsu-api/node_modules/request/main.js:458:18)
at Request.emit (events.js:67:17)
@distracteddev
distracteddev / uninstall.sh
Created July 18, 2012 16:49
Uninstall Node.js - OSX
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do  sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
@distracteddev
distracteddev / connection.js
Created July 16, 2012 22:39
Connect to a redisToGo instance (Heroku or Nodejitsu
// To get a Redis URL provided by Nodejitsu run the following in your terminal:
// $ jitsu databases create redis [name_of_database]
//
// This will output a message with your new Redis' instance URL. Copy/Paste it below:
var REDIS_URL = process.env.REDISTOGO_URL // REPLACE THIS WITH YOUR URL PROVIDED BY THE JITSU CLI
var Resourceful = require('resourceful-redis')
, url = require('url');
// A function helper to connect to redis using Heroku's redis url
@distracteddev
distracteddev / request.js
Created May 10, 2012 23:31
A Modification to the Node.js Passport module that looks for flatiron/union and binds the request functions onto the appropriate object.
/**
* Module dependencies.
*/
// If flatiron/union is being used, then bind the following
// functions to the RoutingStream Prototype
try {
var union = require('union')
, req = union.RoutingStream.prototype;
}
@distracteddev
distracteddev / dateHelper.handlebars.js
Created May 6, 2012 01:17
Handlebars Date Helper that doesn't require an array of Months and leverages Date()'s native Localization
Ember.Handlebars.registerHelper('date', function(path, options) {
date = options.contexts[0].get(path);
dateArray = date.toLocaleDateString().split(', ');
day = date.getDate() + '. ';
// Gets the name of the month form the locaized date string
// (A Nice trick to avoid using your own localized date-month maps)
month = dateArray.splice(1)[0].split(' ')[0] + ' ';
year = 1900 + date.getYear();
return month + day + year;
});
@distracteddev
distracteddev / SafeClone.js
Created April 29, 2012 18:54
SafeClone to for jQuery UI so that it plays nice with Ember.js
$.fn.extend({
safeClone: function() {
var clone;
clone = $(this).clone();
clone.find('script[id^=metamorph]').remove();
clone.find('*').each(function() {
var $this;
$this = $(this);
return $.each($this[0].attributes, function(index, attr) {
if (attr.name.indexOf('data-bindattr') === -1) {
@distracteddev
distracteddev / thanksforhelping.md
Created April 15, 2012 04:33
A Resourceful.js Question
@distracteddev
distracteddev / index.js
Created April 15, 2012 04:18
A Node.js/Director route function
exports.getTags = function () {
var self = this;
BlogPost.tagFilter(function(err, tags) {
if (err) throw err;
console.log(tags);
self.res.end(JSON.stringify(tags));
});
};
@distracteddev
distracteddev / index.js
Created April 15, 2012 04:13
Example of a Resourceful.js Model with a custom MapReduce Filter
var Resourceful = require('resourceful');
var tagFilter = {
map: function (post) {
post.tags.forEach(function (tag) {
emit(tag, 1);
});
},
reduce: function(keys, values) {
class About(Page):
header = models.TextField("Header Text")
offer = models.TextField("Offer Text")
testimonial = RichTextField(_("Testimonial"))
curriculum = models.TextField("Curriculum")
languageCenters = models.TextField("Language Centers")
dailySchedule = models.TextField("Daily Schedule")
image1 = models.ImageField(upload_to='about')
image2 = models.ImageField(upload_to='about')
image3 = models.ImageField(upload_to='about')