Skip to content

Instantly share code, notes, and snippets.

View mjkaufer's full-sized avatar
🏂

Matthew Kaufer mjkaufer

🏂
View GitHub Profile
@mjkaufer
mjkaufer / roulette.sh
Created October 24, 2014 00:55
Bash Roulette
alias roulette='[ $[ $RANDOM % 6 ] == 0 ] && rm -f $(shuf -n1 -e *) && echo "BOOM" || echo *Click*'
@mjkaufer
mjkaufer / robotanno.py
Created February 1, 2020 08:56
boba bot baby
import time
import serial
# configure the serial connections (the parameters differs on the device you are connecting to)
ser = serial.Serial(
port='/dev/tty.usbserial-AD0JM61U',
baudrate=115200,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
@mjkaufer
mjkaufer / countStudents.py
Last active December 19, 2018 00:12
Count the number of students in the example in my blog
from CoefficientCalculator import Term, MultiTerm, Expression, Scalar
# Some brief terminology (no pun intended)
# A term is something like x, x^2, x^3, etc.
# 1 can also be a term
# A multiterm is the product of several terms. Something like x * y or x * z^2 is fine
# Multiterms also have constants, so 5 * x * y^3 is also a valid multiterm
@mjkaufer
mjkaufer / fib.js
Created January 13, 2015 17:52
A way to (poorly) generate the first 10 Fibonacci numbers using (almost) only JavaScript array functions.
var fib = new Array(10);
for(var i = 0; i < fib.length; i++)//strangely enough, setting the values of `a` with array functions is incredibly difficult, so we'll use this instead
fib[i] = 1;
/*^^Given Code^^*/
/*alternately, you could fill an array using the folloring code
var fib = Array.apply(null, new Array(10)).map(Number.prototype.valueOf,10);
@mjkaufer
mjkaufer / script.js
Created October 5, 2014 23:36
Converts lists to prettier lists. I.e. `data1, data2, data3, ` to `data1, data2, and data3`
var data = "";
for(var i = 0; i < 10; i++){//this is to give default values to the data set, to emulate what it would look like
data+=i + ", ";
}
data = data.replace(/\, $/g,"");//take out trailing comma
data = data.replace(/,([^,]*)$/, ", and$1");//adds a pretty "and" to the end
console.log(data);