Skip to content

Instantly share code, notes, and snippets.

@MineRobber9000
MineRobber9000 / donotuse3.py
Last active February 8, 2024 12:48
How to NEVER use lambdas - Python 3 edition
###########################################################
# How to NEVER use lambdas. An inneficient and yet educa- #
# tonal [sic] guide to the proper misuse of the lambda #
# construct in Python 3.x. [DO NOT USE ANY OF THIS EVER] #
# original by (and apologies to): e000 (13/6/11) #
# now in Python 3 courtesy of: khuxkm (17/9/20) #
###########################################################
## Part 1. Basic LAMBDA Introduction ##
# If you're reading this, you've probably already read e000's
@MineRobber9000
MineRobber9000 / broadcast_with_metadata.liq
Created July 26, 2020 03:23
Broadcast from liquidsoap with custom metadata
#!/usr/bin/liquidsoap
set("log.file", false)
# Allow a UNIX domain socket server. (You can make a telnet server, but the UNIX domain socket is easier for me to grok.)
set("server.socket",true)
set("server.socket.path","/home/khuxkm/RadioMineRobber/socket")
# This is your input source. In this example, it's just the tracks from `tracks.pls`, but it could be soundcard input or line-in
pl = mksafe(playlist("tracks.pls"))
@MineRobber9000
MineRobber9000 / README.md
Created July 7, 2020 03:29
Import Python modules from GitHub

githubimport

Allows you to import Python modules from the top level of a GitHub repository. Basically, golang's import semantics but in Python fashion.

>>> import githubimport
>>> from MineRobber9000.test_modules import blah
>>> blah.foo()
"bar"
@MineRobber9000
MineRobber9000 / README.md
Created June 21, 2020 09:10
Gopher transport adapter for python-requests

requests_gopher

A transport adapter to make gopher requests from python-requests. Here be dragons.

I've documented most of this shit with my comments, but I seriously warn you, for your own sanity: don't do this. Don't use this, don't try and write your own transport adapter, there's just so much weird crap you have to deal with. Just take a look, maybe test it once or twice, say "neat", and walk away.

@MineRobber9000
MineRobber9000 / README.md
Last active April 27, 2025 19:58
A small script that prints function signatures based on ast.FunctionDef objects. Handles hint typing and defaults.

print_funcdefs.py

A small script that prints function signatures based on ast.FunctionDef objects. Handles hint typing and defaults.

Usage:

$ python print_funcdefs.py -h
usage: print_funcdefs.py [-h] [-v] file

Prints function signatures from a file (based on the AST representation).
#!/usr/bin/python3
import cgi, wikipedia, os, sys, traceback, wikipedia.exceptions
from urllib import parse
wikipedia.USER_AGENT = "uwupedia (https://gist.github.com/MineRobber9000/803840e86f386d438608eb85920b6a6a)"
# inline uwu
SUBSTITUTES = dict(
l="w",
r="w",
L="W",
@MineRobber9000
MineRobber9000 / 2fa
Created April 3, 2020 03:45
2-factor authentication terminal app in Python
#!/usr/bin/env python
import os, os.path, stat, sys, base64
# TOTP lib inlined
import time, hmac, base64, hashlib, struct
def pack_counter(t):
return struct.pack(">Q", t)
@MineRobber9000
MineRobber9000 / README.md
Last active March 13, 2020 06:52
A brainfuck of a Brainfuck interpreter in Python.

bfbf.py

A brainfuck of a Brainfuck interpreter. Written at 2 in the morning, because who needs sleep? (Answer: me. I didn't even really I named the main class BFInterpeter until it caused an error.)

How the fuck does it work?

So the AST mumbo-jumbo creates a class, BFInterpreter, that has one method: a @classmethod'd method called interpret. This implements the core tenets of

@MineRobber9000
MineRobber9000 / README.md
Created March 4, 2020 00:54
TOTP and HOTP implemented in Python

totp.py

A simple library. Despite its name, it does TOTP and HOTP. To do a TOTP:

import totp, base64

secret = base64.b32decode("ABCDEFGHIJKLMNOP")
code = totp.totp(secret)
if code==input("Insert TOTP here:").strip(): print("Success")
@MineRobber9000
MineRobber9000 / README.md
Created February 12, 2020 13:27
A python library for corrupting text and binaries.

fragmentation.py

A python library for corrupting text and binaries.

Methods

fragment.corrupt(binary: bytes, count: int?)

Arguments: