Skip to content

Instantly share code, notes, and snippets.

View ChaunceyHoover's full-sized avatar

Chauncey Hoover ChaunceyHoover

View GitHub Profile
@ChaunceyHoover
ChaunceyHoover / frequencies.h
Last active October 2, 2022 17:36
A simple note-to-frequency header file, aimed for those who like to play with Window.h's `Beep` function. Also includes a Note-to-Millisecond macro for those aiming to make some moonbase-alpha tier music.
#ifndef HEADER_FREQUENCY_H
#define HEADER_FREQUENCY_H
// Taken from http://www.phy.mtu.edu/~suits/notefreqs.html
// Rounded to nearest number
// Format: <note><octave>(sharp/flat)
// Ex: C5S = C# note in 5th octave
#define C0 16
#define C0S 17
#define D0F C0S
@ChaunceyHoover
ChaunceyHoover / sleep.lua
Last active January 26, 2023 16:17
Lua asynchronous and synchronous sleeping
function sleep(time, func, ...)
local now = os.time()
local thread = coroutine.create(func)
repeat until (os.time() - now > time)
coroutine.resume(thread, ...)
end
function asleep(time, func, ...)
coroutine.wrap(function()
local now = os.time()
import time
import colorsys
import RPi.GPIO as GPIO
import Adafruit_WS2801
import Adafruit_GPIO.SPI as SPI
PIXEL_COUNT = 160
BRIGHTNESS = 0.05
@ChaunceyHoover
ChaunceyHoover / meme-speak.ahk
Created July 17, 2018 00:35
Meme-Speak™ - rEPeaTEdLy turNs caPS LOCK oN and ofF sO yoU Can SPeAK LiKE ReaL memERs
; Meme-Speak™ - rEPeaTEdLy turNs caPS LOCK oN and ofF sO yoU Can SPeAK LiKE ReaL memERs
Repeat = False
; Turns meme-speak on
F1::
Repeat := True
while (Repeat) {
SetCapsLockState, on
Sleep, 10
SetCapsLockState, off
@ChaunceyHoover
ChaunceyHoover / String separator.lua
Last active August 8, 2019 12:56
Simple separator/explode function for Lua
function explode(input, separator)
if input:len() == 0 then return {} end
if input:len() == 1 then return { input } end
separator = type(separator) == "string" and separator:sub(1, 1) or tostring(separator)
local results = {}
local lastPos = 1 -- Note: in Lua, '1' is the start of everything, including strings
for i = 1, input:len() do -- or: for i = 1, string.len(input) do
if string.sub(input, i, i) == separator then -- or: if input:sub(i, i) == separator then
@ChaunceyHoover
ChaunceyHoover / String Generator.lua
Created August 8, 2019 12:56
Simple lua string generator
function rand_str(len)
len = tonumber(len) or 1
local function rand_char()
return math.random() > 0.5
and string.char(math.random(65, 90))
or string.char(math.random(97, 122))
end
local function rand_num()
return string.char(math.random(48, 57))
@ChaunceyHoover
ChaunceyHoover / Case Insensitive Pattern Generator.lua
Created August 8, 2019 12:58
A simple pattern/filter generator. Could be useful for a blacklist of words or something, probably.
function case_insensitive_pattern(pattern)
local p = pattern:gsub("(%%?)(.)", function(percent, letter) -- match regex
if percent ~= "" or not letter:match("%a") then
-- if % is matched or 'letter' is not a letter
return percent .. letter
else
return string.format("[%s%s]", letter:upper(), letter:lower())
end
end)
return p
@ChaunceyHoover
ChaunceyHoover / ComputerCraft Matrix Program.lua
Last active August 8, 2019 13:02
A useful server welcome program for ComputerCraft, complete with hackermans style tendrils in the background. Can be used to show server rules and other important messages.
--[[ Configuration ]]--
-- Max amount of tendrils on screen at a time
max_tendrils = 50
-- How fast the screen updates
-- note: Setting it to 0 or less will cause program to not work properly
update_speed = 0.25
-- Possible colors tendrils can be
-- note: the more you put the same color in a table, the more likely it is to be chosen
@ChaunceyHoover
ChaunceyHoover / music-fixer-upper-symbols.sh
Last active March 2, 2020 07:30
Run in Music folder - removes all special characters from file name
for d in ./*/
do
cd $d
for file in ./*
do
infile=`echo "${file:2}"|sed \
-e 's|"\"|"\\"|g' \
-e 's| |\ |g' -e 's|!|\!|g' \
-e 's|@|\@|g' -e 's|*|\*|g' \
-e 's|&|\&|g' -e 's|]|\]|g' \
@ChaunceyHoover
ChaunceyHoover / music-fixer-upper-format.sh
Last active March 3, 2020 06:04
Run in Music folder - Removes artist name from album folder. NOTE: Comment out "mv" to make sure nothing unexpected happens
# Fixes error generated from using `mv` with files that have spaces in names
IFS='
'
for d in ./*/
do
cd "$d"
for f in ./*/
do
cd "$f"