Skip to content

Instantly share code, notes, and snippets.

View mikermcneil's full-sized avatar
🦢

Mike McNeil mikermcneil

🦢
View GitHub Profile
@mikermcneil
mikermcneil / Balderdash Style Guide.md
Last active December 11, 2015 01:19
Balderdash Style Guide

Balderdash Style Guide

The following is our development style guide. We put this together as a handy reference on how we write our code. We work on lots of projects, and using conventions offers advantages to everyone working with the code base. Writing new code is faster, maintaining old code is easier, and iterative feature development happens faster with consistent development styles used by everyone.

Even after agreeing on this guide, we've all been guilty of delighting in a bit of forbidden fruit. It's out of habit. It's not a big deal, let's just try to move towards standards as quickly as we can. In the mean time, if we see code that doesn't match up, and we have time, let's fix it.

As usual, feel free to pipe up with ideas and errata. That said, let's avoid religious wars and subjective rules-- everything below is here for a reason, and we want everybody on board with the why. Following rules without knowing why they exist is stupid. The goal is to make our code cleaner, our developm

@mikermcneil
mikermcneil / Installing Sails on a blank-slate ubuntu server
Last active June 22, 2017 07:08
Installing Node.js, Sails, and other goodies on a blank-slate Ubuntu instance
# Install Node.js and friends
# (From https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager)
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm nodejs-dev
# Install other tools we like
sudo apt-get install git emacs
@mikermcneil
mikermcneil / Sails controller roadmap.js
Last active December 14, 2015 00:49
What do you think of:
// UserController.js
module.exports = {
// The new way
test1: function() {
// contexual access to params
// (this is probably the most valuable piece-- normalizes stuff between req.params, req.query, req.body, and socket.io)
this.name;
@mikermcneil
mikermcneil / why_nodejs.md
Last active December 14, 2015 02:59
Balderdash's Answer to "Why Node.js?"

Balderdash's Answer to "Why Node.js?"

For the chip/performance guys

Node.js is built on Google's V8 and C libraries. Here's Ryan Dahl's famous presentation about how he built Node.js

http://www.youtube.com/watch?v=jo_B4LTHi3I

From the business side

@mikermcneil
mikermcneil / commonjs.md
Created February 23, 2013 06:55
How commonjs works in the context of node.js

Gabe if you module.expoerts = {} you can use that objects methods and properties whereever you require it?

Mike

// foo.js
module.exports = {
 baz: 'hi'
};
@mikermcneil
mikermcneil / SessionController.js
Created February 26, 2013 18:18
Simplistic login example for Sails
/*---------------------
:: Session
-> controller
---------------------*/
var SessionController = {
login: function(req, res) {
// Get password and username from request
var username = req.param('username');
@mikermcneil
mikermcneil / streaming-orm.js
Last active December 14, 2015 09:19
sample of what a streaming orm might look like. Includes prefix and suffix support.
//////////////////////////////////////////
// Dam
//////////////////////////////////////////
// Simple transformer stream
// Allows for custom iterator, prefix, and suffix
// Set readable and writable in constructor.
// Inherit from base stream class.
var Dam = function(options) {
@mikermcneil
mikermcneil / async-example-sails.js
Created March 2, 2013 00:28
async-example-sails.js
var gameId = 7;
async.auto({
game: Game.find(gameId).done,
reviews: Review.findAllByGameId(gameId).done
}, function (err, results) {
var response = {
id: results.game.id,
@mikermcneil
mikermcneil / stream-to-file.js
Created March 12, 2013 06:18
stream from a url to a file
var fs = require('fs');
var knox = require('knox');
var request = require('request');
var uri = "https://lh4.ggpht.com/N5f6FA5zPjrTH-UggaFLstYSO1za-01CbsO17ZwkghtF0k9TSzWcnCn4bybCDeIOP4cu=w124";
// Open download stream from google
var downStream = request(uri);
var fs = require('fs');
var knox = require('knox');
var request = require('request');
var uri = "https://lh4.ggpht.com/N5f6FA5zPjrTH-UggaFLstYSO1za-01CbsO17ZwkghtF0k9TSzWcnCn4bybCDeIOP4cu=w124";
// Open download stream from google
var downStream = request(uri);