Skip to content

Instantly share code, notes, and snippets.

View brenapp's full-sized avatar
🐵
Code Wranglin

Brendan McGuire brenapp

🐵
Code Wranglin
View GitHub Profile
@brenapp
brenapp / fuzzysearch.js
Created September 26, 2015 02:14
A very basic Fuzzy Search in 66 bytes
/* Fuzzy Search in JavaScript in 66 bytes by SpeedyNinja
Creates a Regex of the Form x.*y.*z.* for query xyz and tests it against the list of terms
*/
f=t=>s=>t.filter(x=>eval("/"+s.replace(/./,"$&.*")+"/gi").test(x))
/*
Usage:
var search = f(["list", "of", "search", "terms"])
search("er") -> ["search", "terms"]
^ ^ ^^
@brenapp
brenapp / pid.c
Last active February 6, 2016 01:48
A very basic PID Controller for ROBOTC
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, I2C_1, , sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Motor, port2, FlywheelLeft, tmotorVex393TurboSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port3, FlywheelRight, tmotorVex393TurboSpeed_MC29, openLoop, encoderPort, I2C_1)
#pragma config(Motor, port4, DriveFrontLeft, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port5, DriveFrontRight, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port6, DriveBackLeft, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port7, DriveBackRight, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, ElevatorRight, tmotorVex393TurboSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port9, ElevatorLeft, tmotorVex393TurboSpeed_MC29, openLoop, reversed)
@brenapp
brenapp / grid.css
Created July 15, 2016 02:19
The Grid System from Skeleton, isolated from everything else
/**
* I did not make this, this is the grid system from the skeleton css framework, shamelessly ripped from their source!
* See the Skeleton Project here: <https://github.com/dhg/Skeleton> <http://getskeleton.com>
*/
.container {
position: relative;
width: 100%;
max-width: 960px;
margin: 0 auto;
padding: 0 20px;
npm i -g express & curl -o /usr/local/bin/serve https://gist.githubusercontent.com/MayorMonty/98ccf4c976ef5f3b959be4f8ac228c31/raw/e895f30bf37858b52f92ad285eeafc35a2087549/serve.js
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brenapp
brenapp / naïve.c
Created February 21, 2017 18:40
The naïve approach to driving in autonomous
task autonomous() {
driveForward();
wait(8000);
stopDrive();
}
task autonomous() {
int sensor = getRotationalSensor();
while (sensor > 15) {
driveForward();
sensor = getRotationalSensor();
}
}
@brenapp
brenapp / help.md
Last active March 27, 2017 21:51
Super small (150b) pub-sub with some cool features

Usage:

var ee = pub();
ee.on('*', (p, e) => console.log(`${e} trigged: ${p}`)); // Called for all events (returns all * listeners)
ee.on("load", d = (t, e) => console.log(`Page loaded in ${t}ms`)); // Returns an array of all listeners for that event (minus * listeners)
ee.emit("load", 2323); // Returns the return values of the .on() functions, in this order: [...specific listeners, ...* listeners]

ee.off("load", d); // Returns the new array of listeners

@brenapp
brenapp / error.log
Created July 17, 2017 06:49
Linker Error
Invoking make in /Users/tim/Documents/Robotics/In The Zone...
CPC -I../include -I../src motors.cpp
LN ./bin/auton.o ./bin/init.o ./bin/motors.o ./bin/opcontrol.o ./bin/pid.o ./bin/robot.o ./firmware/libpros.a -lgcc -lm to bin/output.elf
./bin/motors.o:(.data+0x0): multiple definition of `motors::slewRates'
./bin/init.o:(.data+0x0): first defined here
./bin/motors.o:(.bss+0x0): multiple definition of `motors::slewTargets'
./bin/init.o:(.bss+0x240): first defined here
collect2: error: ld returned 1 exit status
make: *** [bin/output.elf] Error 1
The terminal process terminated with exit code: 1
// Adj. Close for Each Month
let adj = [
30.550734,
29.040157,
28.25503,
32.47147,
28.410118,
30.476208,
30.281532,
28.305592,