Skip to content

Instantly share code, notes, and snippets.

Ben Ng ben-ng

Block or report user

Report or block ben-ng

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ben-ng
ben-ng / shared.js
Last active Dec 14, 2015
Debugging Logical OR on multiple object IDs
View shared.js
var utils = require('utilities')
, assert = require('assert')
, currentId
, tests
, testItems
, Zooby = require('../fixtures/zooby').Zooby
, User = require('../fixtures/user').User
, Profile = require('../fixtures/profile').Profile
, Account = require('../fixtures/account').Account;
@ben-ng
ben-ng / gist:5026870
Last active Dec 14, 2015
Standalone models
View gist:5026870
var model = require('model');
var Adapter = require('../node_modules/model/lib/adapters/mongo').Adapter;
var User = require('../app/models/user.js').User;
var Reel = require('../app/models/reel.js').Reel;
var Video = require('../app/models/video.js').Video;
var modelAdapter = new Adapter({
dbname:config.mongo.path,
host:config.mongo.host,
port:config.mongo.port,
@ben-ng
ben-ng / gist:5219464
Created Mar 22, 2013
Test case for offset dates
View gist:5219464
var utils = require('utilities')
, assert = require('assert')
, currentId
, tests
, testItems
, Zooby = require('../fixtures/zooby').Zooby
, User = require('../fixtures/user').User
, Profile = require('../fixtures/profile').Profile
, Account = require('../fixtures/account').Account;
View test-adapters-shared.js
var utils = require('utilities')
, assert = require('assert')
, currentId
, tests
, testItems
, Zooby = require('../fixtures/zooby').Zooby
, User = require('../fixtures/user').User
, Profile = require('../fixtures/profile').Profile
, Account = require('../fixtures/account').Account;
View gist:5223411
User.verifyPassword = function (password, hash, callback) { //You need a callback because bcrypt.compare is async
bcrypt.compare(password, hash, function(err, isMatch) {
callback(err, isMatch);
});
}
//Usage:
exports.User.verifyPassword(password, user.password, function(err, isMatch) {
if(err) {
console.log("Error!");
@ben-ng
ben-ng / BaseModel.js
Created Jun 10, 2013
A short example of integrating Backbone.js with Geddy.js
View BaseModel.js
/*
* Extend your own models from BaseModel from now on
* e.g. `MyApp.Models.Zooby = BaseModel.extend({etc:etc})`;
*
* TODO: Don't forget to override `parse()` in your model.
* It should be something like `return data.modelName;`
* TODO: Don't forget to handle errors! Check data.errors for them.
*/
var BaseModel = Backbone.Model.extend({
methodUrl: function(method) {
@ben-ng
ben-ng / output.txt
Last active Dec 18, 2015
Weird Test
View output.txt
*** Running tests/adapters.js ***
test dummy ctor
test dummy before
test dummy put
A
B
C
D
test dummy get
E
View Jakefile
var build = path.relative(__dirname, '_shared')
, src = path.relative(__dirname, '_shared_sources')
, buildLessFile = path.join(build, 'css', 'styles.css')
, lessFiles = [
"css/video-js.css"
, "css/elastislide.css"
, "css/jquery.fancybox.css"
, "css/jquery.fancybox-buttons.css"
, "css/jquery.fancybox-thumbs.css"
, "css/bootstrap.css"
View git log
MILK:geddy-model omnomnomben$ git log
commit a487945cf187869679e5ef646f2ffff0589a53e6
Merge: 31af941 7a60fca
Author: Matthew Eernisse <mde@fleegix.org>
Date: Sun Jun 30 22:04:35 2013 -0700
Merge pull request #70 from ben-ng/fix-memory-like
Fix memory LIKE & bugfix in mongo
View cmd.js
var assert = require('assert')
, cmd = require('../../lib/cmd')
, Cmd = cmd.Cmd
, tests;
tests = {
'Cmd parseArgs gen app defaults': function () {
console.log("FOO");
var c = new Cmd(['app', 'foo'], {});
assert.equal('gen:app[foo,default,default]', c.jakeTaskName);
You can’t perform that action at this time.