Skip to content

Instantly share code, notes, and snippets.

@indrora

indrora/bad.lua

Last active Aug 29, 2015
Embed
What would you like to do?
Test socks please ignore
foo = nil
foo()
print("Hello, world!")
local tArgs = { ... }
print("Got ",#tArgs," args")
textutils.tabulate(unpack(tArgs))
function loadgist(gist,name)
content = http_get_gist(gist,name)
if content then
func, err = loadstring(content)
if not err then
return func
else
print("Error: "..err)
end
end
end
function savegist(gist,name,call)
if not call then
print("No output gile given")
return nil
end
content = http_get_gist(gist,name)
-- print(content)
if content then
print(call)
fhandle = fs.open(call, "w")
print(fhandle)
fhandle.write(content)
fhandle.close()
else
print("Error saving file...")
end
end
function http_get_gist(gistid,name)
if not gistid then return nil end
url="https://gist.github.com/"..gistid.."/raw"
if name then
url = url .. "/" .. name
end
-- Debug: Write out the URL
handle = http.get(url)
content = handle.readAll()
handle.close()
return content
end
--[[--
USAGE: loadgist returns a function when presented with two options
loadgist("indrora/8800011","loadgist.lua") -- Loads this script
loadgist("indrora/8800011",nil) -- Gets whatever Gisthub decides is the default file (usu. the first)
Bootstrapper:
Placing this into a turtle or computer in the lua shell will pull this script and begin loading it
assert( loadstring( http.get( "https://gist.github.com/indrora/8800011" ).readAll() ) )()
--]]--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.