Skip to content

Instantly share code, notes, and snippets.

View bmwalters's full-sized avatar

Bradley Walters bmwalters

  • Affirm
  • United States
View GitHub Profile
@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 / 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 / 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 / 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
-- 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
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
@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 = {
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 / npmify.lua
Created January 8, 2017 04:04
Load Lua modules from the node_modules folder!
local string = require("string")
local pathlib = require("pl.path")
local filelib = require("pl.file")
local function split(str, sep)
local ret = {}
local last_sep = 1
for i = 1, #str do
if string.byte(str, i, i) == string.byte(sep) then
@bmwalters
bmwalters / hoax.lua
Last active February 14, 2017 14:29
ES2015 Promises implemented in Lua 5.3
local function check_callable(o)
return type(o) == "function" or type(getmetatable(o).__call) == "function"
end
local PromiseState = {
pending = "pending",
fulfilled = "fulfilled",
rejected = "rejected"
}