Skip to content

Instantly share code, notes, and snippets.

View AndyNovo's full-sized avatar

Andy Novocin AndyNovo

View GitHub Profile
@AndyNovo
AndyNovo / cert.js
Created May 4, 2016 13:28
local server with certificates
var https = require("https");
var fs = require("fs");
var options = {
key: fs.readFileSync('cert.key'),
cert: fs.readFileSync('cert.crt'),
requestCert: false,
rejectUnauthorized: false
};
import os
from cryptography.hazmat.primitives.ciphers import (Cipher, algorithms, modes )
from cryptography.hazmat.backends import default_backend
def encrypt(key, plaintext, associated_data):
# Generate a random 96-bit IV.
iv = os.urandom(12)
# Construct an AES-GCM Cipher object with the given key and a
# randomly generated IV.
import gym
env = gym.make('CartPole-v0')
def ai():
wts=[-.2,0,1,.4]
mms=[0.76464200398541937, 2.3215749215909214, 0.20943257252883613, 2.9815988455023286]
obs=env.reset()
rwd=0
for i in range(200):
move=1 if sum([obs[i]*wts[i]/mms[i] for i in range(len(obs))]) > 0 else 0
import gym
env = gym.make('CartPole-v0')
obs=env.reset()
maxs=[obs[i] for i in range(len(obs))]
mins=[obs[i] for i in range(len(obs))]
def strat(style):
global maxs, mins
ss=lambda x: 0
if style=="1":
@AndyNovo
AndyNovo / interpolate.sagews
Created May 15, 2016 22:06
Polynomial Interpolation in SAGE
p=11
R.<x>=PolynomialRing(GF(p))
points=[(1,1), (3,3)]
f=R.lagrange_polynomial(points)
header = ("01000000" +
"81cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000" +
"e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122b" +
"c7f5d74d" +
"f2b9441a" +
"42a14695")
print hashlib.sha256(hashlib.sha256(binascii.unhexlify(header)).digest()).digest()
header = ("01000000" +
"81cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000" +
"e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122b" +
"c7f5d74d" +
"f2b9441a" +
"42a14695")
hashlib.sha256(hashlib.sha256(binascii.unhexlify(header)).digest()).digest()
B0 = Matrix(GF(3), 5, 5)
B1 = Matrix(GF(3), 5, 5)
B2 = Matrix(GF(3), 5, 5)
B0[1,0] = 1
B0[4,1] = 1
B1[0,0] = -1
B1[1,1] = -1
B1[2,2] = 1
B1[3,1] = -1
B1[4,2] = -1
@AndyNovo
AndyNovo / input.txt
Created September 14, 2016 15:54
Input File
7-21-22-6 22-6 18-1-16-2-17-18-17 10-22-7-21 14 16-14-18-6-14-5 16-22-3-21-18-5
@AndyNovo
AndyNovo / input.txt
Created September 14, 2016 16:03
Another input file
12-2-8-5 25-22-19-18 22-6 25-22-24-18 14 19-14-5-26 12-2-8-5 15-5-14-22-1 25-22-24-18 6-2-22-25 22-19 12-2-8 3-25-14-1-7 3-2-22-6-2-1-2-8-6 1-22-20-21-7-6-21-14-17-18 7-21-18-1 12-2-8 10-22-25-25 20-5-2-10 1-22-20-21-7-6-21-14-17-18 22-19 12-2-8 3-25-14-1-7 19-5-8-22-7 12-2-8 10-22-25-25 20-5-2-10 19-5-8-22-7 7-21-18 7-21-2-8-20-21-7-6 12-2-8 3-25-14-1-7 22-1 12-2-8-5 26-22-1-17 18-9-18-5-12-17-14-12 15-18-16-2-26-18 7-21-18 16-5-2-3 12-2-8-5 25-22-19-18 12-22-18-25-17-6