Skip to content

Instantly share code, notes, and snippets.

View myndzi's full-sized avatar

Kris Reeves myndzi

  • Sigma Bold
  • Olympia, WA
View GitHub Profile
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;
@myndzi
myndzi / .sql
Last active July 7, 2017 04:28
-- 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
var queue = [],
output = [];
function add(args) {
queue.push(args);
}
function delay(n) {
return new Promise(function (resolve) {
function Foo(bar) {
this.state = bar;
}
Foo.prototype.doStuff = function(baz) {
this.state = baz;
};
Foo.prototype.getStuff = function () {
return this.state;
};
@myndzi
myndzi / .js
Last active May 19, 2017 02:17
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];
const Joi = require('joi');
const schema = {
a: Joi.number(),
b: Joi.number(),
};
const value = {
a: 'AAA',
b: "BBB"
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));
});
@myndzi
myndzi / .js
Last active May 14, 2017 20:03
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) {
// 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) {
penguinfrk: 2309,
Chew: 2236,
piper: 2215,
goonerJimmy: 2180,
Chopin: 2173,
Blitz: 2137,
JuhuarKnight: 2072,
shinanai: 2069,
be_f: 2032,
sonic: 2002,