This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Nano Stamp</title> | |
<style> | |
img { | |
image-rendering: pixelated; | |
border: 1px solid black; | |
} | |
</style> |
This file contains 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
export const pipe = function<T>(promise: Promise<T>, ...callbacks: ((value: T) => T|Promise<T>)[]): Promise<T> { | |
let subject = promise; | |
for (const i in callbacks) { | |
subject = subject.then(callbacks[i]) | |
} | |
return subject; | |
} |
This file contains 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
Array.prototype.flip = function() { | |
const obj = {}; | |
this.forEach((e, i) => { | |
obj[e] = i; | |
}); | |
return obj; | |
} |
This file contains 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
exports.unchain = function unchain(subject) { | |
const proxy = new Proxy(subject, { | |
get(target, name, receiver) { | |
if (name === '_') { | |
return new Proxy(subject, { | |
get(target, name, receiver) { | |
const member = Reflect.get(target, name, receiver); | |
if (typeof member === 'function') { | |
return function () { |
This file contains 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
<?php | |
function array_delete(&$array, $key) { | |
if (!isset($array[$key])) { | |
return null; | |
} | |
$value = $array[$key]; | |
unset($array[$key]); | |
return $value; | |
} |
This file contains 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 SEPARATOR = ':::'; | |
module.exports = (function() { | |
const cls = function() { | |
this.userVisits = {}; | |
}; | |
const parseSequences = function(userVisits, length) { | |
const sequences = {}; | |
const size = length - 1; |
This file contains 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(){ | |
module.exports = function scope(block) { | |
const deferred = []; | |
const defer = function(callback, args) { | |
deferred.unshift({target: this, callback, args}); | |
} | |
try { | |
return block(defer); | |
} finally { |
This file contains 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
export namespace RNG { | |
let seq = 1; | |
export function random(seed ?:number) { | |
if (typeof seed != 'undefined') { | |
seq = seed; | |
} | |
let x = Math.sin(seq++) * 10000; | |
return x - Math.floor(x); | |
} | |
} |
This file contains 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 OTP = (() => { | |
function xorStrings(a, b) { | |
let c = ""; | |
for (let i = 0; i < a.length; i++) | |
c += String.fromCharCode(a.charCodeAt(i) ^ b.charCodeAt(i)); | |
return c; | |
} |
This file contains 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 () { | |
function prmze() { | |
let thenCallback = null; | |
let catchCallback = null; | |
let child = null; | |
return { | |
ready: false, | |
then: function (callback) { | |
this.ready = true; |
NewerOlder