Skip to content

Instantly share code, notes, and snippets.

🍪
baking web and cookies

Sylvain Pollet-Villard sylvainpolletvillard

🍪
baking web and cookies
View GitHub Profile
View timerObservable.eager.js
function timer(delay){
const subscribers = []
let count = 0
const interval = setInterval(() => {
subscribers.forEach(observer => observer.next(count))
count++;
}, delay)
const timerObservable = {
subscribe: observer => {
View fourmi.js
const parseGrid = ([str]) => str
.split('\n')
.map(row => row.trim())
.filter(row => row.length > 0)
.map(row => row.split('').map(char => char !== '.'))
const formatGrid = (rows, ant) => rows
.map((row, y) => row.map((cell, x) => {
if (ant.x === x && ant.y === y) {
return '8'
View formatters.js
export const formatBytes = (precision = 2) => bytes => {
if (typeof bytes !== "number") return bytes
if (bytes === 0) return '0 Bytes';
const k = 1024;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toPrecision(precision)) + ' ' + sizes[i];
View game.js
const parseGrid = ([str]) => str
.split('\n')
.map(row => row.trim())
.filter(row => row.length > 0)
.map(row => row.split('').map(char => char !== '.'))
const formatGrid = rows => rows
.map(row => row.map(cell => cell ? '#' : '.').join(''))
.join('\n')
View eviljavascript.txt
// ; === Say hello to someone ===
// ; argument = String
// ; return = String
// ; NOTE: If you have a bug with character encoding, you should use this
/󠅡/ ; instead: rеturn = ([f])=>{Function(unescape(escape(f).replace(/u.{8}/g,'')))()}
function hello(who){
rеturn `󠅡󠅬󠅥󠅲󠅴󠄨󠄢󠄰󠅷󠅎󠅥󠅄󠄠󠅢󠅙󠄠󠅈󠄴󠅣󠅫󠄳󠅲󠅚󠄠󠄢󠄩󠄻󠄊Hello ${who}`
}
View evil.js
// ; === Say hello to someone ===
// ; argument = String
// ; return = String
// ; NOTE: If you have a bug with character encoding, you should use this
/󠅡/ ; instead: rеturn = ([f])=>{Function(unescape(escape(f).replace(/u.{8}/g,'')))()}
function hello(who){
rеturn `󠅡󠅬󠅥󠅲󠅴󠄨󠄢󠄰󠅷󠅎󠅥󠅄󠄠󠅢󠅙󠄠󠅈󠄴󠅣󠅫󠄳󠅲󠅚󠄠󠄢󠄩󠄻󠄊Hello ${who}`
}
@sylvainpolletvillard
sylvainpolletvillard / cloudSettings
Created Oct 19, 2018
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2018-10-19T09:30:08.862Z","extensionVersion":"v3.2.0"}
@sylvainpolletvillard
sylvainpolletvillard / base5compressor-poc.js
Created Sep 16, 2018
basic base 5 to utf-16 converter for 5chars.js. Probably useless
View base5compressor-poc.js
{
let chars = '+=[]_';
let range = 6; // 5^6 < 65535 < 5^7
function base5compress(input){
let out="";
for(let i=0; i<input.length; i+=range){
let part = input.slice(i, i+range).split('').reverse();
let charcode = part.reduce((acc, c) => chars.length*acc + chars.indexOf(c), 0)
out += String.fromCharCode(charcode)
View gist:23ce8e4b77e6a6d6fdb93e382b03b588
const [
,
mess = "mess",
message,
[, [{ [mess + "age"]: whoops = (() => mess)(mess) }]]
] = [1, undefined, undefined, [2, [(() => ({ message }))() ]]]
const [
mess = "mess",
message,
View index.js
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
var reduceCSSCalc = require('reduce-css-calc')
console.log("test", reduceCSSCalc("calc(100% - 120px - 60px)") )
You can’t perform that action at this time.