Skip to content

Instantly share code, notes, and snippets.

var flatiron = require('flatiron'),
resourceful = require('resourceful'),
plates = require('plates'),
path = require('path'),
ecstatic = require('ecstatic'),
app = flatiron.app,
config,
m = {};
@robert52
robert52 / gist:4111865
Created November 19, 2012 16:58
Flatiron and passport authentication
var flatiron = require('flatiron')
, app = module.exports = flatiron.app
, union = require('union')
, connect = require('connect')
, passport = require('passport')
, LocalStrategy = require('passport-local').Strategy;
var Bob = {
id : '1234-5678-9012',
username : 'bob',
@robert52
robert52 / BeGlobal
Last active December 25, 2015 19:09
A small c# wrapper for BeGlobal API requests
using System;
using System.IO;
using System.Net;
using System.Text;
public enum HttpVerb
{
GET,
POST,
PUT,
@robert52
robert52 / server.js
Created November 6, 2013 22:50
Proxy requests between two node.js applications using node-http-proxy
var httpProxy = require('http-proxy');
var fs = require('fs');
var options = {
router : {
'localhost/api': '127.0.0.1:3030/api',
//default route
'localhost/.*': '127.0.0.1:3031'
}
};
var router = new httpProxy.RoutingProxy(options);
@robert52
robert52 / text
Last active September 15, 2015 12:14
List of resources - JavaScript introduction
# reading
http://eloquentjavascript.net/
https://www.codecademy.com/glossary/javascript
https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
http://www.w3schools.com/js/default.asp
# interactive
https://www.codecademy.com/tracks/javascript
// Get process environment or set default environment to development
const ENV = process.env.NODE_ENV || 'development';
const http = require('http');
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
let server;
app.set('root', __dirname);
'use strict';
// Get process environment or set default environment to development
const ENV = process.env.NODE_ENV || 'development';
const http = require('http');
const express = require('express');
const bodyParser = require('body-parser');
const crypto = require('crypto');
const config = require('./config');
@robert52
robert52 / money.model.js
Last active June 18, 2024 00:11
Approaches to create and combine models in mongoose. Document referencing, model composition and many more.
'use strict';
const DEF_CURRENCY = 'USD';
const DEF_SCALE_FACTOR = 100;
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ObjectId = Schema.ObjectId;
const MoneySchema = new Schema({
@robert52
robert52 / module.pattern.dashboard.js
Last active May 20, 2016 11:03
Simple JavaScript module pattern
var DashboardModule = (function () {
var privateVar = 'this is private var';
return {
init: function () {
// some init functionalities
},
bindHandlers: function () {