Skip to content

Instantly share code, notes, and snippets.

View JobLeonard's full-sized avatar

Job van der Zwan JobLeonard

  • IxD/supporting programmer at Linnarsson Lab
  • Malmö
View GitHub Profile
@JobLeonard
JobLeonard / README.md
Last active September 6, 2022 11:45
Adding a value to an array if it's not in the array yet
@JobLeonard
JobLeonard / README.md
Last active August 15, 2022 09:35
instanceOf vs .constructor checks
@JobLeonard
JobLeonard / jsfuck_lljs_v2.js
Created August 23, 2019 10:56
Mangled JSFuck v2
const compile = (() => {
const N = n => {
if (n === 0) return '+[]';
return Array.from({ length: n }, () => '+!![]').join(' + ');
}
const M = {};
const S = s => s.split('').map(x => {
return M[x] || `([]+[])[${S(c)}][${S('fromCharCode')}](${N(x.charCodeAt(0))})`;
// const N = n => {
// if (n === 0) return '+[]';
// return Array.from({length: n}, () => '+!![]').join(' + ');
// }
// const M = {};
// const S = s =>s.split('').map(x => {
// if (!(x in M)) {
// const charCode = x.charCodeAt(0);
@JobLeonard
JobLeonard / lz-string-deba.js
Created April 4, 2019 14:42
LZString variant with unsafe characters removed, see https://github.com/pieroxy/lz-string/issues/126
LZStringDEBA = (function () {
"use strict";
// private property
var fromCharCode = String.fromCharCode,
streamData = null,
streamVal = 0,
streamPos = 0;
function streamBits(token, numBitsMask) {
for (var i = 0; numBitsMask >>= 1; i++) {
@JobLeonard
JobLeonard / sort vs sorted copy.js
Last active September 5, 2018 00:15
compare Uint8Array.slice(0).sort() to Uint8Array.sort()
const count32 = new Uint32Array(256),
count16 = new Uint16Array(256);
function radixU8(input) {
if (input.length < (1 << 16)) {
return radixU8_16(input);
} else {
return radixU8_32(input);
}
}
@JobLeonard
JobLeonard / lz-string-asyncish.js
Last active August 22, 2018 14:18
LZString, window.postMessage-based async version v0.0.5
// Copyright (c) 2013 Pieroxy <pieroxy@pieroxy.net>
// Asyncish version by Job van der Zwan (2018)
// This work is free. You can redistribute it and/or modify it
// under the terms of the WTFPL, Version 2
// For more information see LICENSE.txt or http://www.wtfpl.net/
//
// For more information, the home page:
// http://pieroxy.net/blog/pages/lz-string/testing.html
//
// LZ-based compression algorithm, version 2.0 RC