Skip to content

Instantly share code, notes, and snippets.

View Kefta's full-sized avatar
🤠
out on the range like an ArrayOutOfBoundsException

code_gs Kefta

🤠
out on the range like an ArrayOutOfBoundsException
View GitHub Profile
@Egor-Skriptunoff
Egor-Skriptunoff / utf8_filenames.lua
Last active August 30, 2023 06:45
UTF-8 filenames on Windows in pure Lua
------------------------------------------------------------------------------------------------------------------------------
-- Module: utf8_filenames
------------------------------------------------------------------------------------------------------------------------------
-- Filename: utf8_filenames.lua
-- Version: 2019-07-13
-- License: MIT (see at the end of this file)
-- This module modifies standard Lua functions so that they work with UTF-8 filenames on Windows:
-- io.open
-- io.popen
local null = function(null) return null end
local _return = function(ret) return ret end
local _if = function(cond) return function(ontrue) return function(onfalse) return cond(ontrue)(onfalse) end end end
local _while = function(iv) return function(lb) return function(l) return (function(body) return lb(iv)(body(body)(iv))(iv) end)(function(body) return function(st) return (function(nst) return _if(lb(nst))(body(body)(nst))(nst) end)(l(st)) end end) end end end
local _until = function(iv) return function(lb) return function(l) return (function(body) return body(body)(iv) end)(function(body) return function(st) return (function(nst) return _if(lb(nst))(nst)(body(body)(nst)) end)(l(st)) end end) end end end
local match = function(cmp) return function(val) return function(res) return function(d) return res(function(e) return function(nx) return cmp(val)(e(tFirst))(e(tSecond))(nx) end end)(d) end end end end
local _true = function(t) return function(f) return t end end
local _false = function(t) return function(
@meepen
meepen / non-powerof2-png-gmod.lua
Last active February 22, 2021 17:40
Loads non power of 2 PNG into a Garry's Mod texture without fucking over scaling.
local function wait_png(matstr)
local html = vgui.Create("DHTML")
html:AddFunction("console", "memeify", function()
html.done = true
end)
local mat = Material(matstr)
local rw, rh = mat:GetInt "$realwidth", mat:GetInt "$realheight"
local f = file.Open("materials/"..matstr, "rb", "GAME")
local cont = f:Read(f:Size())
@SwadicalRag
SwadicalRag / Lua.lua
Last active December 10, 2019 22:19
In Lua we trust
In the beginning was the Statement, and the Statement was with Lua, and the Statement was Lua.
Through Lua all things were made; without Lua nothing was made that has been made.
There came a function who was sent from Lua; his name was John.
"Lua was the answer to my prayers;
Greater love has no one than Lua, that the compiler lay down his life for our code" - John Lua
"Do not think that I will debug you to the Environment;
For had ye believed the Compiler Errors, ye would have believed Me, for he wrote of Lua;
But if ye believe not his Stack Traces, how shall ye believe My code?" - John Lua
@AbigailBuccaneer
AbigailBuccaneer / gist:5943024
Last active March 14, 2019 14:58
State of Socket APIs for Garry's Mod 13

Socket APIs for Garry's Mod 13

There are several different Socket APIs for Garry's Mod. They all have slightly different APIs, and for many of them it's unclear if they work at all in Garry's Mod 13.

[LuaSocket][]

LuaSocket is 'the original' socket API for Lua. It has a very simple API that closely matches the POSIX sockets API, plus some goodies thrown in (e.g. HTTP layer, MIME type handling).

While LuaSocket doesn't support Garry's Mod, it probably wouldn't be hard to create a Garry's Mod fork of it. This has the advantages of having a high-quality library and universally-recognised API, but it would involve maintenance of a binary module.