Skip to content

Instantly share code, notes, and snippets.

View hugeblank's full-sized avatar
🥯
Be not square

Todd hugeblank

🥯
Be not square
View GitHub Profile
@hugeblank
hugeblank / util.lua
Last active January 31, 2019 20:52
A modified, more advanced form of the read() computercraft function.
--[[
Features:
- All arguments are put into a table, so that they don't have to be put in any particular order, like how it is in read().
- Type error protection has been condensed into a more understandable form.
- Adds a few arguments, including those from read(), and others that would never make it into read():
- replaceChar (_sReplaceChar)
- history (_tHistory)
- complete (_fnComplete)
- prefix (_sDefault)
@hugeblank
hugeblank / enchat3.hvfs
Last active December 6, 2018 00:32
Demo Harbor Virtual File System for ComputerCraft Lua - Enchat 3 | https://github.com/LDDestroier/enchat | Uses harbor: https://pastebin.com/ivRuuLSH
os.loadAPI("/.harbor/bbpack.lua") -- Write to the file this string | Load the bbpack API locally
local bbpack = {}
bbpack = _G.bbpack
_G.bbpack = nil
local boot = " -- Create the boot function, as a string for recursion\
os.loadAPI(\"/.harbor/bbpack.lua\") -- Load the LZW compression algorithm by BombBloke\
local bbpack = {}\
bbpack = _G.bbpack\
_G.bbpack = nil\
local args = {...} -- Pull the arguments into a table\
@hugeblank
hugeblank / lispify.lua
Last active October 27, 2018 00:04
Convert the CC libraries, or any of your own libraries into importable lisp variants (probably for urn)
local args = {...}
local env
if #args > 0 then
for i = 1, #args do
if _ENV[lib] then
env = _ENV[lib]
else
print(lib.." is not a library in _ENV")
end
end
@hugeblank
hugeblank / convert.lua
Created December 1, 2018 00:09
Demonstration of the power of harbor by compressing the VFS and making an executable out of it
local args = {...}
local convert = loadfile("/.harbor/harbor.lua")().convert -- loadfile in the only necessary harbor function
-- Executable compression
if not fs.exists("/.harbor/bbpack.lua") then -- If we don't have BBPack installed
local bbpdown = http.get("https://pastebin.com/raw/cUYTGbpb") -- get it via http
local bbpfile = fs.open("/.harbor/bbpack.lua", "w") -- open a file for it
bbpfile.write(bbpdown:readAll()) -- write contents of request
bbpfile:close() -- close and close
bbpdown:close()
@hugeblank
hugeblank / emu-corral.lua
Last active February 28, 2019 02:52
Organize your workflow in CCEMUX by setting this up in computer 0. Emu Corral gives you the ability to easily add and manage your projects, hopefully contained in individual computers.
os.pullEvent = os.pullEventRaw -- Lock down this computer, we don't really need direct access to it
local title = "Your Emus:" -- Replace this with whatever you want to have as the header of this menu
local emus = {"Project 1"} -- Your projects.
local open, selected, ctr = nil, 1, 0 -- emulator to open, is only set when a project is selected | the project that the cursor is hovering over | the position used to center the text. Half of the value of the largest string in your projects.
local x, y = term.getSize() -- Get the size of the terminal
for i = 1, #emus do -- For each of your projects
if (emus[i]):len() > ctr then -- If the length of this project string is larger than the current center value
ctr = (emus[i]):len() -- Set it to that value
end
end
@hugeblank
hugeblank / dynahex.lua
Created December 5, 2018 21:50
Dynamically load and unload ComputerCraft terminal palette segments
-- DynaHex by hugeblank
-- Dynamically load and unload palette segments
--[[ BEGIN LICENSE
I, hugeblank formally do not give a rats arse about what you do with this code.
END LICENSE ]]
local this = {} -- This API
local reserved = {} -- Colors set based on how many objects refer to them. If this number is 0 at any index then that color is not referred.
local objects = {} -- Objects that contain hexchex information
local orig = {} -- Original pallete colors
@hugeblank
hugeblank / semver.lua
Created February 27, 2019 08:05
SemVer 2.0.0 parser
-- SemVer parser by hugeblank https://github.com/hugeblank
-- Parses strings that meet SemVer 2.0.0 specs as documented here: https://semver.org/spec/v2.0.0.html
-- Feel free to use/redistribute/modify this file. Should you do so keep the above 3 lines as they are.
-- Any strings that don't meet SemVer specs the parse will return false, and the rule number violated
-- If successful, parser will return a table that can be compared with other SemVer tables.
local this, meta = {}, {}
meta.__eq = function(in1, in2)
@hugeblank
hugeblank / json.lua
Last active March 4, 2019 07:12
Requirable form of ElvishJerricco's JSON parsing API
--[[
Requirable form of ElvishJerricco's JSON parsing API
Original: http://pastebin.com/4nRg9CHU
]]
local this = {}
------------------------------------------------------------------ utils
local controls = {["\n"]="\\n", ["\r"]="\\r", ["\t"]="\\t", ["\b"]="\\b", ["\f"]="\\f", ["\""]="\\\"", ["\\"]="\\\\"}
local function isArray(t)
local max = 0
@hugeblank
hugeblank / nap.lua
Last active March 4, 2019 07:20
REST/HTTP simplifying API
--[[ nap by hugeblank
Nap is designed for use as a REST API parser, but works remarkably great with HTTP in general.
It uses metatables to detect indexing, and when called GETs/POSTs/ETC. the given data depending on the table passed in.
Ex:
nap = require("nap")
github = nap("https://api.github.com")
handle = github.repos['username']['repo'].git.trees.master({
method = "GET",
query = {["recursive"] = 1}
})
@hugeblank
hugeblank / dep-test.ltn
Last active May 1, 2019 07:10
Felt cute, might delete later.
{
{
source = "https://raw.github.com/hugeblank/raisin/0c71e68ee0b228ba2aa33dc9918f05e10d6e1092/raisin.lua",
path = "raisin.lua",
versions = {
"0.0.0",
"0.0.1-test"
}
},
{