Skip to content

Instantly share code, notes, and snippets.

View johannesboyne's full-sized avatar
👨‍💻
Building.

Johannes Boyne johannesboyne

👨‍💻
Building.
View GitHub Profile
@johannesboyne
johannesboyne / mochacairaw_test.html
Last active December 10, 2015 22:48
mochaPhantomJS mocha chai raw test file (html)
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="mocha.css" />
<!--<script src="../libs/jquery/jquery.min.js"></script>-->
<!--<script src="../libs/moment/min/moment.min.js"></script>-->
<!--<script src="../libs/underscore/underscore-min.js"></script>-->
<!--<script src="../libs/backbone/backbone-min.js"></script>-->
<!--<script src="../libs/easeljs-0.5.0.min.js"></script>-->
</head>
(function(){function require(p){var path=require.resolve(p),mod=require.modules[path];if(!mod)throw new Error('failed to require "'+p+'"');if(!mod.exports){mod.exports={};mod.call(mod.exports,mod,mod.exports,require.relative(path))}return mod.exports}require.modules={};require.resolve=function(path){var orig=path,reg=path+".js",index=path+"/index.js";return require.modules[reg]&&reg||require.modules[index]&&index||orig};require.register=function(path,fn){require.modules[path]=fn};require.relative=function(parent){return function(p){if("."!=p.charAt(0))return require(p);var path=parent.split("/"),segs=p.split("/");path.pop();for(var i=0;i<segs.length;i++){var seg=segs[i];if(".."==seg)path.pop();else if("."!=seg)path.push(seg)}return require(path.join("/"))}};require.register("browser/debug.js",function(module,exports,require){module.exports=function(type){return function(){}}});require.register("browser/diff.js",function(module,exports,require){var JsDiff=function(){function clonePath(path){return{newPos:path.
@johannesboyne
johannesboyne / test.js
Last active December 10, 2015 22:48
sample test file
describe('Array', function(){
describe('#indexOf()', function(){
it('should return -1 when the value is not present', function(){
assert.equal(-1, [1,2,3].indexOf(5));
assert.equal(-1, [1,2,3].indexOf(0));
});
});
});
@johannesboyne
johannesboyne / fieldHider.js
Created February 5, 2013 16:04
Dynamic field/attribute hiding from an object. (I named it fieldHider because we used it to hide mongodb results)
// this is used to work in Node.js
// if you want to use it inside the browser, replace the map function to ensure older browser support.
// DEPENDENCIES: underscore!
function omitFields (model, hidden_fields) {
var hider_code = 'return _.omit(model';
hidden_fields.map(function (hider) {
hider_code += ', \''+hider+'\'';
});
hider_code += ');';
@johannesboyne
johannesboyne / pointInPolygonTest.js
Created May 22, 2013 09:04
Test whether a point lies inside a polygon
// borrowd from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
function pnpoly (points, test) {
var i, j, c = false;
for( i = 0, j = points.length-1; i < points.length; j = i++ ) {
if( ( ( points[i].y > test.y ) != ( points[j].y > test.y ) ) &&
( test.x < ( points[j].x - points[i].x ) * ( test.y - points[i].y ) / ( points[j].y - points[i].y ) + points[i].x ) ) {
c = !c;
}
}
return c;
{
"name" : basename.replace(/^node-/, ''),
"version" : "0.0.0",
"description" : prompt('description, what are you working on?', ''),
"main" : prompt('entry point', 'index.js'),
"bin" : function (cb) {
var path = require('path');
var fs = require('fs');
var exists = fs.exists || path.exists;
exists('bin/cmd.js', function (ex) {
{
"do you want to use browserify? (Y/n) ": {
"dependencies": {
"browserify": "~2.35.2",
"uglifyjs": "~2.3.6"
},
"scripts": {
"build-js": "browserify browser/main.js | uglifyjs -mc > static/bundle.js"
},
"default": true
{
"name": "<NAME>",
"version": "<VERSION>",
"description": "<DESCRIPTION>",
"main": "<START>",
"bin": {},
"directories": {
"example": "example",
"test": "test"
},
// User
// ====
var UserSchema = mongoose.Schema({
username: String,
email: String,
salt: String,
hashed_password: String,
orgas: [{type: mongoose.Schema.ObjectId, ref: 'Organization'}]
});