Skip to content

Instantly share code, notes, and snippets.

View mindoftea's full-sized avatar

Emory Hufbauer mindoftea

View GitHub Profile
{"board":"duetm10","firmware":1.21,"nvram":false,"auto_save":{"enabled":false,"save_threshold":12,"resume_threshold":20,"gcodes_to_run":"M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000"},"geometry":{"type":"cartesian","mins":[0,0,0],"maxes":[230,225,300],"delta_radius":105.6,"homed_height":250,"low_dive_height":false,"max_carriage_travel":260,"print_radius":85,"rod_length":215,"z_min":0},"drives":[{"direction":1,"microstepping":32,"microstepping_interpolation":true,"steps_per_mm":160,"instant_dv":15,"max_speed":100,"acceleration":500,"current":800,"driver":0,"endstop_type":1,"endstop_location":1},{"direction":1,"microstepping":32,"microstepping_interpolation":true,"steps_per_mm":160,"instant_dv":15,"max_speed":100,"acceleration":500,"current":800,"driver":1,"endstop_type":1,"endstop_location":1},{"direction":0,"microstepping":32,"microstepping_interpolation":true,"steps_per_mm":800,"instant_dv":3,"max_speed":20,"acceleration":100,"current":800,"driver":2,"endstop_type":1,"endstop_location":1},{"direction":1,"microstepping
import Data.Bits
import Data.List
import Data.List.Split
import qualified Data.Map as Map
import Data.Maybe
-- Abstract operation type
data Operation = Operation {
compute :: [Integer] -> Integer,
symbol :: String
const arraySize = 1e3;
const trialSize = 1e6;
const a = [];
let i = arraySize;
while (i--) {
a[i] = i;
}
const t = [];
const x = a.slice();
@mindoftea
mindoftea / bluetoothLagTest
Created June 21, 2014 22:09
Node-bluetooth-serial-port writing lag test case. Writing consistently takes 250ms to complete on OSX.
"use strict";
var bluetooth=require('bluetooth-serial-port');
bluetooth=new bluetooth.BluetoothSerialPort();
var write=function()
{
var timeStamp;
console.log("sending...");
timeStamp=Date.now();
@mindoftea
mindoftea / chooser.js
Created June 21, 2014 15:03
A node.js program that helps users sort a list based on subjective criteria.
"use strict";
var Prompt=require('prompt');
Prompt.start();
var LOW={};
var HIGH={};
var sortedList=[LOW,HIGH];
var unSortedList=[
@mindoftea
mindoftea / curryProduct.js
Last active August 29, 2015 14:01
A demonstration of some of the power of closures when used for currying in JavaScript.
var f=function(x)
{
var g=function(y)
{
x*=y;
print(x);
return g;
};
return g;
};
@mindoftea
mindoftea / fastFibonacci.js
Created May 10, 2014 06:08
A recursive, caching JavaScript implementation of the famous Fibonacci function. Each time you call it, it gets faster.
var fibonacci=function()
{
var x=[0,1];
return function(n)
{
if(x[n]!==undefined)
{
return x[n];
}
else
@mindoftea
mindoftea / elGamal.js
Created May 10, 2014 06:04
An implementation of the ElGamal encryption system in JavaScript.
var Alphabet = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 𮃩∆";
Alphabet = Alphabet.split("");
var Crypto = function (alpha, gen, C) {
var p, B, encrypt, decrypt, f, g, modInv, modPow, toAlpha, to10;
toAlpha = function (x) {
var y, p, l, n;
if (x === 0) {
return "!!!!";
@mindoftea
mindoftea / seededRand.js
Created May 10, 2014 05:53
A simple seeded pseudo-random number generator implemented in JavaScript using the Blum Blum Shub method.
var SeededRand = function(seed, mod1, mod2)
{
return function()
{
seed = (seed*seed) % (mod1*mod2);
return seed/(mod1*mod2);
};
};
var rand = SeededRand(seed, mod1, mod2);
@mindoftea
mindoftea / pointChecker.js
Created May 10, 2014 05:50
A javascript function which uses a map to efficiently search for nearby points distributed across a one-dimensional field. There is quite a high up-front cost to initializing the map, but, once that is done, each point-finding operation is extremely cheap.
var CheckPoints=function(list, spaceSize, scanSize)
{
var n,m,map;
list.sort(
function(a,b)
{
return -(a.x<b.x)+(a.x>b.x);
}
);
map={};