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
-- 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
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
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
const Joi = require('joi'); | |
const util = require('util'); | |
const schema = Joi.object().keys({ | |
a: Joi.number().meta('bad a'), | |
b: Joi.number().meta('bad b') | |
}).error(errs => { | |
let obj = { }; | |
errs.forEach(err => { | |
obj[err.path] = Joi.reach(schema, err.path).describe().meta[0]; |
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 Joi = require('joi'); | |
const schema = { | |
a: Joi.number(), | |
b: Joi.number(), | |
}; | |
const value = { | |
a: 'AAA', | |
b: "BBB" |
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 schema = Joi.object().keys({ | |
isRegister: Joi.any(), | |
username: Joi.string(), | |
password: Joi.string(), | |
email: Joi.string() | |
}).with('isRegister', 'username', 'password'); | |
app.post('/register', function (req, res) { | |
const isValid = schema.validate(Object.assign({ isRegister: true }, req.params)); | |
}); |
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 resource = app.swag.createResource('Foo'); | |
resource.get('/foo', { | |
name: 'Foos', | |
params: { | |
filter: 'string', | |
itemsPerPage: 'integer' | |
}, | |
returns: 'SomeModel' //models are declared elsewhere/separately | |
}, function (req, res) { |
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
// values 0 through 6 represent tetris pieces | |
// heap[1] is always the piece that has been seen the | |
// fewest number of times (or is tied with it) | |
heap = [unused, 0, 1, 2, 3, 4, 5, 6] | |
update(piece_id) { | |
// find the piece to update | |
for (ptr = 1; ptr <= 8; ptr++) { | |
if (heap[ptr] & 0x07 == piece_id) break; | |
} | |
if (ptr == 8) { |
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
penguinfrk: 2309, | |
Chew: 2236, | |
piper: 2215, | |
goonerJimmy: 2180, | |
Chopin: 2173, | |
Blitz: 2137, | |
JuhuarKnight: 2072, | |
shinanai: 2069, | |
be_f: 2032, | |
sonic: 2002, |