Skip to content

Instantly share code, notes, and snippets.

@MineRobber9000
MineRobber9000 / README.MD
Created March 2, 2016 22:54
Example for how to make a Button-Clicker style game.

(add this section to your readme.md)

Credits

MineRobber9000 - all of the "Button Clicker" style code.

@MineRobber9000
MineRobber9000 / chaninfo.py
Last active July 16, 2017 06:11
A small library for accessing channel info from the Twitch API.
import requests
class ChanInfoError(Exception):
pass;
class OfflineStreamOBJ: # fix for offline streams backported from APIv5 version
def __init__(self,id,name):
self.id = id
self.name = name # we know the name for sure so we can use it
self.message = "[OFFLINE]"
@MineRobber9000
MineRobber9000 / README.md
Created April 16, 2017 23:42
A python module for making python modules.

PyMod

PyMod is a library I wrote in the course of writing a Brainfuck to Python compiler. It allows programmatic generation of python programs/modules. Methods of the Program class are:

Program.addImport

Adds an import to the module. Takes arguments where moduleName is the name of a module or feature, and futureImport is a boolean stating if the first argument is a module or feature. (defaults to False)

Program.addLine

Adds a line to the program. Takes argument line which is the line to add.

@MineRobber9000
MineRobber9000 / README.md
Created June 22, 2017 00:50
A Python module for note systems

notes.py

A Python module for note systems.

Examples

import notes
notebook = notes.BasicNotebook()
# Add note to a user
notebook.addNote("TestUser1","TestUser2","This is a test message.")
# Check if a user has notes, and if so, show them their notes:
@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!")
@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 / 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 / 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 / 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 / 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())