Instantly share code, notes, and snippets.

View README.md

Detailed Description: checkglobals module + patch

The checkglobals module + patch (from LuaPowerPatches -- Download Patch for Lua 5.1.3 is a hybrid of a compile-time and run-time approach for detecting undefined variables. Consider the following trivial Lua module:

-- multiplybyx.lua
local function multiplybyx(y)
  return y * X                -- is X defined???
end
return multiplybyx
View globalsplus.lua
-- globalsplus.lua
-- Like globals.lua in Lua 5.1.4 but records fields in global tables too.
-- Probably works but not well tested. Could be extended even further.
--
-- usage: luac -p -l example.lua | lua globalsplus.lua
--
-- D.Manura, 2010-07, public domain
local function parse(line)
local idx,linenum,opname,arga,argb,extra =
View makebuild.lua
--[[
Simple Makefile generator in Lua 5.1.
With gcc include dependency support.
WARNING: proof of concept; not well tested. GNU style Makefile.
See premake for a more complete implementation.
(c) David Manura, 2013-03. MIT license (same as Lua).
--]]
local M = {}
View notes-fd-staircase.txt
One method I've prototyped to reduce effects of finite difference (F.D.) staircase effects (though not really recommended nor used but provided for reference):
(1) Solve the partial differential equation for f in the usual way by F.D.
(2) Measure f and grad(f) at each point about one or two mesh units away from the boundary surface by using data from #1. Use this to update values at boundary condition mesh points. For example, by linear extrpolation or other extrapolation technique.
(3) Repeat #1 until convergence.
Other obvious variations for updating boundary mesh point values are possible, including expressing #1-3 as a single matrix equation to solve (which probably has some equivalence to currently used techniques), thereby avoiding the repetition needed in #3.
View hamming_weight_test.lua
--[[
Correctness and benchmark tests of various hamming weight implementations.
This is also called "popcount".
See also
http://lua-users.org/wiki/HammingWeight
http://stackoverflow.com/questions/109023/best-algorithm-to-count-the-number-of-set-bits-in-a-32-bit-integer
http://www.dalkescientific.com/writings/diary/archive/2008/07/03/hakmem_and_other_popcounts.html
http://perso.citi.insa-lyon.fr/claurado/ham/overview.pdf
http://chessprogramming.wikispaces.com/Population+Count
David Manura, 2012-03.
View memoize.lua
--[[
memoize.lua
http://lua-users.org/wiki/FuncTables
http://www.lua.org/pil/17.1.html
Code is public domain.
D.Manura.
--]]
View sourceunpack.lua
#!/usr/bin/env lua
--[[ FILE README.txt
LUA MODULE
sourceunpack v$(_VERSION) - Extract Lua files containing other Lua files.
SYNOPSIS