Skip to content

Instantly share code, notes, and snippets.

View samuelmaddock's full-sized avatar

Sam Maddock samuelmaddock

View GitHub Profile
@samuelmaddock
samuelmaddock / srcds_fastdl.bat
Last active March 7, 2021 23:58
Simple FastDL script written using Python 2.7.3 with the bz2 library.
start srcds_fastdl.py "/source" "/target"
@samuelmaddock
samuelmaddock / cl_init.lua
Last active December 17, 2015 00:19
Alternate implementation of Garry's Mod view model hands without using player classes.
function GM:PostDrawViewModel( vm, ply, weapon )
if ( !IsValid( weapon ) ) then return false end
if ( weapon.UseHands || !weapon:IsScripted() ) then
local hands = ply:GetHands()
if ( IsValid( hands ) ) then
hands:DrawModel()
end
@samuelmaddock
samuelmaddock / Screen Radial Clamp.lua
Last active December 20, 2015 10:58
Clamps a given 2D screen coordinate to a radial space. Created for the game Garry's Mod.
local math = math
function ScreenRadialClamp(x,y,padding)
local w, h = ScrW(), ScrH()
local ratio = w / h
-- Default padding is 10% of the screen height
padding = padding or h * 0.1
@samuelmaddock
samuelmaddock / MSQP.go
Created October 22, 2013 02:01
Go script to query Valve's Master Server using the Master Server Query Protocol described here: https://developer.valvesoftware.com/wiki/Master_Server_Query_Protocol
package main
import (
"net"
"os"
"bytes"
"encoding/binary"
"fmt"
"time"
)
@samuelmaddock
samuelmaddock / twitch_hostname.lua
Created January 5, 2014 23:32
Twitch.TV live hostname
if not SERVER then return end
local STREAM_API_URL = "https://api.twitch.tv/kraken/streams/%s"
local STREAM_HOSTNAME = "%s | twitch.tv/%s"
local CvarFlags = { FCVAR_ARCHIVE, FCVAR_DONTRECORD }
local TwitchPingDelay = CreateConVar( "twitch_pingdelay", 2 * 60, CvarFlags,
"Frequency in which the Twitch.TV stream will be pinged." )
local TwitchChannelCvar = CreateConVar( "twitch_channel", "", CvarFlags,
"Twitch.TV channel to append to the server hostname." )
@samuelmaddock
samuelmaddock / infected_notice.lua
Created April 19, 2014 04:26
GMod Lua virus notice
--
-- Garry's Mod Lua virus fix instructions
--
-- Save under lua/autorun to alert clients that they're infected.
-- This will open an HTML window directing them how to clean their
-- files.
--
if SERVER then
AddCSLuaFile()
@samuelmaddock
samuelmaddock / cl_browserpool.lua
Created April 22, 2014 16:25
Awesomium Pool Interface
if browserpool then return end -- ignore Lua refresh
local table = table
local vgui = vgui
_G.browserpool = {}
--
-- Debug variable which will allow outputting messages if enabled.
-- @type boolean
@samuelmaddock
samuelmaddock / loading.lua
Last active February 6, 2017 00:25
Garry's Mod Loading Screen - Disable Audio; overwrite "garrysmod\lua\menu\loading.lua", set to read-only
--=============================================================================--
--
-- This file has been modified to remove any audio that plays on loading screens.
-- https://gist.github.com/samuelmaddock/bb2f643ac95dcc6a56e9
--
--=============================================================================--
g_ServerName = ""
g_MapName = ""
g_ServerURL = ""
@samuelmaddock
samuelmaddock / gm_sublime_glass.lua
Last active May 14, 2016 05:59
Glass effect for Garry's Mod; save in lua/autorun.
---
-- Sublime Glass - Garry's Mod
--
-- Use with the 'Sublime Text Trans' package.
-- https://github.com/vhanla/SublimeTextTrans
--
if SERVER then
AddCSLuaFile()
return
@samuelmaddock
samuelmaddock / unicode_fix.js
Last active August 29, 2015 14:15
Renames files using `#U[\w\d]{4}` names to their actual unicode character.
var fs = require('fs');
var files = fs.readdirSync('.');
var UNICODE_PATTERN = /#U([\d\w]{4})/gi;
for (var i = 0; i < files.length; i++) {
var filename = files[i];
if (!UNICODE_PATTERN.test(filename)) { continue; }
var fixedFilename = filename.replace(UNICODE_PATTERN, function (match, grp) {