Skip to content

Instantly share code, notes, and snippets.

View joemccann's full-sized avatar
💭
Thinking

Joe McCann joemccann

💭
Thinking
View GitHub Profile
@joemccann
joemccann / server.js
Created November 17, 2011 21:24
cluster setup
var cluster = require('cluster');
var app = require('./app');
// Comment this out:
// var server = cluster(app)
// .use(cluster.pidfiles())
// .use(cluster.cli())
// .use(cluster.stats())
// .use(cluster.repl('/var/run/colab-rest-api.sock'));
@joemccann
joemccann / wtf.js
Created November 16, 2011 23:01
express cluster
if (cluster.isMaster){
// Fork workers.
for (var i = 0; i < 2; i++) {
cluster.fork()
}
console.log('Forked ' + numCPUs + ' workers.')
cluster.on('death', function(worker) {
// we need to spin back up on death
@joemccann
joemccann / addCommand.js
Created November 12, 2011 16:31
Ace Editor Add Command Fail
function bindKeyboard(){
// CMD+s TO SAVE DOC
var command = {
name: "save",
bindKey: {
mac: "Command-S",
win: "Ctrl-S"
},
exec: function(){
@joemccann
joemccann / test.js
Created November 9, 2011 19:18
MongoDB Primary Failover fix
var mongoose = require('mongoose')
, Server = require('mongodb').Server
, ReplSetServers = require('mongodb').ReplSetServers
, http = require('http')
var set = 'mongodb://cihcisdapp809v:27077,mongodb://cihcisdapp809v:37077'
// https://github.com/christkv/node-mongodb-native/blob/master/lib/mongodb/connections/repl_set_servers.js#L32
var replSet = new ReplSetServers([
new Server( 'mongodb://cihcisdapp809v', 27077, { auto_reconnect: true } ),
@joemccann
joemccann / javascript_will_listen.md
Created October 1, 2011 08:54
JavaScript Will Listen - By Bella Morningstar

I wouldn't be so alone

If my Github followers lived in my home

Alex Russell would send a pull request

But I'd be too busy

Return to San Francisco by nine

@joemccann
joemccann / vintage.js
Created August 21, 2011 22:04
vintage javascript filter
/**
* vintageJS is a jQuery plugin that uses the HTML5 canvas element to add a vintage look to images
*
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* Built on top of the jQuery library
* http://jquery.com
*
*
@joemccann
joemccann / nginx.conf
Created August 7, 2011 12:26
nginx rev-proxy for serverfault
server {
listen 80;
server_name subprint.com;
access_log /var/www/subprint/logs/access.log;
error_log /var/www/subprint/logs/error.log;
root /var/www/subprint/server/public; # express serves static resources for subprint.com out of here
location / {
@joemccann
joemccann / code.js
Created July 19, 2011 08:31
Sample code.js file for client side scripting for Express app.
!function(d,w){
var debug = true
/*
* @desc Lose the URL bar for mobile version by sliding screen up.
* @return void
*/
function scrollUp(delay){
@joemccann
joemccann / smoosh.json
Created July 19, 2011 08:29
Sample smoosh config for Express app
{
"VERSION": "0.0.1",
"JSHINT_OPTS": { "browser": true },
"JAVASCRIPT": {
"DIST_DIR": "./public/js",
"code": [ "./public/js/code.js"]
},
"CSS": {
"DIST_DIR": "./public/css",
"style": ["./public/css/style.css"]
@joemccann
joemccann / index.ejs
Created July 19, 2011 08:26
Sample index.ejs file for Express App
<div id="main">
</div>