Skip to content

Instantly share code, notes, and snippets.

View Cheatoid's full-sized avatar
😆
can i haz teh epic cheat on steroids?

Cheatoid Cheatoid

😆
can i haz teh epic cheat on steroids?
View GitHub Profile
@Cheatoid
Cheatoid / manual_select.lua
Created March 29, 2023 10:57
Manual `select` implementation (for weird Lua environments)
-- assuming Lua environment argument/local limit is 200
local manual_select_impl = {
[0] = function() end;
--[1] = function(a1) return a1 end;
--[2] = function(_,a2) return a2 end;
--[3] = function(_,_,a3) return a3 end;
--[4] = function(_,_,_,a4) return a4 end;
--[5] = function(_,_,_,_,a5) return a5 end;
--[6] = function(_,_,_,_,_,a6) return a6 end;
--[7] = function(_,_,_,_,_,_,a7) return a7 end;
@Cheatoid
Cheatoid / manual_unpack.lua
Created March 24, 2023 03:44
Manual `unpack` implementation (for weird Lua environments)
local manual_unpack_impl = {
-- return limit is variadic depending on Lua environment/version (usually 250 or 255)
[0] = function() end; -- no value
[1] = function(t) return t[1] end;
[2] = function(t) return t[1], t[2] end;
[3] = function(t) return t[1], t[2], t[3] end;
[4] = function(t) return t[1], t[2], t[3], t[4] end;
[5] = function(t) return t[1], t[2], t[3], t[4], t[5] end;
[6] = function(t) return t[1], t[2], t[3], t[4], t[5], t[6] end;
[7] = function(t) return t[1], t[2], t[3], t[4], t[5], t[6], t[7] end;
@Cheatoid
Cheatoid / extensions.d.ts
Last active December 7, 2023 04:54
TSTL plugins (unsafe_cast, goto/label, continue, next, vararg, methodsof, prototypeof, inline, typedparams) ✨
/**
* Emits a Lua continue statement.
* @internal
* @emits `continue`
*/
declare function __continue(this: void): void;
/**
* Emits a Lua goto statement (requires Lua 5.2+ or JIT).
* @param label - The label name to jump to.
@Cheatoid
Cheatoid / dfpwm.lua
Last active November 4, 2023 21:56
Simple DFPWM player for CC.
-- Simple DFPWM player for CC:T
-- https://gist.github.com/Cheatoid/e798988c54b411e9d1b64e7aa7057d91
local dfpwm = require("cc.audio.dfpwm")
local CHUNK_SIZE = 16 * 1024
local unpack = unpack or table.unpack
--- Play DFPWM audio from a file or URL
---@param path string Path (or direct URL) of the file to play
---@param speakers? table (Optional) List of speaker peripherals to play audio to
local function play_dfpwm(path, speakers)
assert(type(path) == "string", "bad argument #1 (string expected, got " .. type(path) .. ")")
@Cheatoid
Cheatoid / xor-benchmark.lua
Created February 15, 2022 13:26
Curated (table) Xor cipher benchmarks across LuaJIT, LuaJIT interpreter and Cobalt (ComputerCraft: Tweaked)
-- Note: do use local(ization) for better performance when JIT is off
local pairs, ipairs, next, rawset, rawget, bit_bxor = pairs, ipairs, next, rawset, rawget, bit32 and bit32.bxor or bit.bxor
local Xor0 = function(t, k)
-- assume `t` and `k` are (non empty) byte arrays (sequential & numeric indexed Lua tables)
local x = {}
for i = 1, #t do
x[i] = bit_bxor(t[i], k[((i - 1) % #k) + 1])
end
return x
end
@Cheatoid
Cheatoid / array-insert.md
Last active September 27, 2021 12:18
[E2] Autogenerated convenient push/insert/unshift functions for `array` and `table` types. (Since E2 doesn't have generics, yet.)
function angle array:insert(Index, Value:angle) { return This:insertAngle(Index, Value) }
#ifdef array:insertAttachment(number, attachment)
function attachment array:insert(Index, Value:attachment) { return This:insertAttachment(Index, Value) }
#endif
function bone array:insert(Index, Value:bone) { return This:insertBone(Index, Value) }
#ifdef array:insertCollision(number, collision)
function collision array:insert(Index, Value:collision) { return This:insertCollision(Index, Value) }
#endif
function complex array:insert(Index, Value:complex) { return This:insertComplex(Index, Value) }
@Cheatoid
Cheatoid / sh_cloakhax.lua
Last active June 18, 2021 00:58
(GLua) Something dirty I guess. This is supposed to let you hide players from SUI scoreboard (and cloak them) based on clientside actions.
-- Courtesy of /gh/Cheatoid
-- Updates: https://gist.github.com/d29fc5dd6ea9819295d2c87098b7bfb6
-- Totally untested. But, it is supposed to let you hide players from SUI scoreboard (and cloak them) based on clientside actions.
-- Needless shall I have to tell you again, this *will* be abused by haxxors/skids... But, you will just need to live with that I guess.
-- Whenever you want to toggle the state, simply call the hax_ToggleCloak() function on clientside.
local PLAYER = FindMetaTable'Player'
AccessorFunc(PLAYER, 'm_bHideOnScoreboard', 'HideOnScoreboard', FORCE_BOOL)
local msgID = 'hax_togglecloak'
@Cheatoid
Cheatoid / clientside-hack.lua
Created January 31, 2021 06:35
Starfall | Full example, showing how to enable unrestricted clientside access to vgui library for the specific Starfall chip
--[[
0. Assuming you can run clientside Lua (sv_allowcslua 1).
1. Spawn this code as a Starfall chip.
2. Aim on the Starfall chip!
3. Open ingame developer console (by default, press tilde key) and submit the following:
lua_run_cl LocalPlayer():GetEyeTrace().Entity.instance.env.vgui = _G.vgui
4. The above command will give unrestricted access to vgui library to the Starfall chip.
5. Be sure you trust chip's owner *before* using the above hack command on other player's SF chip!!
]]
@Cheatoid
Cheatoid / A.txt
Created January 5, 2021 12:49
Gist description placeholder...
1st line
2nd line
3rd line
@Cheatoid
Cheatoid / table-reverse.md
Last active December 11, 2020 20:36
[E2] table:reverse function (holy sh*t, this is reta**ed...)
# I needed an E2 function to...
# Reverse a sequential array-part of the given E2 table (using by-reference semantics, hence not returning a new table),
# but since there is no such builtin/official E2 function, I had to "invent" my own... Thanks to Wire for being lazy :D
# This is one of the most cancerous E2 functions ever. The reversing algorithm itself is pretty fast: O(n/2)
# The reason this code is soo big is basically because of how E2 tables work.
# We have to know the type of both values while performing a swap operation...
# (P.S. The code was fully auto-generated by my own tool.)
# (P.P.S. A sample test code can be found on the very bottom.)
# https://gist.github.com/b941df6ed2276fbeee17098c77410fee