Skip to content

Instantly share code, notes, and snippets.

View battis's full-sized avatar

Seth Battis battis

View GitHub Profile
@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
@battis
battis / add_timezone_to_ics.php
Last active July 30, 2017 18:26
PHP Script to Add Time Zones to iCalendar/vCal Feeds
<?php
$filename = "calendar";
if (isset($_GET["url"])) {
$url = $_GET["url"];
if (!isset($_GET["show_url"])) {
preg_match("|.+\/([^?]+)\??|", $url, $matches);
if (isset ($matches[1])) {
@battis
battis / google_reader_to_wordpress.php
Created July 30, 2017 18:16
Transmogrifying those Google Reader JSON dumps into something useful
/**********************************************************************
* Google Reader to Wordpress
*
* 2011-11-27
* Seth Battis (seth@battis.net)
*
* This script takes the output of Google Reader's JSON export of
* shared items and converts it into an XML file that can be imported
* into a Wordpress blog as posts. All of the data in the original JSON
* file is preserved in the XML file, either by transfering it to