Skip to content

Instantly share code, notes, and snippets.

View weswigham's full-sized avatar
:shipit:
:shipit:

Wesley Wigham weswigham

:shipit:
:shipit:
View GitHub Profile
@weswigham
weswigham / chargin_voxel.lua
Created March 4, 2014 05:07
Imma chargin mah lazor
local color = Color(255, 255, 255, 255)
Voxel.display.color = color
Voxel.display:zero()
local function toggleCore(center, size)
for x=center-size,center+size do
for y=center-size,center+size do
for z=center-size,center+size do
if math.sqrt((x-center)^2 + (y-center)^2 +(z-center)^2)<=size then
@weswigham
weswigham / method_missing.lua
Created November 5, 2013 04:33
You've always wanted method_missing in lua, right? This is a pretty close approximation.
--[[
Method missing should be an optional definition on any object.
If a method cannot be found, method_missing is called if available
]]
local field = '__method__missing'
function method_missing(selfs, func)
local meta = getmetatable(selfs)
@weswigham
weswigham / webclude.lua
Last active December 24, 2015 12:49
Pull Lua dependencies straight from the web! Now adds a searcher to require, instead of other things!
local socket = require("socket")
local http = require("socket.http")
--Safety is overrated. Pull scripts form the web!
local function webclude(target, ...)
local body, status, res_head, res_stat = http.request(target, ...)
if body then
return body
@weswigham
weswigham / scope
Created July 14, 2013 22:14
Scope in python
def SomeFunc():
x = 3
def InnerFunc():
x = 22
InnerFunc()
return x
@weswigham
weswigham / scope
Created July 14, 2013 22:13
Lua scope
function SomeFunc()
local x = 3
local function InnerFunc()
x = 22
end
InnerFunc()
@weswigham
weswigham / matrix_test.lua
Created July 2, 2013 23:45
Example usage of matrix.lua
local Matrix = require("matrix")
print(tostring(Matrix(3)))
local mat = Matrix(3)
mat[1][1] = 1
mat[1][2] = 2
mat[1][3] = 3
mat[2][1] = 4
mat[2][2] = 5
@weswigham
weswigham / matrix.lua
Created July 2, 2013 23:42
O(1) Matrix Rotation. I think.
local rawget = rawget
local rawset = rawset
local setmetatable = setmetatable
local tostring = tostring
local error = error
local type = type
local print = print