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
// a typescript implement of hindley-milner type inference | |
// reference http://smallshire.org.uk/sufficientlysmall/2010/04/11/a-hindley-milner-type-inference-implementation-in-python/ | |
/// <reference path="./lib.es6.d.ts" /> | |
// ... | |
interface AstNode { | |
} | |
class Id implements AstNode { |
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> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<title>SAI HOOKER TEST</title> | |
</head> | |
<body> | |
<canvas id="c"></canvas> | |
<script> |
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> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>SAI HOOKER TEST</title> | |
</head> | |
<body> | |
<div id="u" style="position:absolute;"> |
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
# remember to add | |
#PermitTunnel yes | |
# in /etc/ssh/sshd_config | |
# create tun device on both machines | |
# ref: http://www.k336.org/2013/04/non-root-ssh-vpn.html | |
sudo ip tuntap add dev tun0 mode tun user oxyflour group oxyflour | |
# delete tun | |
sudo ip tuntap del dev tun0 mode tun |
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
var watch = require('node-watch'), | |
exec = require('child_process').exec | |
function debounce(func, delay) { | |
var timeout = 0 | |
return function() { | |
var that = this, | |
args = arguments | |
if (timeout) { | |
clearTimeout(timeout) |
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
# from http://engineering.circle.com/https-authorized-certs-with-node-js/ | |
# generate ca | |
wget https://raw.githubusercontent.com/anders94/https-authorized-clients/master/keys/ca.cnf | |
openssl req -new -x509 -days 9999 -config ca.cnf -keyout ca-key.pem -out ca-crt.pem | |
# generate private key for server | |
openssl genrsa -out server-key.pem 4096 | |
# generate server certificate, remember to update the CN (common name) |
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
Promise.chain = function(arr, func) { | |
var res = [ ], | |
req = Promise.resolve() | |
return arr.reduce((req, val, i) => req.then(r => { | |
res.push(r) | |
return func(val, i) | |
}), req).then(r => { | |
res.push(r) | |
return res.slice(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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<style> | |
html, body, .slide { | |
width: 100%; | |
height: 100%; | |
overflow: hidden; | |
background-color: black; |
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
<body> | |
<script> | |
// https://github.com/vbohush/SortingAlgorithmAnimations | |
const methods = { | |
async bubble(a) { | |
// https://en.wikipedia.org/wiki/Bubble_sort | |
for (let i = 0; i < a.length; i ++) { | |
for (let j = a.length - 1; j > i; j --) { | |
if (await a.comp(a[j - 1], a[j])) { | |
a.swap(j - 1, j) |
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
<html> | |
<body> | |
<canvas id="cv"></canvas> | |
<script> | |
const A = 500, // billiard size | |
SQ3 = A * Math.sqrt(3), | |
p = [A * 0.25, A], // start point [x, y] | |
v = [0.4, 0.5], // velocity [vx, vy], smaller is better | |
strokeStyle = 'red', // line style | |
lineWidth = 2 // line width |