Skip to content

Instantly share code, notes, and snippets.

@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:

@MineRobber9000
MineRobber9000 / square.py
Last active January 3, 2020 09:07
A library that squares a number, obfuscated using AST objects to make it harder to read
import sys
from ast import *
module=Module(body=[FunctionDef(name='square',args=arguments(args=[arg(arg='x',annotation=None,lineno=1,col_offset=1)],vararg=None,kwonlyargs=[],kw_defaults=[],kwarg=None,defaults=[],lineno=1),body=[Return(value=BinOp(left=Name(id='x',ctx=Load(),lineno=1,col_offset=1),op=Pow(),right=Num(n=2,lineno=1,col_offset=1),lineno=1,col_offset=1),lineno=1,col_offset=1)],decorator_list=[],returns=None,lineno=1,col_offset=1)])
modobj=type(sys)(__name__)
exec(compile(module,"<ast>","exec"),None,modobj.__dict__)
sys.modules[__name__]=modobj
@MineRobber9000
MineRobber9000 / README.md
Created December 28, 2019 05:26
A simple struct setup.

pack

A simple, elegant, and efficient struct system in Python using metaclasses.

@MineRobber9000
MineRobber9000 / bot.py
Last active December 5, 2019 16:31
Coin flip bot
import teambot, tasks, time, re
NICK = ""
NS_PASS = ""
VAULT = ""
CHANNELS = []
REDEEM_FAILURE = re.compile(r"Please wait (\d+m )?(\d+s)")
REDEEM_SUCCESS = re.compile(r"Redeemed ([0-9.]+) coins")
MESSAGE_FORMAT = re.compile(r"\S+ flips heads and (wins|loses) [0-9.]+ coins! \(new total: ([0-9.]+)\)")
@MineRobber9000
MineRobber9000 / mkgist
Last active November 14, 2019 15:59
Command line tool to make gists
#!/usr/bin/env python3
import requests, argparse, configparser, os.path, json
config = configparser.ConfigParser()
config.read(os.path.expanduser("~/.config/github.ini"))
creds = config["credentials"]
def read_file(fn):
with open(fn) as f: return dict(content=f.read())
@MineRobber9000
MineRobber9000 / csv2sqlite.py
Created November 6, 2019 16:47
CSV to SQLite database.
import sqlite3, csv, sys, re
DIGIT = re.compile("0([box])(\d+)")
def get_type(s):
if s.isdigit(): return "INTEGER", int
m = DIGIT.match(s)
if not m: return "TEXT", str
base, num = m.groups()
if base=="x": return "INTEGER", lambda x: int(x,16)
elif base=="o": return "INTEGER", lambda x: int(x,8)
@MineRobber9000
MineRobber9000 / csv2md.py
Created October 17, 2019 18:25
CSV to Markdown table generator.
import csv,sys
assert len(sys.argv) in (2,3),"Usage: csv2md.py <input_file> [output_file]"
# assumes top row is table headers
with open(sys.argv[1]) as f: rows = list(csv.reader(f))
max_row_length = max(*[len(r) for r in rows])
for row in rows:
@MineRobber9000
MineRobber9000 / scramble_solver.py
Created August 24, 2019 19:41
Solve a word scramble (such as "what word is made from the letters 'ysujfit'?")
#!/usr/bin/python3
import argparse
# This is the list of words that will be used to search for the word.
# Format is one word per line.
# The script will ignore lines starting with a hash.
WORDLIST = "/usr/share/dict/words" # default word list on most Linux boxen
def str_sorted(word):
"""Returns a string with sorted characters."""
@MineRobber9000
MineRobber9000 / Code.gs
Last active December 8, 2018 05:33
MRANK function for Google Sheets
function MRANK(value,values) {
var values = values.map(function(x) { return x[0]; }); // apparently I misjudged how Google Sheets passes values. Why is it like this?!?!
var valuesSorted = values.sort(function(a,b){ return b-a; });
var valuesUnique = valuesSorted.filter(function(value,index,self) { return self.indexOf(value) === index; });
var index = valuesUnique.indexOf(value);
if (index<0) {
throw("MRANK has no valid input data");
}
return index+1;
}
@MineRobber9000
MineRobber9000 / basic.lua
Created July 2, 2017 22:21
A WIP BASIC interpreter for ComputerCraft
local function _W(f) local e=setmetatable({}, {__index = _ENV or getfenv()}) if setfenv then setfenv(f, e) end return f(e) or e end
print("BASIC interpreter?")
print("Programmer lazy.")
print("Understandable, have a great day!")