Skip to content

Instantly share code, notes, and snippets.

@laser
laser / queinteresante.js
Last active August 29, 2015 14:17
Type Aliases for Object Types as Interfaces
/* @flow */
///////////////////////////////////////////////////////////
// Types and Classes
//
class User {
n: number;
constructor(n) {
this.n = n;
@laser
laser / sigh.js
Last active August 29, 2015 14:17
Putting the "Java" in "JavaScript"
/* @flow */
class User {
n: number;
constructor(n) {
this.n = n;
}
}
class UserDAOIFace {
@laser
laser / wat.js
Last active August 29, 2015 14:16
What do I name these things
function derp(expansions) {
var o = {};
// parse a period-delimited string
// and use the resulting array to
// add keys to an object.
function f1(acc, item) {
f2(acc, item.split('.'));
return acc;
}
@laser
laser / started.md
Last active August 29, 2015 14:16
Gettin' Started

STUFF TO INSTALL

  • heroku toolbelt

TECH STACK

  • AngularJS
  • UIRouter
  • SASS (SCSS)
  • Express
  • Sequelize
  • express-resource
@laser
laser / javascript-validation.md
Last active August 29, 2015 14:14
Composing Continuation-Passing and Direct Style Functions in JavaScript
@laser
laser / secrets.md
Last active August 29, 2015 14:13
Consolidating HipChat, Flowdock, and Google Talk w/Adium

Consolidated Chat Client

You already run too many chat clients. This gist provides you with steps for consolidating Flowdock, HipChat, Google Talk, and IRC communications into Adium.

OTR (Encrypted) Chat Support

Adium also supports OTR communication, so Google and friends can't index your shit and sell your personal secrets to Internet pirates. OTR chat can be done through the following messaging services:

  • Google Talk
  • Facebook Chat
@laser
laser / create-method.md
Last active August 29, 2015 14:13
createMethod

Creating Methods in JavaScript

Creating a (named) method on an object is typically done with an anonymous function expression, e.g.:

$scope.updateWarningLevel = function(warningLevel) {
  $scope.worksheet.warningLevel = warningLevel;
}
@laser
laser / o.js
Created December 31, 2014 18:32
o
function ensure(notOkCode, notOkMessage, response, okFx) {
return function(err) {
if (err) {
response.status(notOkCode).json({"message": notOkMessage});
}
else {
okFx.apply(okFx, Array.prototype.slice.call(arguments, 1));
}
};
}
@laser
laser / n.js
Created December 31, 2014 18:32
n
expressRouter.get("/api/ledgers/:id", function(req, res) {
UserService.getLedgerById(req.params.id, function(err, ledger) {
if (err) {
res.status(404).json({"message": "Not Found"});
}
else {
res.status(200).json(ledger);
}
});
});
@laser
laser / m.js
Created December 31, 2014 18:32
m
function createAccount(email, password, done) {
var id = uuid();
async.waterfall([
_.partial(Services.Accounts.provision, email, password),
_.partial(Services.Notification.confirm, email)
],
_.partial(done, _, id, _));
}