This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local wrapped_env = { | |
print = wrap_output, | |
} | |
setmetatable(wrapped_end,{ | |
__index = _G, __newindex = _G, | |
__pairs = function() | |
return pairs(_G) | |
end, | |
__ipairs = function() | |
return ipairs(_G) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- dispatcher.lua: Callback handling mechanism. | |
-- Namespace | |
local dispatcher = {} | |
-- Import |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- util.lua: Shared utility functions | |
-- Namespace | |
local util = {} | |
-- Error, type checking |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder