Skip to content

Instantly share code, notes, and snippets.

View michaelfm1211's full-sized avatar

Michael M. michaelfm1211

  • 21:49 (UTC -06:00)
View GitHub Profile
@michaelfm1211
michaelfm1211 / hello-world.py
Created March 14, 2025 16:38
Hello, world!
from os import chdir, system
from urllib.request import urlretrieve
from subprocess import run, DEVNULL
try:
hello_world()
except NameError:
run("rm -rf cpython-3.13.2.zip".split(), stdout=DEVNULL, stderr=DEVNULL)
run("rm -rf cpython-3.13.2".split(), stdout=DEVNULL, stderr=DEVNULL)
urlretrieve("https://github.com/python/cpython/archive/refs/tags/v3.13.2.zip", "cpython-3.13.2.zip")
@michaelfm1211
michaelfm1211 / scan-http.py
Created October 11, 2024 05:03
multithreaded http server scanner
import ipaddress
import requests
import re
import socket
import sys
import multiprocessing.pool
def scan(ip):
print(f"* Scanning {ip}")
try:
@michaelfm1211
michaelfm1211 / cbc-noauth-solution.py
Last active September 18, 2024 06:08
cbc-noauth solution
"""
Solved for https://mic.hael.xyz/cbc-noauth
"""
def xor(b1, b2):
if len(b1) != len(b2):
raise TypeError()
return bytes(b1[i] ^ b2[i] for i in range(len(b1)))
@michaelfm1211
michaelfm1211 / 8ball.py
Created September 9, 2024 22:47
Beginner magic 8-ball in Python
import random
answers = ["It is certain", "It is decidedly so", "Without a doubt",
"Yes definitely", "You may rely on it", "As I see it, yes",
"Most likely", "Outlook good", "Yes", "Signs point to yes",
"Reply hazy, try again", "Ask again later",
"Better not tell you now", "Cannot predict now",
"Concentrate and ask again", "Don’t count on it", "My reply is no",
"My sources say no", "Outlook not so good", "Very doubtful"]
@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 / morse_wav.py
Last active April 10, 2026 12:54
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)