Skip to content

Instantly share code, notes, and snippets.

View TechplexEngineer's full-sized avatar

Blake Bourque TechplexEngineer

View GitHub Profile
@TechplexEngineer
TechplexEngineer / joystic_ioctl_test.c
Created September 23, 2024 13:14
Test to get Joystick Ioctl
#include <stdio.h>
#include <linux/joystick.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/input.h>
#define KEY_MAX_LARGE 0x2FF
#define KEY_MAX_SMALL 0x1FF
#define JSIOCSBTNMAP_LARGE _IOW('j', 0x33, __u16[KEY_MAX_LARGE - BTN_MISC + 1])
@TechplexEngineer
TechplexEngineer / pi_play_sound.js
Created September 8, 2024 20:48
Nodejs play sound on raspberry pi with child proces
import { spawn } from 'child_process';
const process = spawn('mpg321', ["-q", "/home/pi/r2_control/sounds/HUM__014.mp3", '-g', "50"]);
let stdOut = [];
let stdErr = [];
process.stdout.on('data', (data) => {
stdOut.push(data);
});
@TechplexEngineer
TechplexEngineer / FIRST_Export_Roster.js
Created October 24, 2022 20:34
Export team roster from FIRST dashboard
(()=>{
function convertToCSV(arr) {
const array = [Object.keys(arr[0])].concat(arr)
return array.map(it => {
return Object.values(it).toString()
}).join('\n')
}
if (typeof ContactRosterModel == "undefined") {
@TechplexEngineer
TechplexEngineer / sortPlaylist.js
Last active October 31, 2022 01:22
Added support for Round Robin "RR"
(() => {
// -----------------------------------------------------------------
// CONFIG (you're safe to edit this)
// -----------------------------------------------------------------
// ~ GLOBAL CONFIG
// -----------------------------------------------------------------
const MODE = 'sort_playlist'; // 'publish_drafts' / 'sort_playlist';
const DEBUG_MODE = true; // true / false, enable for more context
// -----------------------------------------------------------------
// ~ PUBLISH CONFIG
@TechplexEngineer
TechplexEngineer / FC_Extract.js
Last active November 24, 2023 16:26
Extract first choice priority list to tab separated values for pasting into a spreadsheet
// ---- First extract the table headers
hdrs = []
$("#PriorityTable tr.cart-header-row").each((idx, row) => {
$("th", row).each((idx2, col)=>{
hdrs.push($(col).text())
})
})
hdrs.push("Part Number")
// console.log("Headers:",hdrs)
@TechplexEngineer
TechplexEngineer / parse.js
Created December 24, 2019 14:52
parse rules from FRC game manual
const ruleData = [];
$('p[class$="Rule"],p[class$="Rules"]').each((idx, rule) => {
const ruleObj = {};
const ruleText = $(rule).find('span:first').text().match(/([A-Za-z])([0-9]+)/i);
if (_.isNull(ruleText)) { return true; }
ruleObj.section = ruleText[1];
ruleObj.number = ruleText[2];

Keybase proof

I hereby claim:

  • I am techplexengineer on github.
  • I am techplex (https://keybase.io/techplex) on keybase.
  • I have a public key ASCZD0EJzrxNgUHnfD0q0_Dz1zHITZzOuWy2Xg0Y4Bn4rQo

To claim this, I am signing this object:

// --------------------------------------
// i2c_scanner
//
// Version 1
// This program (or code that looks like it)
// can be found in many places.
// For example on the Arduino.cc forum.
// The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
// Adapted to be as simple as possible by Arduino.cc user Krodal
// Simple Arithmetics Grammar
// ==========================
//
// Accepts expressions like "2 * (3 + 4)" and computes their value.
Expression
= head:Term tail:(_ ("+" / "-") _ Term)* {
return tail.reduce(function(result, element) {
if (element[1] === "+") { return result + element[3]; }
if (element[1] === "-") { return result - element[3]; }
def main():
client = TwitchClient(client_id='a57grsx9fi8ripztxn8zbxhnvek4cp')
# Monkey patch TwitchClient.users to add get_by_name https://github.com/tsifrer/python-twitch-client/pull/52
from types import MethodType
from twitch.resources import User
def get_by_name(self, user_ids):
if isinstance(user_ids, str):
user_ids = [user_ids]