Skip to content

Instantly share code, notes, and snippets.

View Philanatidae's full-sized avatar

Phil Philanatidae

View GitHub Profile
@Philanatidae
Philanatidae / isolate_video.js
Created November 29, 2022 16:18
Script to completely isolate the <video> element on a webpage
/*
This is a script (albeit a bit hacky) to isolate a webpage to its single <video> element.
Useful on website that have a <video> element surrounded by a bunch of garbage (ads, chat windows, etc.).
Doesn't work if there are multiple <video> elements (well, it might if <video> happens to be grabbed as the first element).
To use: Copy the script below, open developer console on webpage (right click >> inspect element >> console), paste, and hit enter.
*/
@Philanatidae
Philanatidae / Setting Up MSYS2 as Default Terminal.md
Last active February 12, 2023 02:26
Instructions to remind myself how to set up MSYS2 as my default terminal in Windows.

Setting Up MSYS2 as Default Terminal

  1. Download and install MSYS2: https://www.msys2.org/.
  2. Open MSYS2 and run pacman -Syu to update packages.
  3. Open file explorer and go to C:\msys64.
  4. Open all the INI files for the systems (clang32.ini, clang64.ini, mingw32.ini, mingw64.ini, msys2.ini) and uncomment the MSYS2_PATH_TYPE=inherit line. This allows the Windows $PATH variable to be included in the shells.
  5. Download and install Windows Terminal from the Windows store.
  6. Open the settings for Windows Terminal and click "Open JSON".
  7. Copy and paste the following objects into the "list" array under "profiles":
{
@Philanatidae
Philanatidae / main.m
Created February 11, 2021 23:18
Sine Wave Playback Example of Audio Queues
#include <string.h>
#include <math.h>
#include <unistd.h>
#include <assert.h>
#include <stdlib.h>
#import <CoreAudio/CoreAudio.h>
#import <AudioToolbox/AudioToolbox.h>
typedef struct soundState {
@Philanatidae
Philanatidae / FRC Encoders.md
Created February 16, 2019 20:51
Explanation and sample code of encoders for FRC Team 2927

Encoders in FRC

Encoders are hardware that measure rotation. The encoder generates pulses that contains the information.

Rotation is directly proportional to distance. One revolution of the encoder can relate to a certain amount of distance:

encoder ticks * K = distance, where K is the distance of one rotation divided by the ticks of one rotation. K is a decimal (double).

A very simple way of determining K is to read the encoder values (console, SmartDashboard, etc.) while rotating the encoder. For example, K for a drive train can be found by moving the robot forward one rotation of the wheels. The distance traveled is the circumference of the wheels, and the change in ticks (final tick - initial tick) can be found using the console/SmartDashboard. The units for distance can be arbitrarily chosen depending on the need.

@Philanatidae
Philanatidae / main.cpp
Created February 10, 2019 01:15
Example of using stb_vorbis with PortAudio (C++11)
/*
This is a simple example of playing an OGG file/stream with stb_vorbis
and PortAudio. This was my first time experimenting with stb_vorbis and
PortAudio. I wrote up this example if anybody else had trouble integrating
the two libraries.
This example uses C++11 since the project I am integrating PortAudio into is
C++11. I use `unique_ptr` and lambda functions, but they are not requirements.
Since this was a quick example I have very little error checking. If you
@Philanatidae
Philanatidae / state_machine_ex.lua
Created October 5, 2017 03:40
Basic state machine in Lua
-- States
stateA = {}
function stateA:onStart()
-- Called when state is switched to this state
end
function stateA:render(dt)
-- Called every frame
end
function stateA:onEnd()
-- Called when state is switched from this state