This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Foo(bar) { | |
this.state = bar; | |
} | |
Foo.prototype.doStuff = function(baz) { | |
this.state = baz; | |
}; | |
Foo.prototype.getStuff = function () { | |
return this.state; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var queue = [], | |
output = []; | |
function add(args) { | |
queue.push(args); | |
} | |
function delay(n) { | |
return new Promise(function (resolve) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- starting pieces is 100, 250, or 1000 | |
-- randomizer_id has 3 values | |
-- perfect_clears could be 0-10 for 100 pieces, 0-100 for 1000 pieces | |
SELECT r1.game_id, users.user_name, r1.perfect_clears, r1.time_taken, | |
DATE(r1.timestamp) set_on, (replays.record IS NOT NULL) as has_replay | |
FROM pcb_records r1 | |
LEFT OUTER JOIN pcb_records r2 | |
ON (? OR r2.timestamp >= NOW() - INTERVAL ? DAY) | |
AND r2.user_id = r1.user_id | |
AND r2.starting_pieces = r1.starting_pieces |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { cloneElement, Children, Component } from 'react'; | |
// Adds sticky scrolling to some react component or element; usage: | |
// <ScrollLocked><whatever></ScrollLocked> | |
class ScrollLocked extends Component { | |
constructor(props) { | |
super(props); | |
this.el = null; | |
this.locked = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;wumpus 1.0 | |
;myndzi - 6/5/2006 | |
on *:text:!wumpus:*:wump $nick $fulladdress | |
on me:*:join:#wumpus:%wumpuscid = $cid | |
on *:start:wumplisten | cave1 | |
alias wumplisten { | |
if ($sock(wumpus_l)) sockclose wumpus_l | |
socklisten -dp 0.0.0.0 wumpus_l 2421 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validate(schema) { | |
return function (req, res, next) { | |
// assuming joi callback style validation | |
schema.validate(req.params, schema, function (err, coercedParams) { | |
if (err) { next(err); return; } // if you want to handle errors with middleware | |
// if (err) { req.params = null; req.validationError = err; } // if you want to handle it in your route | |
else { req.params = coercedParams; } // replacing req.params with the validated/coerced version | |
next(); | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Promise = require("bluebird"); | |
const fs = Promise.promisifyAll(require('fs')) | |
const getNumbers = () => new Promise((resolve, reject) => { | |
var fileNumbers = []; | |
for(var n = 0; n < 10; n++){ | |
fileNumbers.push(n); | |
} | |
resolve(fileNumbers); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Promise = require("bluebird"); | |
const fs = Promise.promisifyAll(require('fs')) | |
function getNumbers() { | |
var fileNumbers = []; | |
for(var n = 0; n < 10; n++){ | |
fileNumbers.push(n); | |
} | |
return fileNumbers; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var WINDOW = Math.pow(2,11)-1; | |
function time() { | |
var hrtime = process.hrtime(); | |
return (hrtime[0] * 1e3) + ((hrtime[1] / 1e6)|0); | |
} | |
function setPedanticInterval(cb, ival) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function testKick(kickArr, matrix) { | |
let ptr = 0; | |
let numTests = 0; | |
let aLen = kickArr.length; | |
outer: while (ptr < aLen) { | |
numTests = kickArr[ptr++]; | |
while (numTests-- > 0) { | |
if (matrix.has(kickArr[ptr++])) { | |
if (kickArr[ptr] <= ptr) { return 0; } |