Skip to content

Instantly share code, notes, and snippets.

View mpeterv's full-sized avatar

Peter Melnichenko mpeterv

View GitHub Profile
@mpeterv
mpeterv / test-normpath.lua
Created July 17, 2016 11:36
Script to compare Python's os.path.normpath and Penlight's pl.path.normpath on random inputs
-- Usage: lua test-normpath.lua [count | path]
local path = require "pl.path"
local socket = require "socket"
math.randomseed(math.floor(socket.gettime() * 1000))
local chars = "./A"
local function gen_random_path()
local length = math.random(0, 5) + math.random(0, 5)
local lua = "lua"
local i = 0
while arg[i] do
lua = arg[i]
i = i - 1
end
local is_windows = package.config:sub(1, 1) == "\\"
@mpeterv
mpeterv / gist:52df984bdee4d6dcb1169d384be28d1b
Created October 29, 2016 19:47
Missing dependency reporting includes indirect deps
Missing dependency for cgilua 5.1.4-2: luafilesystem >= 1.5.0
Missing dependency for busted 2.0.rc12-1: luafilesystem >= 1.5.0
Missing dependency for busted 2.0.rc12-1: luafilesystem
Missing dependency for penlight 1.4.1-1: luafilesystem
Missing dependency for xavante 2.4.0-1: luafilesystem >= 1.6.0
Missing dependency for wsapi 1.6.1-1: luafilesystem >= 1.6.2
Missing dependency for sailor 0.5-4: luafilesystem >= 1.5.0
Missing dependency for sailor 0.5-4: luafilesystem
Missing dependency for sailor 0.5-4: luafilesystem >= 1.6.2
Missing dependency for sailor 0.5-4: luafilesystem >= 1.6.0
@mpeterv
mpeterv / luacheck-build.sh
Last active April 29, 2018 16:25
Cross-compile luacheck.exe
#!/usr/bin/env bash
# TODO: write a program called `rock2bin` that does this all in
# one call (`rock2bin luacheck -l 5.3 -t windows`).
mkdir build
curl https://www.lua.org/ftp/lua-5.3.4.tar.gz | tar xz
luarocks unpack luafilesystem 1.6.3-2
luarocks unpack lanes 3.10.1-1
@mpeterv
mpeterv / discordia.lua
Created March 12, 2018 09:22
Discordia client serialized with vinspect
<1>{
[1] = {},
[2] = {
autoReconnect = true,
bitrate = 64000,
cacheAllMembers = false,
compress = true,
dateTime = "%F %T",
firstShard = 0,
largeThreshold = 100,
@mpeterv
mpeterv / randtest.lua
Created September 29, 2018 10:31
binser random bad data deserialization testing
local binser = require "binser"
local unpack = table.unpack or unpack
local error_patterns = {
"Expected more bytes of input",
"Could not deserialize type byte",
"Expected more bytes of input",
"Got nil resource name",
"Expected table metatable",
"No resources found for name",