I hereby claim:
- I am alenaksu on github.
- I am alenaksu (https://keybase.io/alenaksu) on keybase.
- I have a public key ASCDJ8C2NWmHdBP3cDwzEEGpBDeVbDZoqS5rbXc3CTXWBgo
To claim this, I am signing this object:
{ | |
"server": { | |
"maxConnections": 100, | |
"host": "0.0.0.0", | |
"port": 10000 | |
}, | |
"chat": { | |
"messageLength": 150, | |
"messages": { | |
"welcome": "Welcome to chat server. Press CTRL+C to leave.", |
export const flat = arr => { | |
// Create a copy of the original array | |
const result = [...arr]; | |
for (let i = 0; i < result.length; i++) { | |
while (Array.isArray(result[i])) { | |
// insert in the current position a copy of the original item | |
result.splice(i, 1, ...result[i]); | |
} | |
} |
const encodeNumber = (n, precision) => { | |
// Multiple number by 10^precision to round the result | |
n = Math.round(n * +`1e${precision}`); | |
/** | |
* Number is already in two's complement so just shift left | |
* by 1-bit and negate if and only if number is negative | |
*/ | |
n = n < 0 ? ~(n << 1) : n << 1; |
export function default (polygon) { | |
let cx = 0, cy = 0, a = 0; | |
for (let i = 0, l = polygon.length; i < l; i++) { | |
let x0 = polygon[i].x, | |
x1 = polygon[(i + 1) % l].x, | |
y0 = polygon[i].y, | |
y1 = polygon[(i + 1) % l].y; | |
let m = (x0 * y1 - x1 * y0); |
function curry(fn) { | |
function nest(...args) { | |
const next = this.bind(this, ...args); | |
if (args.length === 0 || next.length === 0) { | |
return next(); | |
} else { | |
return nest.bind(next); | |
} | |
} |
I hereby claim:
To claim this, I am signing this object:
const trusted = [], | |
untrusted = [ | |
'eval', | |
...Object.keys(window) | |
].filter(k => trusted.indexOf(k) !== -1); | |
export default function createSecureScript(script, ...args) { | |
return new Function( | |
...untrusted, | |
...args, |
function isInside(p, [a, b]) { | |
return (b[0] - a[0]) * (p[1] - a[1]) > (b[1] - a[1]) * (p[0] - a[0]); | |
} | |
function getEdges(polygon) { | |
let edges = []; | |
for (let i = 0; i < polygon.length; i++) { | |
let edge = [polygon[(i + polygon.length - 1) % polygon.length], polygon[i]]; |
interface Point { | |
x: number; | |
y: number; | |
} | |
/** | |
* Compute the perpendicular distance between a point and a line | |
* @param point | |
* @param line | |
*/ |
export default class TEA { | |
get DELTA() { | |
return 0x9e3779b9; | |
} | |
constructor(/* Uint32Array(4) */ _key) { | |
this._key = _key; | |
} | |
encrypt(/* Uint32Array(2) */ _value) { |