Skip to content

Instantly share code, notes, and snippets.

View bmwalters's full-sized avatar

Bradley Walters bmwalters

  • Affirm
  • United States
View GitHub Profile
function unrequire( modName )
if( not modName ) then return end
local _R = debug.getregistry()
local moduleMetatable = _R["_LOADLIB"]
package.loaded[ modName ] = nil
_G[ modName ] = nil
for k, ud in pairs( _R ) do
if( (type(k) == "string") and string.find( k, "^LOADLIB: .+gm.._" .. modName .. "_.+%.dll$" ) and (type(ud) == "_LOADLIB") and (getmetatable(ud) == moduleMetatable) ) then
print( "Unloading: " .. k )
FROM debian:jessie
RUN apt-get update && apt-get install -y \
build-essential \
ca-certificates \
curl \
binutils-dev \
libmad0-dev \
libgtk2.0-dev \
libasound-dev \
@maca
maca / das_download.rb
Created February 11, 2012 09:08
Script to download all Destroy All Software screencasts, account needed
#! /usr/bin/env ruby
# usage:
# $ das_download.rb email password [download_directory]
require 'mechanize'
# gem 'mechanize-progressbar'
email = ARGV[0] or raise('Please provide the email address for your account')
password = ARGV[1] or raise('Please provide the password for your account')
path = ARGV[2] || './'
@i-am-scott
i-am-scott / gist:10386462
Created April 10, 2014 14:10
Gmod lua_error_url
<?php
/*
Gmod Command (Including quotes!):
lua_error_url "http://example.com/log_errors.php"
Expected POST data
Array
(
[v] => 4
local red = Color(255,0,0)
local green = Color(0,255,0)
local function log(color,s)
MsgC(color,s .. "\n")
end
function mdmp(out)
local files,_ = file.Find("*.mdmp","BASE_PATH")
if out then log(red,"Found " .. #files .. " files!") end
@mentlerd
mentlerd / sh_grep.lua
Created January 28, 2015 12:10
Pretty printing for gmod13
-- Global 'nil' value
NIL = {}
-- Localise for faster access
local pcall = pcall
local string_len = string.len
local string_sub = string.sub
local string_find = string.find
@ssp
ssp / git-extract-file.markdown
Created January 23, 2012 13:21
Extract a single file from a git repository

How to extract a single file with its history from a git repository

These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).

First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter (2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.

Finally all remaining files are listed using git ls, the files to keep are removed from that using grep -v and the resulting list is passed to git rm which is invoked by git filter-branch --index-filter (3.). A bit convoluted but it does the trick.

1. copy the repository to extract the file from and go to the desired branch

Exploiting Lua 5.1 on 32-bit Windows

The following Lua program generates a Lua bytecode program called ignore-unsigned-sga.fnt, which in turn loads a DLL from within an extremely locked down Lua 5.1 sandbox in a program called RelicCOH2.exe. The remainder of this document attempts to explain how this program works by a whirlwind tour of relevent bits of the Lua 5.1 virtual machine.

if string.dump(function()end):sub(1, 12) ~= "\27Lua\81\0\1\4\4\4\8\0" then
  error("This generator requires a 32-bit version of Lua 5.1")
end

local function outer()
  local magic -- In bytecode, the stack slot corresponding to this local is changed
@steevp
steevp / openmw_steam.py
Last active January 17, 2024 10:42
Launch openmw and have Steam track your gameplay hours, etc as if you were playing Morrowind
#!/usr/bin/env python
import os
import sys
from ctypes import CDLL
from subprocess import call
# Morrowind
os.environ["SteamAppId"] = "22320"
# Enable Steam Overlay
@haasn
haasn / about:config.md
Last active April 2, 2024 18:46
Firefox bullshit removal via about:config

Firefox bullshit removal

Updated: Just use qutebrowser (and disable javascript). The web is done for.