Skip to content

Instantly share code, notes, and snippets.

@ClearlyKyle
ClearlyKyle / AHT20_BMP280.c
Created March 15, 2024 19:24
AHT20 + BMP280 combined sensor example script
#include <Adafruit_AHTX0.h>
#include <Adafruit_BMP280.h>
Adafruit_AHTX0 aht = {};
Adafruit_BMP280 bmp = {}; // I2C
void setup()
{
Serial.begin(115200);
while (!Serial)
@ClearlyKyle
ClearlyKyle / background.js
Last active April 21, 2024 20:01
Basic chrome extension that sends a message to the background script, then captures a screenshot of the current web-page
// Function to convert data URL to Blob
function data_URL_to_blob(data_url)
{
var arr = data_url.split(',');
var mime = arr[0].match(/:(.*?);/)[1];
var bstr = atob(arr[1]);
var n = bstr.length;
var u8arr = new Uint8Array(n);
while (n--)
@ClearlyKyle
ClearlyKyle / c.json
Created December 4, 2023 11:47
VSCode snippets for generating a single-header defines. "#header-single" - generates a template for the header file to be used as a single-file header, "#header-guards" generates the standard guard macros to prevent multiple inclusions of a header file
"Create a single header C file": {
"prefix": "#header-single",
"body": [
"#ifndef __${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H__",
"#define __${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H__",
"$0",
"#endif // __${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H__",
"",
"#ifdef ${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_IMPLEMENTATION",
"#endif // ${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_IMPLEMENTATION"
@ClearlyKyle
ClearlyKyle / hellopeSDL2.odin
Created February 13, 2023 22:08
SDL2 Hello World | SDL2 Open Window Odin | SDL
package main
import "core:fmt"
import SDL "vendor:sdl2"
SCREEN_WIDTH : i32 = 640
SCREEN_HEIGHT : i32 = 480
main :: proc()
{
@ClearlyKyle
ClearlyKyle / crush.js
Last active January 6, 2023 11:00
Get sentences from languagecrush, and output them to a string format
/**
* Returns an array of strings representing the sentences (where they break)
* in the given HTML element (.reading-word-container).
* Words are joined by spaces, and there are spaces after punctuation marks.
*
* @param {HTMLElement} html - The HTML element containing the sentences.
* @return {string[]} An array of strings representing the sentences.
*/
function getSentences(html)
{
@ClearlyKyle
ClearlyKyle / spacy_sentences.py
Created January 6, 2022 11:08
SRT_Sentences_with_Spacy
import os
import pysrt
import spacy
output_folder_name = "txt"
try:
os.mkdir("./{}".format(output_folder_name))
except OSError:
pass # already exists
@ClearlyKyle
ClearlyKyle / colour.c
Created January 3, 2022 22:03
SDL_Colour to Uint32 for SDL_gfx
Uint32 SDL_Colour_To_Uint32(const SDL_Colour *col)
{
// Must be format AABBGGRR for gfx library
return (Uint32)((col->a << 24) + (col->b << 16) + (col->g << 8) + (col->r << 0));
}
SDL_Colour Uint32_To_SDL_Colour(const Uint32 colour)
{
SDL_Colour tmp;
tmp.a = (colour >> 24) & 0xFF;
@ClearlyKyle
ClearlyKyle / STR_to_Sentences.py
Created October 8, 2020 21:11
Using pysrt to convert a SRT file to a list of sentences.
import pysrt
import os
output_folder_name = "txt"
try:
os.mkdir("./{}".format(output_folder_name))
except OSError:
pass # already exists