Skip to content

Instantly share code, notes, and snippets.

@johnholbrook
johnholbrook / ADDVEC
Created January 26, 2017 03:18
TI-83/84 BASIC program to add arbitrarily many 2D vectors
Degree
0->X
0->Y
Input "How many to add?", N
While N>0:
0->S
0->T
Input "Magnitude: ", S
Input "Angle (deg): ", T
X+Scos(T)->X
@johnholbrook
johnholbrook / f1_anthem_count.py
Last active June 17, 2017 19:01
Counts the number of times each national anthem has been played on an F1 podium
from json import loads
from urllib2 import urlopen
data = loads(urlopen("http://ergast.com/api/f1/results/1.json?limit=1000").read())["MRData"]["RaceTable"]["Races"]
totals = {}
for race in data:
driver_nat = race["Results"][0]["Driver"]["nationality"]
constructor_nat = race["Results"][0]["Constructor"]["nationality"]
@johnholbrook
johnholbrook / sentinal.cc
Created September 26, 2017 23:47
C++ sentinal loop example
#include <iostream>
double todayHigh, todayLow, monthHigh, monthLow;
//this is the "sentinal input" (or something). It runs only once, before
//we enter the loop, and provides input for the first execution of the
//loop only.
cout << "Enter today's high: ";
cin >> todayHigh;
@johnholbrook
johnholbrook / template_ex.cc
Last active December 15, 2017 04:02
c++ template example
#include <iostream>
template <class T>
class ArbitratyList{
ArbitraryList(){
count = 0;
}
T list[4];
int count;
void add(T tmp){
@johnholbrook
johnholbrook / electric_vehicle.c
Created March 24, 2018 20:26
Code for 2016 Huntington HS Science Olympiad Electric Vehicle. Video at https://youtu.be/nu0Z7hJpxFk.
#pragma config(UART_Usage, UART1, uartVEXLCD, baudRate19200, IOPins, None, None)
#pragma config(UART_Usage, UART2, uartNotUsed, baudRate4800, IOPins, None, None)
#pragma config(Sensor, in8, selector, sensorPotentiometer)
#pragma config(Sensor, dgtl1, qEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, button, sensorTouch)
#pragma config(Motor, port7, drive, tmotorServoContinuousRotation, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#define COUNTS_TO_CM (3.1416 * 6.985)/360 //pi * wheel diameter
#define STOP_MOVING_DIST 150 //in cm
@johnholbrook
johnholbrook / binary_arith_template.tex
Created April 20, 2018 20:32
LaTeX array for binary addition / subtraction
$\begin{array}{lllllllllllllllllllllllllllllllll}
& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ %carry digits
& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ %1st number
+ & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ %2nd number
\hline
& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ %result
\end{array}$
Tx: 55 ff 00 10 ef 10 ef
reading 7 bytes, timeout = 500
reading 1 byte, timeout = 500
Rx: 00 ef ed 10 ff
Retrying...
Tx: 55 ff 00 10 ef 10 ef
reading 7 bytes, timeout = 500
Rx: 55 ff 00 ef 10 ef 10
Tx: 55 ff 00 15 ea 01 fe 03 fc 05 fa 07 f8 0b f4 30 cf
reading 23 bytes, timeout = 500
<?php
echo "Hello World!";
function make_packet($data)
{
$bytes = str_split($data, 2);
$buffer = "\x55\xff\x00";
$sum = 0;
foreach ($bytes as $byte) {
$byte = hexdec($byte);
$sum += $byte;
@johnholbrook
johnholbrook / view_post_source.js
Last active June 26, 2019 19:03
Tampermonkey script to add 'view post source' button to Discourse forum posts
// ==UserScript==
// @name Discourse View Post Source
// @namespace jholbrook
// @author John Holbrook
// @version 0.1
// @description Adds a 'view post source' button to posts on Discourse forums
// @website https://gist.github.com/dhmmjoph/77edfd56cd54e65acbd4877e3154458a
//Change these or add aditional sites here:
// @match https://www.vexforum.com/t/*
for i in {1..30}
do
echo "Loop $i"
youtube-dl -a list.txt
done