Skip to content

Instantly share code, notes, and snippets.

View michaelfm1211's full-sized avatar

Michael M. michaelfm1211

  • 21:23 (UTC -05:00)
View GitHub Profile
@michaelfm1211
michaelfm1211 / xlog.c
Created February 2, 2024 04:53
libusb wired xbox 360 controller event logger
//compile:gcc -Wall -Wextra -Werror -pedantic -O3 $(pkg-config --cflags --libs
// libusb-1.0) -o $A0 $SRC
//dev:gcc -Wall -Wextra -Werror -pedantic -fsanitize=address
// -fsanitize=undefined -g $(pkg-config --cflags --libs libusb-1.0) -o $A0 $SRC
#include <libusb.h>
#include <stdio.h>
#include <unistd.h>
// this may need to be changed depending on your controller
@michaelfm1211
michaelfm1211 / wiki_reader.py
Created January 3, 2024 06:09
script to read
"""
wiki_reader.py - Crude script to read a wikipedia article from an offset and an article ID
To find an article ID, use bzgrep on
enwiki-latest-pages-articles-multistream-index.txt.bz2
For example (in my shell *index* expands to enwiki-latest-pages-articles-multistream-index.txt.bz2):
bzgrep "Python (programming language)" *index*
Requires the bzip2 compressed dumps of Wikipedia. Download
enwiki-latest-pages-articles-multistream-index.txt.bz2 and
@michaelfm1211
michaelfm1211 / airports.json
Created December 27, 2023 06:55
JSON list of airports, codes, names, and coordinates
{"ZPDQ":{"airportCodeIata":"DIG","airportName":"Deqen Shangri-La Arpt","cityName":"Deqen","cityType":"International","countryCode":"CN","region":"","meta":{"icaoCode":"ZPDQ","iataCode":"DIG","latitudeDegreeNum":27.7936000824,"longitudeDegreeNum":99.6772003174,"timeZoneDesc":"Asia/Shanghai"}},"KSGF":{"airportCodeIata":"SGF","airportName":"Springfield-Branson Rg","cityName":"Springfield","cityType":"Domestic","countryCode":"US","region":"MO","meta":{"icaoCode":"KSGF","iataCode":"SGF","latitudeDegreeNum":37.24570084,"longitudeDegreeNum":-93.38860321,"timeZoneDesc":"America/Chicago"}},"KFOE":{"airportCodeIata": "FOE","airportName":"Forbes Field","cityName":"Forbes Field","cityType":"Domestic","countryCode":"US","region":"United States","meta":{"icaoCode":"KFOE","iataCode":"FOE","latitudeDegreeNum":37.24570084,"longitudeDegreeNum":-93.38860321,"timeZoneDesc":"America/Chicago"}},"KBED":{"airportCodeIata":"BED","airportName":"Laurence G. Hanscom Field","cityName":"Laurence G. Hanscom Field","cityType":"Domestic","co
@michaelfm1211
michaelfm1211 / userscript.js
Last active July 31, 2023 15:29
Tampermonkey Userscript to use HTML Gmail as the default
// ==UserScript==
// @name Use HTML Gmail as Default
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Set the HTML version of Gmail as the default, and add an account switcher
// @author Michael M
// @match https://mail.google.com/mail/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @run-at document-start
@michaelfm1211
michaelfm1211 / morse_wav.py
Last active May 26, 2023 22:49
Morse code WAV file generator
from struct import pack
# WAV format reference: http://soundfile.sapp.org/doc/WaveFormat/
# one period of a sine wave in 8 samples
beep = bytes([0x80, 0xd9, 0xff, 0xd9, 0x80, 0x26, 0x01, 0x26]) * 80
# one period of silence
sil = bytes([80] * 8) * 80
# morse code
@michaelfm1211
michaelfm1211 / exkcd_shortcut.js
Created February 5, 2023 17:09
Tampermonkey script to show Explain XKCD links on xkcd.com
// ==UserScript==
// @name Explain XKCD shortcut
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Shows link to Explain XKCD on xkcd.com
// @author michaelfm1211
// @match https://xkcd.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
@michaelfm1211
michaelfm1211 / graph.py
Last active November 23, 2022 03:35
highly experimental and useless graphing program
from PIL import Image
from math import ceil
# these variables are not used everywhere and some parts just assume that they are both (100, 100).
# change at your own risk.
scale = (100, 100)
res = (100, 100)
@michaelfm1211
michaelfm1211 / poly.c
Last active September 26, 2022 14:12
simply polymorphic C program that changes it's own binary
// this program has been tested on macOS and Alpine Linux, but not Windows. Both
// GCC Clang and GNU GCC have also been tested to work. Ideally, this program
// should work on any x86-64 machine.
//
// the program assumes it's binary is called "poly", so you must change the
// source code if you want to rename the executable to anything else.
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
@michaelfm1211
michaelfm1211 / mouse-totp.py
Last active September 25, 2022 23:15
pyusb script to use an extra USB mouse with my totp program
# adapted from https://www.orangecoat.com/how-to/read-and-decode-data-from-your-mouse-using-this-pyusb-hack
# requirements:
# - macOS (although it may be adapted for linux)
# - pyusb (https://pypi.org/project/pyusb/)
# - my totp program (https://github.com/michaelfm1211/totp). you might be able to use another totp program
# - the accompanying totp-copy.sh (https://gist.github.com/michaelfm1211/32336940e1d27c4b2a44c9e3f665f26c). again, may be adapted for linux
# - terminal-notifier (https://github.com/julienXX/terminal-notifier). not stricly needed, but nice to have
import atexit
@michaelfm1211
michaelfm1211 / marquee.c
Last active September 25, 2022 23:04
C program that simulates the (deprecated) HTML <marquee> tag
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
bool rflag = false;
float speed = 0.05;