Skip to content

Instantly share code, notes, and snippets.

@fluffywaffles
fluffywaffles / main.js
Created March 10, 2015 01:19
The Superroute!
var router = express.Router()
, Response = require('../models/response.js');
// NOTE(jordan): LET'S BUILD TEH SUPERROUTE
router.get('/:program/:pfilter?/:endpoint/:efilter?/:action?', function(req, res) {
// NOTE(jordan): so many optional parameters!!!
var program = req.params.program
, pfilter = req.params.pfilter
, endpoint = req.params.endpoint
/** USAGE(jordan, 8/19/15):
*
* // NOTE: StackLogger combines each stacked message with newlines.
*
* var _error = ErrorStackLogger('My Error Generating Class has an Error:');
* // or, equivalently:
* var _error = StackLogger('error', 'My Error Generating Class has an Error:');
*
* _error('Bad input.') // => 'My Error Generating Class has an Error:'
* // ' Bad input.'
router.post('/signup', function (req, res, next) {
passport.authenticate('whatever', function () {
console.log('passport custom callback!');
console.log(arguments);
res.send();
})(req, res, next)
});
var T = [
[ 1, 2, 3 ],
[ 2, 2, 2 ],
[ 3, 2, 1 ]
]
var symbols = [ 1, 2, 3 ]
function translateToProduct (k, i, ps) {
// Array.sort(byVolume)
function byVolume (a, b) {
va = a[0] + a[1] + a[2]
vb = b[0] + b[1] + b[2]
if (va > vb)
return -1
else if (vb > va)
return 1
return 0
}
// Array.sort(byVolume)
function byVolume (a, b) {
va = a[0] + a[1] + a[2]
vb = b[0] + b[1] + b[2]
if (va > vb)
return -1
else if (vb > va)
return 1
return 0
}
@fluffywaffles
fluffywaffles / todo.sh
Created February 24, 2016 17:27
fucking broken because bash is the worst scripting language
alias cgrep="grep --color=always"
todo () {
echo "$1 $2"
local cmd="ghi"
local end="-- skorlir/todo"
if [ "$1" = "--help" ] || [ "$1" = "help" ]; then
echo $(sed 's/ {2,}//g' << EOC
server {
listen 80;
server_name _;
access_log /var/log/nginx/access.log;
# send requests matching ~ with .php extension to /usr/share/nginx/www
# handle with fastcgi
location ~ \.php$ {
root /usr/share/nginx/www;
fastcgi_pass 127.0.0.1:9000;
@fluffywaffles
fluffywaffles / gist:9f5367f9232e4452d22c73e481cb4f7b
Created April 10, 2016 05:57
Blendle js source (mangled, webpack)
This file has been truncated, but you can view the full file.
webpackJsonp([2], {
0: function(e, t, n) {
"use strict";
var i = n(1)["default"];
n(657);
var s = n(5929)
, r = i(s)
, a = n(34)
, o = i(a)
, l = n(25)
var express = require('express')
, app = express();
app.use(express.logger('dev'));
app.use(express.static(__dirname + "/dist"));
app.listen(process.env.PORT || 5000);