Skip to content

Instantly share code, notes, and snippets.

View nefftd's full-sized avatar

Anthony Eadicicco nefftd

View GitHub Profile
#!/bin/sh
truncate -s 6G /swap;
chmod 0600 /swap;
SWFILE=$(mdconfig -a -t vnode -f /swap);
if [ $? -eq 0 ] && [ -n $SWFILE ] && [ -e "/dev/$SWFILE" ]; then
geli onetime -e AES-XTS -l 256 -d "/dev/$SWFILE" &&
swapon "/dev/$SWFILE.eli"
fi
do
local function _lua_unpack(t, i, j, ...)
if j >= i then
return _lua_unpack(t, i, j - 1, t[j], ...)
end
return ...
end
function lua_unpack(t, i, j)
do
local function _lua_unpack(t, i, j)
if i <= j then
return t[i], _lua_unpack(t, i + 1, j)
end
end
function lua_unpack(t, i, j)
assert(type(t) == 'table','bad argument #1')
local wrapped_env = {
print = wrap_output,
}
setmetatable(wrapped_end,{
__index = _G, __newindex = _G,
__pairs = function()
return pairs(_G)
end,
__ipairs = function()
return ipairs(_G)
-- dispatcher.lua: Callback handling mechanism.
-- Namespace
local dispatcher = {}
-- Import
-- util.lua: Shared utility functions
-- Namespace
local util = {}
-- Error, type checking
local buffer = vim.buffer()
local data = {}
for i = 1,#buffer do
-- NOTE: buffer is a userdata; must be copied into array
data[i] = buffer[i]
end
data = table.concat(data,'\n') -- join the table into a string, separated by new lines
local buffer = vim.buffer()
local data = {}
for i,entry in ipairs(buffer) do
data[i] = entry
end
data = table.concat(data,'\n') -- join the table into a string, separated by new lines
-- General helpers
function mod.guard(val) -- Bounds val [0,1] and NaN->0
mod:argcheck(val,1,'number')
if val < 0 or val ~= val then val = 0
elseif val > 1 then val = 1 end
return val
end
for dir in package.path:gmatch([^;]+) do
dir = dir:gsub('%?.*$','')
for file in lfs.dir(dir) do
print(file)
end
end
for dir in package.cpath:gmatch([^;]+) do
dir = dir:gsub('%?.*$','')
for file in lfs.dir(dir) do