Skip to content

Instantly share code, notes, and snippets.

@LPGhatguy
LPGhatguy / alias.lua
Created October 17, 2015 09:08
Converts snake_case libraries (like excessive moe's) to camelCase.
local function breakSnake(id)
if (type(id) ~= "string") then
return id
end
return (id:gsub("(%w)_(%a)", function(a, b)
return a .. b:upper()
end))
end
@LPGhatguy
LPGhatguy / main.lua
Created October 17, 2015 09:27
Pote: The Portable Game FS Extension
local pote = require("pote")
function love.load(args)
pote.mount(args)
print(love.filesystem.read("app/main.lua"))
end
@LPGhatguy
LPGhatguy / repent.lua
Created October 22, 2015 09:43
Adds the compliment of math.sin, math.repent
function math.repent()
return 3
end
@LPGhatguy
LPGhatguy / chrome-repaint-bug.html
Created December 4, 2015 21:30
Put this into an HTML file and test it!
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<style>
.container > *:first-child::before {
content: "X";
color: black;
font-size: 2em;
}
@LPGhatguy
LPGhatguy / CubeTimer.lua
Created June 19, 2013 00:13
The source for a cube timer application.
--[[
Cube Timer
Version 3.1
]]
local start_keys = {"lctrl", "ralt"}
local start_keys_down = {false, false}
local keys_down = false
local keys_down_last = false
@LPGhatguy
LPGhatguy / cube.js
Last active December 18, 2015 16:19
This is the official WCA Cube Scrambling JavaScript source, taken from http://www.jaapsch.net/scramble_cube.htm.
var size=3;
var seqlen=30;
var numcub=5;
var mult=false;
var cubeorient=false;
var colorString = "yobwrg"; //In dlburf order. May use any colours in colorList below
// list of available colours
var colorList=new Array(
'y', "yellow", "yellow",
@LPGhatguy
LPGhatguy / luby.lua
Created June 19, 2013 00:37
This is a fun thing that allows select Ruby code (namely loops with ranges) to execute as valid Lua code.
--Luby 1.0
function construct_iterator(n)
local at = 0
return function()
at = at + 1
return n[at]
end, n
end
@LPGhatguy
LPGhatguy / format.lua
Created December 31, 2013 05:29
LDOC Prototype. Produces HTML-formatted documentation from Lua comments. See http://hastebin.com/nexedayeqo.lua for example input code. This is taken from my personal stash of utility scripts and isn't guaranteed to be decent. util.lua is the library's utility set (one function?) parser.lua parses the comments and forms a document tree. output.l…
return {
["html"] = {
value_process = function(source)
if (type(source) == "string") then
return source:gsub("\n", "\n<br />")
else
return source
end
end,
extension = ".html",
@LPGhatguy
LPGhatguy / minify.lua
Last active January 1, 2016 19:59
Minifies Lua from the command line.
--[[
Lua Minify 1.0
Usage:
lua minify.lua comments DIRECTORY
strips comments from all .lua files in the directory, recursively, and puts them in DIRECTORY/minified
lua minify.lua minify DIRECTORY
strips comments and minifies code from all .lua files and places them like the prior command.
]]
@LPGhatguy
LPGhatguy / VoipEncoder.lua
Created December 16, 2014 22:18
Demonstration of encoding SoundData into a packet
local ffi = require("ffi")
-- Create a C struct representing the header for our packet
ffi.cdef([[
typedef struct {
uint32_t uuid; // user identifier
uint32_t size; // in bytes
uint32_t bitrate; // in Hz
uint16_t bitdepth; // bits per sample
uint16_t channels; // probably 1 or 2