Skip to content

Instantly share code, notes, and snippets.

View albertosouza's full-sized avatar
👨‍🔬
Creating things

Alberto Souza albertosouza

👨‍🔬
Creating things
View GitHub Profile
@mikehostetler
mikehostetler / bootstrap.js
Created June 20, 2014 13:32
Sails powered script
var extend = require('util')._extend;
var async = require('async');
var Waterline = require('../node_modules/sails/node_modules/waterline');
var couchdb = require('sails-couchdb-orm');
var config = require('../config/adapters').adapters.couchdb;
couchdb.config = extend(couchdb.defaults, config);
module.exports = bootstrap;
@hayes
hayes / compound-socket.js
Last active December 10, 2015 18:18
a quick way to get access to compound routing/controllers through socket.io
var sio = require('socket.io');
var fn = function () {};
var http = require('http');
module.exports = function (compound) {
var app = compound.app;
var server = http.createServer(app);
compound.server = server;
var io = compound.io = sio.listen(server);
@mikermcneil
mikermcneil / trying-out-0.9.md
Last active December 19, 2015 09:08
How to try out Sails.js 0.9

Sails v0.9 Preview

Installation

# Install a sneak peek of sails.js v0.9.0 (global install):
sudo npm install -g sails@git://github.com/balderdashy/sails.git#development

# Or, to revert to 0.8.94 (current stable release), you can do:
sudo npm install -g sails@0.8.94
@mikermcneil
mikermcneil / bootstrap-sails-in-memory.js
Last active December 25, 2015 20:38
Programmatic usage of sails (for testing, core testing, scheduled jobs, build scripts, etc.)
// NOTE:
// you may need to grab the latest version of Sails on the v0.10 branch for some of this to work
var sails = require('sails');
// You can do a lot here, but I'll show a few important ones
var options = {
// Completely disable globals (sails, your models, your services, _, async)
globals: false,

Applications of Cognitive Theory in Data Modeling and Software Design

Written as both a refresher course on the mechanics of cognition in human psychology, and as the beginning of a working theory, wherein one might make some deductions from human psychology to broadly advance/improve the design of server software and data models for the industry en masse.

c. Mike McNeil, 2013-2014 All Rights Reserved.

What's the point of this? I think psychology will inevetiably instruct the future of software design, in the same way neurobiology is beginning to impact the hardware engineering industry. >

@tleen
tleen / gist:5109955
Created March 7, 2013 17:30
Format a Javascript Date to RFC-822 datetime using moment.js
var rfc822Date = moment(yourDate).format('ddd, DD MMM YYYY HH:mm:ss ZZ')
@edwardhotchkiss
edwardhotchkiss / graphics_magick_center_image_on_canvas.js
Created October 31, 2012 03:32
Use GM Module (Graphics Magick) for Node.js to center an image on a white background canvas
var gm = require('gm');
var canvasWidth = 248;
var canvasHeight = 389;
gm(__dirname + '/original.jpg').size(function(error, size) {
if (error) {
console.error(error);
@mikermcneil
mikermcneil / plugins_proposal.md
Last active October 19, 2020 08:42
Sails.js v0.9 plugins proposal

A Modest Proposal: Hooks

Sails.js v0.9: Release Cantidate for 1.0

Philosophy

  • The question of what "belongs" in a framework is complex, and depends on your use case. A better question is "what are the defaults?" By pulling all of the current features of Sails into plugins, and then including them by default, we provide full customizability (the possibility of disabling just about everything) without sacrificing all the conveniences Sails developers are used to.
  • Plugins make it easier to contribute, and make modifying the core a much less scary proposition.
  • Node.js is quite minimalist, and super awesome. Let's take a leaf out of Ryan/Isaac's book!
  • Community plugins are fantastic, but to ensure quality, plugins will only be listed on the Sails website/repo when they've met some basic quality assurance testing.
@circa10a
circa10a / easy-soap-request-index.js
Last active May 24, 2021 23:02
easy-soap-request-index.js
const axios = require('axios-https-proxy-fix');
/**
* @author Caleb Lemoine
* @param {object} opts easy-soap-request options
* @param {string} opts.url endpoint URL
* @param {object} opts.headers HTTP headers, can be string or object
* @param {string} opts.xml SOAP envelope, can be read from file or passed as string
* @param {int} opts.timeout Milliseconds before timing out request
* @param {object} opts.proxy Object with proxy configuration

A Modest Proposal: Events

Sails.js v0.10

Events are a new feature of the Sails core as of 0.9.

Core events

Lifecycle