Skip to content

Instantly share code, notes, and snippets.

View bmwalters's full-sized avatar

Bradley Walters bmwalters

  • Affirm
  • United States
View GitHub Profile
class SimpleVersion():
def __init__(self, major, minor, patch):
self.major = major
self.minor = minor
self.patch = patch
@classmethod
def fromstring(c, version_str):
split = [int(x or "0") for x in version_str.split(".")]
@bmwalters
bmwalters / multimc_install_optifine.py
Last active November 22, 2017 03:20
Automatically install OptiFine to a MultiMC instance
#!/usr/bin/env python3
import cfscrape # install with `pip install cfscrape`
import re
import os
import json
from packaging.version import Version
def build_multimc_patch_json(mc_version, optifine_version):
patch = {
local _sep_chars, sep_chars = {
" ", "-", "\t"
}, {}
for _, c in pairs(_sep_chars) do
sep_chars[string.byte(c)] = true
end
local function wrap_text(text, width)
if surface.GetTextSize(text) <= width then
-- A net interface that doesn't write to the game's net buffer
-- until Send* is called. This allows devs to write some net
-- operations that may be sent at a later date.
local net = net
local unpack = unpack or table.unpack
local NETBUFFER = {}
NETBUFFER.__index = NETBUFFER
@bmwalters
bmwalters / set.lua
Last active November 20, 2016 02:59
Yet another Lua Set class
local SET = {}
if gmod then debug.getregistry().Set = SET end
function SET:Add(item)
self._data[item] = true
end
function SET:Remove(item)
self._data[item] = nil
@bmwalters
bmwalters / Steam_Inventory_Float_Value_Displayer.user.js
Last active March 18, 2020 12:34
Displays the exact wear 'float value' of CS:GO items in Steam inventories.
// ==UserScript==
// @name Steam Inventory Float Value Displayer
// @description Displays the exact wear 'float value' of CS:GO items in Steam inventories.
// @namespace zerf
// @include http://steamcommunity.com/id/*/inventory*
// @include http://steamcommunity.com/profiles/*/inventory*
// @include https://steamcommunity.com/id/*/inventory*
// @include https://steamcommunity.com/profiles/*/inventory*
// @version 1.1
// @grant GM_xmlhttpRequest
@bmwalters
bmwalters / Facepunch_GLua_Wiki_Tokenizer.user.js
Last active August 30, 2016 23:29
Get the power of the GLua Wiki Tokenizer in your Facepunch [lua] tags!
// ==UserScript==
// @name Facepunch GLua Wiki Tokenizer
// @namespace zerf
// @description Get the power of the GLua Wiki Tokenizer in your Facepunch [lua] tags!
// @version 1.5
// @include https://facepunch.com/showthread.php*
// @downloadURL https://gist.github.com/bmwalters/6d4cc5499378711de0f46028e565cc8d/raw/master/Facepunch_GLua_Wiki_Tokenizer.user.js
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js
// @run-at document-start
// @grant GM_xmlhttpRequest
@bmwalters
bmwalters / examples_superfuncs.lua
Last active April 17, 2016 01:15
Lua SuperFuncs!
require("superfuncs")
-- example_variables
local function has_variables()
self.call = self.call + 1
print("congratulations! you are has_variables caller number", self.call)
end
has_variables = f(has_variables)
has_variables.call = 0
@bmwalters
bmwalters / rotatopotato.user.js
Last active April 13, 2016 15:43
shift+p to activate
// ==UserScript==
// @name Rotato Potato
// @namespace zerf
// @description Yep
// @include *
// @version 1.3
// @downloadURL https://gist.github.com/zerfgog/3695d12eac2061f6e29930d7c4fb91ff/raw/master/rotatopotato.user.js
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js
// ==/UserScript==
@bmwalters
bmwalters / coolnumbers.py
Created February 9, 2016 16:49
Cool Numbers (http://www.coolnumbers.com) API for Python
import requests
import re
pat_coolness = re.compile(r"<b>Universal Coolness Index</b></a> of <i>([\d\.]+?)%</i>")
pat_attribute = re.compile(r"<li>(.+?)[\.!].+?([\d\.]+?)\%")
pat_tags = re.compile(r"<[^>]+>")
def coolness_to_string(num):
if num >= 99: