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
#!/usr/local/bin/python3 | |
# | |
# bye_camels.py from https://github.com/tylerneylon/cstructs | |
# | |
""" | |
Usage: | |
bye_camels.py <input_file> [<output_file>] | |
bye_camels.py -i <input_file> <output_file> | |
Replaces all camel-case identifiers in the input with |
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
#!/usr/bin/awk -f | |
# | |
# call_graph.awk | |
# | |
# Usage: | |
# ./call_graph.awk my_program.lua | dot -Tpng > call_graph.png | |
# | |
# This is a script that generates a visual call graph | |
# for a Lua file. This script only shows calls made | |
# to functions defined within the input Lua file; that is, |
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
-- all_top_sorts.lua | |
-- | |
-- Generate all permutations - aka topological sorts - of | |
-- the set [1, 2, ..., n] such that the permutation has | |
-- certain pairs in a given order. This can also be thought | |
-- of as listing all linear orders consistent with a given | |
-- partial order. | |
-- | |
-- This code is based on chapter 3 of | |
-- Donald Knuth's book Literate Programming. |
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
-- copy.lua | |
-- | |
-- Lua functions of varying complexity to deep copy tables. | |
-- | |
-- 1. The Problem. | |
-- | |
-- Here's an example to see why deep copies are useful. Let's | |
-- say function f receives a table parameter t, and it wants to |
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
--[[ json.lua | |
A compact pure-Lua JSON library. | |
The main functions are: json.stringify, json.parse. | |
## json.stringify: | |
This expects the following to be true of any tables being encoded: | |
* They only have string or number keys. Number keys must be represented as | |
strings in json; this is part of the json spec. |
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 t_sum = 0 | |
local t_num = 0 | |
local t1, t2, t3 | |
local do_time = true | |
local function mark1() | |
if not do_time then return end | |
t1 = os.clock() | |
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
#!/usr/local/bin/lua | |
usage_str = [[ | |
Usage: | |
lgraph 'function of x' | |
Example: | |
lgraph 'x^2' | |
]] | |
Grapher = {xmin = -1, xmax = 1, ymin = -1, ymax = 1, ncols = 160, nrows = 50} |
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
-- time_lock_inj.lua | |
-- | |
local usage_str = [[ | |
Usage: | |
lua time_lock_inj.lua <list_of_input_source_files> | |
Injects lock timing code for all the given files. | |
This assumes you're locking things with calls to |
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
// keylog.c | |
// | |
// Usage: | |
// ./keylog [command ...] | |
// | |
// This runs the given command, capturing all keyboard input in the file | |
// "outfile." This is currently written for mac os x. I'm guessing slight edits | |
// would allow it to work on other *nix systems as well. | |
// | |
// I learned how to do this by looking at the source of the "script" binary, |
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
--[[ Summary: Below, "entity" and "item" may be different types. | |
They simply implement same-name methods. | |
--]] | |
-- A bit from entities.lua: | |
function entities.runloop(dt) | |
for _, entity in pairs(all_entities) do | |
entity:update_and_draw(dt) | |
end |