Skip to content

Instantly share code, notes, and snippets.

Avatar
🌜
Lua

Elias Hogstvedt CapsAdmin

🌜
Lua
View GitHub Profile
@CapsAdmin
CapsAdmin / RangeSlider.ts
Last active Sep 9, 2022
quick and dirty typescript version of https://github.com/githuboftigran/rn-range-slider as i just needed some sliders for debugging
View RangeSlider.ts
import React, {
memo,
MutableRefObject,
PureComponent,
RefObject,
useCallback,
useEffect,
useMemo,
useRef,
useState,
View modestack.ts
type Mode = "safe" | "faster";
const modeStack: Mode[] = ["safe"];
const getMode = () => modeStack[0];
const pushMode = (mode: Mode) => modeStack.unshift(mode);
const popMode = () => modeStack.shift();
type HasLength = { length: number };
type WithModeRequest<Result> = {
mode: Mode;
View preprocess.lua
local preprocess = {}
function preprocess.Init()
if _G.load then
_G.old_preprocess_load = _G.old_preprocess_load or _G.load
local old_preprocess_load = _G.old_preprocess_load
_G.load = function(code, name, ...)
if type(code) == "string" then
code = preprocess.Preprocess(code, name, nil, "load")
View build.sh
git clone git@github.com:LuaJIT/LuaJIT.git
cd LuaJIT
make
cd ..
gcc -O2 main.c -I LuaJIT/src/ -L LuaJIT/src/ -lluajit
./a.out main.lua
View glua.lua
type IPixVis = {}
type ISensor = {}
local CLIENT = true
local SERVER = true
local MENU = true
type IBfRead = {}
type IWeapon = {}
type IVehicle = {}
type IVector = {}
type IMatrix = {}
@CapsAdmin
CapsAdmin / spleeter.cmd
Last active Nov 23, 2022
This makes it possible to run spleeter without having to install pyton and pip on windows. See http://github.com/deezer/spleeter for more info on what spleeter is. Usage is `.\spleeter.cmd separate -p spleeter:5stems -o amen .\amenbrother.wav`
View spleeter.cmd
@echo off & set GOLUWA_START_TIME="%time%" & PowerShell -nologo -noprofile -noninteractive Invoke-Expression ('$args=(''%*'').split('' '');'+'$PSScriptRoot=(''%~dp0'');$env:GOLUWA_CURRENT_DIRECTORY=(''%cd%'');'+((Get-Content -Raw '%~dp0%~n0%~x0' ) -Replace '^.*goto :EOF')); & goto :EOF
# ^^^^^
# this is some magic to execute the rest of this cmd as powershell
# so we can run it from explorer with double click or cmd easily
function Download($url, $location) {
Write-Host -NoNewline "'$url' >> '$location' ... "
(New-Object System.Net.WebClient).DownloadFile($url, "$location")
Write-Host "OK"
View loading.html
<!DOCTYPE html>
<html>
<style>
body {
background-color: black;
background-size: cover;
overflow: hidden;
opacity: 1;
transition: all 300ms ease-in 200ms;
}
View csv2tbl.lua
local function string_split(self, separator)
local tbl = {}
local tbl_i = 1
local last_pos = 1
local len = #separator - 1
for i = 1, #self do
if self:sub(i, i + len) == separator then
tbl[tbl_i] = self:sub(last_pos, i - len - 1)
View vararg_pass.js
let tbl = {
foo: [1,2,3],
bar: [4,5,6],
}
let test = function(a,b,c) {
console.log(a,b,c)
}
/*
View tokenizer.lua
-- these have to be sorted by longest first
local keywords = {
"function",
"then",
"end",
"if",
}
local symbols = {