Skip to content

Instantly share code, notes, and snippets.

View SwadicalRag's full-sized avatar
👨‍⚕️
working :)

swadical SwadicalRag

👨‍⚕️
working :)
View GitHub Profile
@SwadicalRag
SwadicalRag / compressed.lua
Last active August 29, 2015 14:19
HashLib
function installHashLib()hashLib={}function string.levenshtein(a,b)local c=string.len(a)local d=string.len(b)local e={}local f=0;if c==0 then return d elseif d==0 then return c elseif a==b then return 0 end;for g=0,c,1 do e[g]={}e[g][0]=g end;for h=0,d,1 do e[0][h]=h end;for g=1,c,1 do for h=1,d,1 do if a:byte(g)==b:byte(h)then f=0 else f=1 end;e[g][h]=math.min(e[g-1][h]+1,e[g][h-1]+1,e[g-1][h-1]+f)end end;return e[c][d]end;function ayy(i,j,k)j=j or 2;i=i or"lmao"local l='a'for m=1,j,1 do l=l..'y'end;if k then print(l..' '..i)else return l..' '..i end end;hashLib.responders={}hashLib.trigger=function(n,o,p)for m,q in ipairs(hashLib.responders)do if string.levenshtein(string.lower(n),string.lower(q.string))<=1 or string.find(string.lower(n),string.lower(q.string))then if q.specific then if q.targetID==p then print(q.response or"")break end else if type(q.response)=="function"then print(q.response(nick,p,n)or"")else print(q.response or"")end;break end end end end;hook.Add("Message","HashLibMsg",function(o,p,n)h
@SwadicalRag
SwadicalRag / doge.lua
Last active August 29, 2015 14:20
doge.lua
function doge(...)
local dogeWords = {
"very",
"so",
"much",
"many",
"such",
"quite"
}
@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
function ease(Time,Initial,Final,TimeElapsed)
Time = Time/(TimeElapsed/2)
if (Time < 1) then
return -Final/2 * ((1 - Time*Time)^0.5 - 1) + Initial
end
Time = Time-2
return Final/2 * ((1 - Time*Time)^0.5 + 1) + Initial
end
@SwadicalRag
SwadicalRag / why.lua
Created May 14, 2015 01:44
Statistics. Why?
cookie.statistics.juxtapose = function(tbl1,tbl2)
local t1 = {}
local t2 = {}
local t1_total = 0
t1.count = 0
for k,v in ipairs(tbl1) do
t1.count = t1.count + 1
t1_total = t1_total + tonumber(v)
end
cookie.maymays.flipTable = function(unflip)
local flips = {
"(╯°□°)╯︵ ┻━┻",
"(ノ ゜Д゜)ノ ︵ ┻━┻",
"(╯°□°)╯︵ ┻━┻ ︵ ╯(°□° ╯)",
"┬─┬ ︵ /(.□. \\)",
"(ノಥ益ಥ)ノ ┻━┻",
"(╯°Д°)╯︵ /(.□ . \\)",
"(╯'□')╯︵ ┻━┻",
"(ノಥДಥ)ノ︵┻━┻・/",
@SwadicalRag
SwadicalRag / repeat.lua
Last active April 21, 2017 12:17
Repeat after me
local function ParseStatement(msg,repper)
if(msg:match("^repeat[ \n\r\t]-after[ \n\r\t]-.-[ \n\r\t]-.+[ \n\r\t]-ty")) then
local to_repeat = msg:match("^repeat[ \n\r\t]-after[ \n\r\t]-.-[ \n\r\t]-[\"'](.+)[\"'][ \n\r\t]-x[ \n\r\t]-%d-[ \n\r\t]-ty")
local n = msg:match("^repeat[ \n\r\t]-after[ \n\r\t]-.-[ \n\r\t]-[\"'].+[\"'][ \n\r\t]-x[ \n\r\t]-(%d+)[ \n\r\t]-ty")
local person = msg:match("^repeat[ \n\r\t]-after[ \n\r\t]-([^ ]+)[ \n\r\t]-[\"'].+[\"'][ \n\r\t]-x[ \n\r\t]-%d+[ \n\r\t]-ty")
if not (to_repeat and tonumber(n) and person) then return end
local out = ""
local repper = (repper or "\n")
for i=1,tonumber(n) do
out = out..to_repeat..repper
@SwadicalRag
SwadicalRag / compare.lua
Created September 10, 2015 05:36
compare tables
local function compare(tbl1,tbl2,compared)
compared = compared or {}
for k,v in pairs(tbl1) do
if(type(v) == "table") then
if not compared[v] then
if(type(tbl2[k]) == "table") then
compared[v] = true
if not compare(v,tbl2[k],compared) then
return false
end
@SwadicalRag
SwadicalRag / lao.lua
Last active September 20, 2015 08:42
Lao "G" in Lua
hook.Add("Message","Lao G",function(_,__,msg)
if(msg:match("(%a*[Gg]%a*)")) then
for g in msg:gmatch("(%a*[Gg]%a*)") do
local g2,n = g:gsub("([Gg])","'G'")
print(g2)
end
print("There's the 'G'!")
end
end)
local spawnProtectionNetchannel = "meme_protect_spawn"
if(SERVER) then
util.AddNetworkString(spawnProtectionNetchannel)
hook.Add("PlayerSpawn","meme_protect_spawn",function(ply)
ply:GodEnable()
timer.Simple(5,function()
if not IsValid(ply) then return end
ply:GodDisable()
net.Start(spawnProtectionNetchannel)