Skip to content

Instantly share code, notes, and snippets.

View mattkrins's full-sized avatar
🇺🇦
ukr

Matt Krins mattkrins

🇺🇦
ukr
View GitHub Profile
@mattkrins
mattkrins / cl_surfaceGetURL.lua
Last active December 1, 2022 18:04
This is a simple Garry's Mod helper function to hot-load images from a web URL for use in your rendering operations.
local WebMaterials = {}
function surface.GetURL(url, w, h, time)
if !url or !w or !h then return Material("error") end
if WebMaterials[url] then return WebMaterials[url] end
local WebPanel = vgui.Create( "HTML" )
WebPanel:SetAlpha( 0 )
WebPanel:SetSize( tonumber(w), tonumber(h) )
WebPanel:OpenURL( url )
WebPanel.Paint = function(self)
if !WebMaterials[url] and self:GetHTMLMaterial() then
@mattkrins
mattkrins / cl_Interactive2D3D.lua
Last active May 14, 2017 17:49
An Interactive 2D3D button library for Garry's Mod.
local Interactive2D3D = {}
Interactive2D3D.IsVisible = function(self) return (self.Visible or false) end
Interactive2D3D.Start = function(self, vPos, aRot, vScale)
if !vPos or !aRot then return false end
self.Valid = true
local plpostoscreenx = vPos.x - LocalPlayer():GetShootPos().x
local plpostoscreeny = vPos.y - LocalPlayer():GetShootPos().y
local plpostoscreen = math.sqrt( plpostoscreenx^2+plpostoscreeny^2 )
local dist1 = 1/( math.cos( math.rad( EyeAngles().y ) ) ) * plpostoscreen
local distfull = 1/( math.cos( math.rad( EyeAngles().p ) ) ) * dist1
@mattkrins
mattkrins / sh_switchStatement.lua
Last active March 21, 2017 10:59
A Garry's Mod Switch Statement helper function.
local s function switch(v) s = v or false return s end
function case(v, yes, no) if s and v and (v==s) then if yes then return yes(s, v) end return true end if no then return no(s, v) end return false end
function clearSwitch() s=nil return true end
@mattkrins
mattkrins / cl_drawContainerBox.lua
Last active March 21, 2017 10:58
A simple but practical Garry's Mod draw helper function, particularly useful with 3D2D rendering operations.
function draw.ContainerBox( r, x, y, w, h, c, p )
draw.RoundedBox( r or 0, x or 0, y or 0, w or 0, h or 0, c or color_white )
if p then p(x or 0, y or 0, w or 0, h or 0) end
end
@mattkrins
mattkrins / soranews24.user.js
Last active August 24, 2023 23:37
Soranews24 Dark
// ==UserScript==
// @name Kuronews24
// @description Dark theme for SoraNews24
// @version 1.9
// @author Matt Krins
// @namespace https://gist.github.com/mattkrins
// @icon https://user-images.githubusercontent.com/2367602/78975577-e4aeca00-7b03-11ea-8b33-e860d636b9ad.png
// @homepageURL https://gist.github.com/mattkrins/d06c7504bf92efe933b50dc3b9308573
// @match *://soranews24.com/*
// @grant GM_addStyle
@mattkrins
mattkrins / HexColor.lua
Created September 17, 2019 17:31
Garry's Mod (gmod) Hex to RGB color helper
function HexColor(hex, alpha)
hex = hex:gsub("#","")
return Color ( tonumber("0x" .. hex:sub(1,2)), tonumber("0x" .. hex:sub(3,4)), tonumber("0x" .. hex:sub(5,6)), alpha or 255 )
end
@mattkrins
mattkrins / dark-bargain.user.js
Last active May 26, 2021 00:43
DarkBargain User Script
// ==UserScript==
// @version 1.4
// @name DarkBargain
// @description Dark theme for OzBargain
// @namespace https://gist.github.com/mattkrins
// @homepageURL https://gist.github.com/mattkrins/520ab6712c0ee5d4b4fecf4703fff976
// @icon https://user-images.githubusercontent.com/2367602/78972377-238d5180-7afd-11ea-9b38-4983a8281184.png
// @author Matt Krins
// @match *://www.ozbargain.com.au/*
// @grant GM_addStyle
@mattkrins
mattkrins / steam-client-link.user.js
Last active October 9, 2020 07:33
Add button to open steam app on the client