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* sequence(x) { | |
yield x; | |
yield * sequence(x + 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
let squeeze = s => s.replace(/../g,c=>String.fromCharCode(c[a='charCodeAt']()|c[a](1)<<7)); | |
let unsqueeze = s => s.replace(/./g,c=>String.fromCharCode((c=c.charCodeAt())&127,c>>7)); | |
console.log(unsqueeze("㟦ᑲᝣ㓷㩤㹨㒽Ჽ㒻ᚭᒻ㓦㙬㋒㩣ᨨᠰ㒫ᢪᠰ⦫㨨ᔩᠳᘰᠴᘰᠵᠰᶩ") === | |
"for(c.width|=i=9;i--;)x.fillRect(400+i*100+S(t)*300,400,50,200);"); | |
console.log(squeeze("for(c.width|=i=9;i--;)x.fillRect(400+i*100+S(t)*300,400,50,200);") === | |
"㟦ᑲᝣ㓷㩤㹨㒽Ჽ㒻ᚭᒻ㓦㙬㋒㩣ᨨᠰ㒫ᢪᠰ⦫㨨ᔩᠳᘰᠴᘰᠵᠰᶩ"); | |
console.log("㟦ᑲᝣ㓷㩤㹨㒽Ჽ㒻ᚭᒻ㓦㙬㋒㩣ᨨᠰ㒫ᢪᠰ⦫㨨ᔩᠳᘰᠴᘰᠵᠰᶩ".length === 32); |
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
/* | |
Variations of https://medium.com/@d0nut/why-building-a-sandbox-in-pure-javascript-is-a-fools-errand-d425b77b2899 | |
jailbreaking example. | |
*/ | |
var flag = "I'm the flag!"; | |
function jail(code) { | |
// quick string escape for inner strings | |
code = code.replace(/["'`\\]/g, function(v){ return `\\${v}`}); |
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
let fs = require('fs'); | |
let path = process.cwd(); | |
console.log('looking for StreamingHistory.json file in ' + path + '\\data\\'); | |
let buffer = {}; | |
try { | |
buffer = fs.readFileSync(path + "\\data\\StreamingHistory.json"); | |
} catch (e) { |
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
if [[ $# -eq 0 ]] ; then | |
echo 'You must specify a valid virtual host name' | |
exit 0 | |
fi | |
vhost=$1 | |
export vhost | |
sudo rm -rf /var/www/"$vhost" | |
sudo a2dissite "$vhost".conf |
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
if [[ $# -eq 0 ]] ; then | |
echo 'You must specify a valid virtual host name' | |
exit 0 | |
fi | |
vhost=$1 | |
export vhost | |
sudo mkdir -p /var/www/"$vhost"/public_html | |
sudo chmod -R 777 /var/www/"$vhost" |
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 Vector() { | |
this.capacity = 1; | |
this.elements = new Array(this.capacity); | |
this.size = 0; | |
this.add = (element) => { | |
if (this.size > this.capacity) | |
console.err('this.size > this.capacity'); | |
if (this.size === this.capacity) { |
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
#!/usr/bin/env python | |
""" | |
Very simple HTTP server. | |
Upon a GET or POST request, returns a json object with the route of the request | |
and the data of the request body. | |
""" | |
import socket | |
from http.server import BaseHTTPRequestHandler, HTTPServer | |
import time |
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
let parent = (t, i) => t[((i + 1)>>1) - 1]; | |
let kids = (t, i) => [t[2*i + 1],t[(i+1)*2]] |
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
type 'a binary_tree = Leaf | Node of 'a * 'a binary_tree * 'a binary_tree;; | |
let visit_binary_tree tree (visiting_function:'a binary_tree -> 'a list) :'a list = match tree with | |
| Leaf -> [] | |
| Node (_, _, _) -> visiting_function tree;; | |
(* | |
1 | |
/ \ | |
2 3 |