View LazyIteratorChain.kt
// Example
//
// val nodes: List<Iterable<Int>> = listOf(
// listOf(1),
// listOf(2),
// listOf(3)
// )
//
// LazyIteratorChain.fromIterables(nodes).asSequence().toList() == listOf(1, 2, 3)
View test.js
// objective:
// - move pool.query to pool._query
// - redefine pool.query to wrap the original pool.query
pg.Pool.prototype._query = pg.Pool.prototype.query
pg.Pool.prototype.query = wrapper(async function (sql, params) {
return await this._query(sql, params)
})
View sql-tag.js
const $generated = Symbol('$generated')
function sql (strings, ...values) {
let query = ''
strings.forEach((string, i) => {
query += string + (i < values.length ? '$' + (i + 1) : '')
})
query = query.replace(/^\s+/mg, '').trim()
return [$generated, query, values]
}
View grammar.js
Root =
(DiceRoll / Constant)*
Constant
= sign:Sign? value:Integer {
return { type: 'Constant', sign: sign || "+", value, syntax: text() }
}
DiceRoll
= sign:Sign? count:Integer "d" sides:Integer {
return { type: 'DiceRoll', sign: sign || '+', count, sides, syntax: text() }
}
View ip-root.js
// mimic our ip_root sql function
exports.ipRoot = (function () {
const {Address4, Address6} = require('ip-address')
return function (str) {
let ip = new Address6(str)
if (ip.v4 && !ip.valid) {
// it is v4
ip = new Address4(str)
return Address4.fromInteger(Number.parseInt(_.padEnd(ip.mask(24), 32, '0'), 2)).correctForm()
}
View FloodGate.js
// DEMO
const gate = new FloodGate()
socket.on('new_message', (text, cb) => {
// bail if user is spamming us
if (gate.bump(socket.ip).isFlooding(socket.ip)) {
return cb('RATE_LIMITED')
}
View portrace-output
(574.0, 679.0)
(574.0, 664.0)
(558.0, 664.0)
(542.0, 664.0)
(542.0, 648.0)
(542.0, 632.0)
(526.5, 632.0)
(511.0, 632.0)
(511.0, 648.0)
(511.0, 664.0)
View map.txt
.............................◢XXXXXXXXXXXXXXXXXXXX◣..............................
.............................X....................X..............................
................◢XXXXXXXXXXXXX....................XXXXXXXXXXXXXX◣................
...............◢◤............X....................X.............◥◣...............
..............◢◤.............X....................X..............◥◣..............
.............◢◤..............X......XXXXXXXXX.....X...............◥◣.............
.............X...............X..>.......X..........................X.............
.............X..........................X..........................X.............
.............X.......X..................X..................X.......X.............
.............X.......X.....................................X.......X.............
View app.js
var PIXI = require('pixi.js')
console.log(PIXI)
View withTransaction.js
function rollback (conn, cb) {
conn.query('ROLLBACK', function (err) {
if (err) {
console.log('Rollback failed');
// need to remove conn from the pool
return cb(err);
}
return cb();
})