Skip to content

Instantly share code, notes, and snippets.

View samuelmaddock's full-sized avatar

Sam Maddock samuelmaddock

View GitHub Profile
@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 / 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) {
@samuelmaddock
samuelmaddock / ExampleEvent.php
Last active August 29, 2015 14:22
ZF2 Eventing Skeleton
<?php
namespace Example;
use Zend\EventManager\Event;
class ExampleEvent extends Event
{
const EVENT_FOOBAR = 'foobar';
protected $value;
@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 / example.lua
Last active January 17, 2016 05:00
MediaPlayer grab fft
local mp = MediaPlayer.Create( "global" )
-- only allow media which supports FFTs (remove this if you don't want it)
mp.ServiceWhitelist = { 'af', 'sc' }
if CLIENT then
local function audioPostDraw( media )
local fft = media.fft
if not fft then return end
@samuelmaddock
samuelmaddock / CEF3.build.cs
Last active February 22, 2016 05:32
Unreal Engine 4.10.1 CEF3 binaries missing from shipping build fix; overwrite this file in `\Engine\Source\ThirdParty\CEF3`
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.IO;
public class CEF3 : ModuleRules
{
public CEF3(TargetInfo Target)
{
/** Mark the current version of the library */