Skip to content

Instantly share code, notes, and snippets.

View battis's full-sized avatar

Seth Battis battis

View GitHub Profile
const int ENABLE_A = 4;
const int ENABLE_B = 5;
const int SPEED = 6;
void setup() {
pinMode(ENABLE_A, OUTPUT);
pinMode(ENABLE_B, OUTPUT);
pinMode(SPEED, OUTPUT);
}
@battis
battis / DoublyIndexedList.java
Created March 23, 2020 17:36
Rethinking Levels as a doubly-indexed list
import java.util.ArrayList;
import java.util.List;
public class DoublyIndexedList {
private Sprite[][] level;
/* ... */
public void set(int x, int y, Sprite sprite) {
level[x][y] = sprite;
@battis
battis / Current First Play Track.png
Last active April 23, 2019 14:28
Exploit iOS autoplay-on-connect bug for greater joy
Current First Play Track.png
@battis
battis / MecanumDrive.java
Created January 7, 2019 14:51
FTC MecanumDrive OpMode
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;
/**
* This is based on the helpful write-up at
* https://www.roboteq.com/index.php/component/easyblog/entry/driving-mecanum-wheels-omnidirectional-robots?Itemid=1208
* which itself is pulled from the Simplistic Control of Mecanum Drive from Ian McInerney, FRC Team 2022:
@battis
battis / musical_stairs.ino
Last active May 4, 2018 12:49
Musical Stairs
/*
* Musical Stairs
*
* The core assumptions of this code mostly have to do with the sequence in which the
* XSHUT pins are wired together:
*
* 1. All of the XSHUT pins are contiguous on the Arduino, starting at XSHUT_OFFSET.
* 2. The pins are ordered L1, R1, L2, R2, ... , L10, R10
*
* At the moment, we are triggering a note to be played if REQ_CONSECUTIVE_BREAKS consecutive
@battis
battis / laser_time-of-flight_sensor_test.ino
Last active May 1, 2018 16:55
Laser Time-of-Flight Sensor Test (multiple sensors)
#include <Wire.h>
#include <VL53L0X.h>
const int NUM_SENSORS = 5;
const long SENSOR_TIMEOUT = 25;
const long MAX_TESTS = 100;
const long MAX_DURATION = 300000;
const int XSHUT_OFFSET = 2; // first XSHUT pin
VL53L0X sensors[NUM_SENSORS];
@battis
battis / laser_time-of-flight_sensor_test.ino
Created May 1, 2018 13:46
Laser Time-of-Flight Sensor Test
#include <Wire.h>
#include <VL53L0X.h>
const long SENSOR_TIMEOUT = 500;
const long MAX_TESTS = 1000;
const long MAX_DURATION = 300000; //ms
VL53L0X sensor;
int count = 0;
@battis
battis / start_tt-rss_daemon
Last active February 19, 2018 17:27
Start TT-RSS daemon in a detached screen (a 'cheap daemon' on multiuser servers)
#!/usr/bin/expect -f
set screen "tt-rss"
set prompt "$"
set ttrss "~/public_html/tt-rss"
# open a new screen (reusing any existing 'tt-rss' screen)
spawn screen -D -R "$screen"
expect "$prompt"
@battis
battis / button_timing.ino
Created February 1, 2018 19:17
Button Timing
int buttonPin = 2;
int buttonState;
unsigned long timestamp;
void setup() {
// prepare ports for communication
pinMode(buttonPin, INPUT);
Serial.begin(9600);
@battis
battis / iTunesLibraryToggle
Last active August 21, 2018 13:09
Toggling between iTunes Libraries
#!/usr/bin/env bash
#
# usage: iTunesLibraryToggle [library] [playlist]
# e.g. iTunesLibraryToggle "$HOME/Music/iTunes (Music & Audiobooks)" Audiobooks
iTunesLibraryToggle() {
# make sure the iTunes directory is, in fact, a symlink
iTunesDir=$HOME/Music/iTunes
if [[ ! -d "$iTunesDir" || -L "$iTunesDir" ]] ; then