Opinions are like assholes, every one has got one.
This one is mine.
Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# | |
# Update 7 Oct 2010: | |
# - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
# the WebSocket protocol implementation in the cramp gem does not work | |
# well with Chrome's (newer) WebSocket implementation. | |
# | |
# Requirements: | |
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby |
; | |
(function(exports, undefined) { | |
angular.module('module.Socket', [], function($provide) { | |
$provide.factory('Socket', ['$rootScope', function socketController($rootScope) { | |
var scope = $rootScope.$new() | |
scope.socket = io.connect('/') | |
scope.send = function(message) { | |
try { | |
var m = JSON.stringify(message) |
var express = require('express'), | |
passport = require('passport'), | |
LocalStrategy = require('passport-local').Strategy, | |
connect = require('connect'), | |
http = require('http'), | |
path = require('path'), | |
util = require('util'), | |
fs = require('fs'), | |
redis = require('redis'), | |
cookie = require('cookie'), |
// Short module explanation // Something to gather my thoughts | |
// // I think this looks cool. | |
// | |
module.exports = the_exported_function // Modules are a function. Always. | |
// | |
module.exports.extra = extra // Additional API entry points if | |
module.exports.other = other // desired. | |
// | |
var util = require('util') // Other packages from npm or core | |
var assert = require('assert') // No comma-first due to lots of |
validate = (customer, next)-> | |
console.log 'validating...' | |
#VALIDATE HERE | |
next() | |
insert = (customer, next)-> | |
console.log 'inserting...' | |
# insert into DB (asynchronously of course), and then call... | |
next() |
# The upstream server doesn't need a prefix! no need for wss:// or http:// because nginx will upgrade to http1.1 in the config below | |
upstream yeomanserver { | |
server localhost:3000; | |
} | |
server { | |
listen 443; | |
server_name legionofevil.org; | |
root html; |
// Restify server config here | |
var server = restify.createServer({ | |
name: 'restify-test', | |
version: '1.0.0', | |
}); | |
// ... | |
// Connect config here | |
var connectApp = connect() |
// Based off example code from Hal Robertson | |
// https://github.com/halrobertson/test-restify-passport-facebook | |
// See discussion: https://groups.google.com/forum/?fromgroups#!topic/passportjs/zCz0nXB_gao | |
var restify = require('restify') | |
// config vars | |
var FB_LOGIN_PATH = '/api/facebook_login' | |
var FB_CALLBACK_PATH = '/api/facebook_callback' | |
var FB_APPID = '<<YOUR APPID HERE>>' |
This is a short guide that will teach you the workflows that have been figured out by the voxel.js community for writing node modules + sharing them on NPM and Github. It is assumed that you have a basic understanding of JavaScript, github and the command line (if not you can check out an introduction to git and the command line or learn JS basics from JavaScript for Cats)