Skip to content

Instantly share code, notes, and snippets.

@LPGhatguy
LPGhatguy / build-love.sh
Created March 20, 2014 05:38
Builds LOVE on Fedora 20. Requires the shell to be in the extracted LOVE's directory and that libmpg123 is installed (because it isn't in Fedora's package manager)
echo LOVE Install for Fedora Initialized
pause
yum install gcc gcc-c++ automake libtool SDL2 SDL2-devel openal openal-devel luajit luajit-devel DevIL DevIL-devel freetype-devel libmodplug libmodplug-devel physfs physfs-devel libvorbis-devel
platform/unix/automagic
./configure
make
make install
echo Complete!
@LPGhatguy
LPGhatguy / graph.lua
Last active August 29, 2015 13:57
Graph Prototype 1 - displays a few graphs in a demo graphing window
--[[
PUBLIC DOMAIN
Where this designation is not recognized, you are
permitted to copy, modify, and distribute this code
without restriction.
Lucien Greathouse
(LPGhatguy)
]]
@LPGhatguy
LPGhatguy / synth.lua
Last active August 29, 2015 13:57
Synthesizer Prototype 2 - A synthesizer for an organ without need for any assets. Use the keys 1Q2W3ER5T6YU8I9O0P[=], backspace, \ZSXDCVGBHNM,L.;/, and right shift to play it.
--[[
PUBLIC DOMAIN
Where this designation is not recognized, you are
permitted to copy, modify, and distribute this code
without restriction.
Lucien Greathouse
(LPGhatguy)
]]
@LPGhatguy
LPGhatguy / notimagefontfont.lua
Created April 3, 2014 03:28
Generates a bitmap version of love's default font with an outline.
local infont
local outfont
local glyphstring = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`~!@#$%^&*()-=_+[]{}\\|;:'\",./<>?"
local teststring = [[
Who packed five dozen old quart jugs in my box?
Prating jokers quizzically vexed me with fibs.
Brawny gods just flocked up to quiz and vex him.
Watch "Jeopardy!", Alex Trebek's fun TV quiz game.
]]
local border = 2
@LPGhatguy
LPGhatguy / oops.lua
Created April 25, 2014 19:57
Creates an insane development environment.
--usage: require("oops")
local rawset, tostring = rawset, tostring
local meta = {
__mode = "v",
__index = function(self, index)
return tostring(index)
end,
__newindex = function(self, index, value)
rawset(self, tostring(index):upper(), value)
end
@LPGhatguy
LPGhatguy / demo.lua
Last active August 29, 2015 14:02
OpenGL function loader for LuaJIT. This is a fixed up version of slime73's original code. See demo.lua for usage.
local glfw = require("glfw3") --Let's say we have a magic GLFW3 binding there!
local openGL = require("opengl")
openGL.loader = glfw.GetProcAddress
openGL:import()
--and somewhere else
local vbo = ffi.new("GLuint[1]")
gl.GenBuffers(1, vbo)
gl.BindBuffer(GL.ARRAY_BUFFER, vbo[0])
gl.BufferData(GL.ARRAY_BUFFER, ffi.sizeof(vertices), vertices, GL.STATIC_DRAW)
@LPGhatguy
LPGhatguy / fdef_to_stsnippet.lua
Last active August 29, 2015 14:02
Run this is a folder full of 'fdef' files to turn it into a folder of sublime-snippet files. See sample.fdef, sample.sublime-snippet, and sample-all.sublime-snippet.
--[[
]]
local lfs = require("lfs")
local CWD = "./"
function readfile(path)
local handle = io.open(path, "r")
if (handle) then
local data = handle:read("*a")
handle:close()
@LPGhatguy
LPGhatguy / cascade.lua
Created August 28, 2014 00:26
Lua cascade operator. This has issues with Lua's expression-versus-statement policies, so it can be slightly ambiguous
local function table_copy(source, target)
target = target or {}
for key, value in pairs(source) do
target[key] = value
end
return target
end
@LPGhatguy
LPGhatguy / composition.lua
Last active August 29, 2015 14:11
Function composition operator in Lua using __concat, which might not be the best operator to use.
debug.setmetatable(function() end, {
__concat = function(self, with)
return function(...)
return self(with(...))
end
end
})
local sin = math.sin
print((sin .. sin)(5)) --sin(sin(5))
@LPGhatguy
LPGhatguy / README.md
Last active August 29, 2015 14:16
An API to generate badges and place them in markdown readme files automatically using shields.io.

README Sample

This file is to be used with the example.lua file.

Here, we use Markdown's ability to use shortlink images:

Testing results: ![shield_build] ![shield_tests]

Version information: