Skip to content

Instantly share code, notes, and snippets.

View kmiyashiro's full-sized avatar
🐻

Kelly Miyashiro kmiyashiro

🐻
  • San Francisco, CA
View GitHub Profile
/**
* Module dependencies.
*/
var express = require('express'),
fs = require('fs');
var app = module.exports = express.createServer();
var port = (app.settings.env == 'test') ? 8000 : 3001;
// Calls done when db is finished connecting
exports.dbReady = function(done) {
var db = require('../../models/db');
switch (db.state) {
case 'connected':
done();
break;
case 'connecting':
db.once('open', done);
@kmiyashiro
kmiyashiro / admin.html
Created May 10, 2012 21:02
Mocha HTML spec
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="../libs/mocha.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div id="mocha"></div>
<script src="../libs/mocha.js" type="text/javascript" charset="utf-8"></script>
@kmiyashiro
kmiyashiro / CleanView.js
Created April 7, 2012 22:32
Backbone wrapper
/**
* Extend Backbone.View to have a "close" function.
* Unbind all triggers and events.
* Save an array of all bound events to unbind
* Define onClose on views to clean up model/collection listeners
*/
define(function(require) {
var Backbone = require('use!libs/backbone/backbone'),
_ = require('use!underscore');
@kmiyashiro
kmiyashiro / grunt.js
Created March 12, 2012 21:16
mote grunt task
/*global config:true, task:true*/
config.init({
options: {
templates: {
namespace: "tmpl",
dir: 'templates'
}
},
pkg: '<json:package.json>',
test: {
@kmiyashiro
kmiyashiro / gist:2013589
Created March 10, 2012 22:17
Upsert nested array/objects possible?
I have a schema that looks like this:
band: {
albums: [
{ tweets: [
{ tweet }, { tweet }
] }
]
}
I want to add the band (doc) if it doesn't exist.
@kmiyashiro
kmiyashiro / MyView.js
Created February 6, 2012 18:06
Auto re-use element?
checkExisting: function() {
var existing = $(this.id)[0];
if (existing) this.setElement(existing);
}}
@kmiyashiro
kmiyashiro / locations
Created January 16, 2012 07:05
test file
js
model
user.js
test
test.js
Error: Calling node's require("model/user") failed with error: Error: Cannot find module 'model/user'
({
appDir: "../js",
baseUrl: "./",
dir: "../js-deploy",
//Comment out the optimize line if you want
//the code minified by UglifyJS
optimize: "none",
paths: {
'app' : 'app',
@kmiyashiro
kmiyashiro / gist:1495695
Created December 19, 2011 06:24
backbone simple
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Page Title</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://documentcloud.github.com/underscore/underscore-min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://documentcloud.github.com/backbone/backbone-min.js" type="text/javascript" charset="utf-8"></script>
</head>