Skip to content

Instantly share code, notes, and snippets.

@dopa
dopa / moment-mongoose-virtuals.js
Created April 19, 2012 19:27
How to use Moment.js with Mongoose's Virtuals
var moment = require('moment')
, dateMask = 'YYYY-MM-DD';
var MeetingSchema = new Schema({
...
});
MeetingSchema
.virtual('startDate_yyyymmdd')
.get(function () {
@dopa
dopa / gist:2572197
Created May 1, 2012 23:04
memecube-nodejitsu-everyauth-errors
[05/01 15:55:45 PDT] starting step - getRequestToken
[05/01 15:55:45 PDT] ...finished step
[05/01 15:55:46 PDT] starting step - storeRequestToken
[05/01 15:55:46 PDT] /usr/local/src/dopa/memecube/package/node_modules/everyauth/lib/modules/everymodule.js:348
[05/01 15:55:46 PDT] throw err;
[05/01 15:55:46 PDT] ^
[05/01 15:55:46 PDT] TypeError: Cannot read property 'auth' of undefined
[05/01 15:55:46 PDT] at Object._storeRequestToken (/usr/local/src/dopa/memecube/package/node_modules/everyauth/lib/modules/oauth.js:114:21)
[05/01 15:55:46 PDT] at Object.exec (/usr/local/src/dopa/memecube/package/node_modules/everyauth/lib/step.js:47:21)
[05/01 15:55:46 PDT] at /usr/local/src/dopa/memecube/package/node_modules/everyauth/lib/stepSequence.js:26:38
@dopa
dopa / gist:2889830
Created June 7, 2012 16:18
console.log(io.sockets) inside route
{ manager:
{ server:
{ stack: [Object],
connections: 7,
allowHalfOpen: true,
_handle: [Object],
_events: [Object],
httpAllowHalfOpen: false,
cache: [Object],
settings: [Object],
@dopa
dopa / gist:2944964
Created June 17, 2012 16:07
mongoose-auth twitter error
starting step - getRequestToken
...finished step
starting step - storeRequestToken
...finished step
starting step - redirectToProviderAuth
...finished step
starting step - extractTokenAndVerifier
...finished step
starting step - getSession
...finished step
@dopa
dopa / gist:2961510
Created June 20, 2012 18:46
memecube server.js
/*jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, strict:false, undef:true, curly:true, node:true, indent:4, maxerr:50, white:false, laxcomma:true, supernew:false */
/*global mongoose */
/*global io */
/*global req */
/*global res */
/*global JSONRES */
var express = require('express')
, conf = require('./conf')
@dopa
dopa / gist:2961517
Created June 20, 2012 18:47
memecube everyauth-loader.js
// https://github.com/bnoguchi/mongoose-auth/blob/master/index.js
var everyauth = require('everyauth');
everyauth.everymodule.configurable({
'User': 'A function that returns the mongoose User model (not Schema).'
});
var Modules = {
everymodule: require('./lib/modules/everymodule')
@dopa
dopa / gist:4734750
Created February 7, 2013 22:17
SimpleForm Bootstrap
<%= simple_form_for @product, :html => { :class => 'form-horizontal' } do |f| %>
<fieldset>
<legend><%= controller.action_name.capitalize %> Product</legend>
<%= f.input :name %>
<%= f.input :price %>
<div class="form-actions">
<%= f.submit nil, :class => 'btn btn-primary' %>
<%= link_to 'Cancel', products_path, :class => 'btn' %>
@dopa
dopa / gist:4980459
Created February 18, 2013 20:35
Localtunnel Troubles 2/18/2013
Shinkansen:rs-api justinschier$ localtunnel -k ~/.ssh/id_rsa.pub 3000
This localtunnel service is brought to you by Twilio.
Port 3000 is now publicly accessible from http://4nhi.localtunnel.com ...
^CShinkansen:rs-api justinschier$ localtunnel -k ~/.ssh/id_rsa.pub 3000
[Error] Unable to register tunnel. Perhaps service is down?
Shinkansen:rs-api justinschier$ localtunnel -k ~/.ssh/id_rsa.pub 3000
[Error] Unable to register tunnel. Perhaps service is down?
Shinkansen:rs-api justinschier$ date
Mon Feb 18 15:33:41 EST 2013
Shinkansen:rs-api justinschier$ localtunnel -k ~/.ssh/id_rsa.pub 3000
@dopa
dopa / gist:5025526
Last active December 14, 2015 04:08
Dopa Monit Config File
###############################################################################
## Monit control file
###############################################################################
##
## Comments begin with a '#' and extend through the end of the line. Keywords
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
##
## Below you will find examples of some frequently used statements. For
## information about the control file and a complete list of statements and
## options, please have a look in the Monit manual.
@dopa
dopa / gist:5040472
Last active December 14, 2015 06:09
Rails 3 Passenger NGINX Site Config
# www to non-www redirect -- duplicate content is BAD:
# https://github.com/h5bp/html5-boilerplate/blob/5370479476dceae7cc3ea105946536d6bc0ee468/.htaccess#L362
# Choose between www and non-www, listen on the *wrong* one and redirect to
# the right one -- http://wiki.nginx.org/Pitfalls#Server_Name
#server {
# don't forget to tell on which port this server listens
# listen 80;
# listen on the www host
# server_name www.example.com;