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 question = ['🥚','🐔'] | |
let answer = question.sort() | |
console.log(answer[0] + ' was first!') |
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 memoize(func) { | |
let mem = {}; | |
return (...args) => { | |
let dest = args.reduce((mem, arg) => { | |
mem.args = mem.args || []; | |
mem.mems = mem.mems || []; | |
let idx = mem.args.indexOf(arg); | |
let 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
import os | |
import socket | |
from OpenSSL import crypto, SSL | |
# OpenVPN is fairly simple since it works on OpenSSL. The OpenVPN server contains | |
# a root certificate authority that can sign sub-certificates. The certificates | |
# have very little or no information on who they belong to besides a filename | |
# and any required information. Everything else is omitted or blank. | |
# The client certificate and private key are inserted into the .ovpn file | |
# which contains some settins as well and the entire thing is then ready for |
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
// Very simple way to compute the center (centroid) of a triangle. | |
// The only things you have to know are the three vectors forming the triangle. | |
// vector = [x, y, z]; | |
var vectorA = [-1, -3, -2]; | |
var vectorB = [2, 1, 2]; | |
var vectorC = [8, -4, 1]; | |
var centerX = ((vectorA[0] + vectorB[0] + vectorC[0]) / 3); | |
var centerY = ((vectorA[1] + vectorB[1] + vectorC[1]) / 3); |
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
long pow_mod(long x, long n, long p) { | |
if (n == 0) return 1; | |
if (n & 1) | |
return (pow_mod(x, n-1, p) * x) % p; | |
x = pow_mod(x, n/2, p); | |
return (x * x) % p; | |
} | |
/* Takes as input an odd prime p and n < p and returns r | |
* such that r * r = n [mod p]. */ |
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
/* | |
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace | |
so it's better encapsulated. Now you can have multiple random number generators | |
and they won't stomp all over eachother's state. | |
If you want to use this as a substitute for Math.random(), use the random() | |
method like so: | |
var m = new MersenneTwister(); |