Skip to content

Instantly share code, notes, and snippets.

@Maxinary
Maxinary / shuffle_trial.py
Created February 1, 2021 18:16
Shuffles lists to fit constraints of repetition
from random import shuffle
from random import randint
'''
shuffle_trial is a set of functions used to shuffle a set of labeled files
into order by counting the number of repeated fields in each file (see
comment documentation on the generate_repeats function)
Max Scribner
December 13, 2018
'''
from random import shuffle
'''
shuffle_trial is a set of functions used to shuffle a set of labeled files
into order by counting the number of repeated fields in each file (see
comment documentation on the generate_repeats function)
Max Scribner
December 13, 2018
'''
@Maxinary
Maxinary / vec.js
Created February 21, 2017 14:55
Vec Stuff
class Vec{constructor(angle,r){this.x=r*Math.cos(angle);this.y=r*Math.sin(angle);}add(vec){return new Vec(Math.atan2(this.y+vec.y, this.x+vec.x), Math.sqrt(Math.pow(this.x+vec.x, 2) + Math.pow(this.y + vec.y, 2)))}}
function deg(x){return x/Math.PI*180;}
@Maxinary
Maxinary / vec.js
Created February 21, 2017 14:55
Vec Stuff
class Vec{constructor(angle,r){this.x=r*Math.cos(angle);this.y=r*Math.sin(angle);}add(vec){return new Vec(Math.atan2(this.y+vec.y, this.x+vec.x), Math.sqrt(Math.pow(this.x+vec.x, 2) + Math.pow(this.y + vec.y, 2)))}}
function deg(x){return x/Math.PI*180;}
@Maxinary
Maxinary / permutations.js
Last active January 1, 2017 03:18
generates all permutations of integers 0 to x non-recursively
function perm(x){
acc = [[0]];
for(var i=1; i<x; i++){
add = [];
for(var j=0; j<acc.length; j++){
for(var k=0; k<acc[j].length+1; k++){
add.push(acc[j].slice(0, k).concat([i]).concat(acc[j].slice(k, acc[j].length)));
}
}
acc = add;
@Maxinary
Maxinary / index.html
Last active November 4, 2016 19:36
A test of some shaders
<html>
<head>
<title>WebGL</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="glMatrix-0.9.5.min.js"></script>
<script type="text/javascript" src="webgl-utils.js"></script>
<script type="text/javascript" src="keyregisterer.js"></script>
import math
for i in range(2*10**10):
k = i**2
#m**2+m-2*k
q = (-1+math.sqrt(1+8*k))/2#quadratic formula
if(q==int(q)):
print(k)
@Maxinary
Maxinary / percent_data.py
Last active April 20, 2016 23:40
Basic manipulations of percentage data. All inputs must be greater than 0 less than 1
def p_and(x,y):
return x*y
def p_or(x,y):
return x+y - p_and(x,y)
def p_xor(x,y):
return x+y - 2*p_and(x,y)
def prompt(inp):
return input(inp+"\n>")
state = 0
end = False
while end!=True:
if state == 0:
print("You are sitting in a room. There is a door and a table.")
value = prompt("Press 1 to look at the door, Press 2 to look at the desk, press 3 to sit still")
if value == "1":
class Step:
def __init__(self, text, options):
self.text = text
self.options = options
def __call__(self):
if len(self.options)>0:
return self.options[input(self.text+"\n"+"\n".join([str(i+1)+" to "+self.options[i].name for i in range(len(self.options))])$
else:
print(self.text)
return -1