Skip to content

Instantly share code, notes, and snippets.

@LPGhatguy
LPGhatguy / game.html
Last active September 29, 2019 01:18
Reglike: A simple roguelike written in Regex!
<!DOCTYPE html>
<html>
<head>
<title>Reglike</title>
<style>
*, *::before, *::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
@LPGhatguy
LPGhatguy / parse-exp.lua
Created February 11, 2016 10:50
A parser for C-style numeric expressions
local bit = require("bit")
-- Operators that can stay as-is
local natop = {
["+"] = true,
["-"] = true,
["*"] = true,
["/"] = true
}
@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 / repent.lua
Created October 22, 2015 09:43
Adds the compliment of math.sin, math.repent
function math.repent()
return 3
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 / 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 / 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:

@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
@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 / luajit-curl.lua
Last active March 19, 2023 09:53
A cURL binding for LuaJIT. Missing some constants presumably, but functional
--[[
LuaJIT-cURL
Lucien Greathouse
LuaJIT FFI cURL binding aimed at cURL version 7.38.0.
Copyright (c) 2014 lucien Greathouse
This software is provided 'as-is', without any express
or implied warranty. In no event will the authors be held
liable for any damages arising from the use of this software.