Skip to content

Instantly share code, notes, and snippets.

View howmanysmall's full-sized avatar
😎
pobam L+

howmanysmall

😎
pobam L+
  • Utah
View GitHub Profile
------------------------------------------------------------------------------------------------------------------
-- CFrameSerializer.lua
-- Written by CloneTrooper1019
-- @ 3/7/2019
------------------------------------------------------------------------------------------------------------------
-- Usage
-- string CFrameSerializer:EncodeCFrame(CFrame cf) < Compresses a CFrame into a JSON string.
-- CFrame CFrameSerializer:DecodeCFrame(string cf) < Decompresses a JSON CFrame string.
------------------------------------------------------------------------------------------------------------------
-- Utility Functions
-- Elliptic Curve Cryptography in Computercraft
local byteTableMT = {
__tostring = function(a) return string.char(unpack(a)) end,
__index = {
toHex = function(self, s) return ("%02x"):rep(#self):format(unpack(self)) end,
isEqual = function(self, t)
if type(t) ~= "table" then return false end
if #self ~= #t then return false end
local ret = 0
@howmanysmall
howmanysmall / FastBitBuffer.lua
Last active November 29, 2020 04:06
MOVED TO A REPO - https://github.com/howmanysmall/FastBitBuffer. My BitBuffer module versus other BitBuffers. Mine is the FastBitBuffer one below. CC0 license.
--[[
==========================================================================
== API ==
Differences from the original:
Using metatables instead of a function returning a table.
Added Vector3, Color3, Vector2, and UDim2 support.
Deprecated BrickColors.
Changed the creation method from BitBuffer.Create to BitBuffer.new.
using extern CFrame.new;
using extern CFrame.fromAxisAngle;
using extern Vector3.new;
using extern Vector3.FromNormalId;
using extern Instance.new;
using extern error;
typedef ArrayOfInstances table<int, RbxInstance>;
RbxInstance ChangeHistoryService = game::GetService @ ChangeHistoryService;
local DIGITS = 1000
DIGITS = DIGITS + 2
local LENGTH = math.modf(10 * DIGITS / 3)
local RUN_AMOUNT = 100
local STRING = "Time to run %s %d times: %.4f seconds"
local os_clock = tick or os.clock
local function CalculatePi()
--[[
Lexical scanner for creating a sequence of tokens from Lua source code.
This is a heavily modified and Roblox-optimized version of
the original Penlight Lexer module:
https://github.com/stevedonovan/Penlight
Authors:
stevedonovan <https://github.com/stevedonovan> ----------------- Original Penlight lexer author
ryanjmulder <https://github.com/ryanjmulder> ----------------- Penlight lexer contributer
mpeterv <https://github.com/mpeterv> ----------------- Penlight lexer contributer
Tieske <https://github.com/Tieske> ----------------- Penlight lexer contributer
local bit32 = {}
local bit = require("bit")
for Index, Function in next, bit do
bit32[Index] = Function
end
bit32.rrotate = bit.ror
bit32.lrotate = bit.rol
var MARKERS = ["X", "O"];
var PLAYER_1_NAME = document.getElementById("player1name");
var PLAYER_2_NAME = document.getElementById("player2name");
var GAME_MESSAGE = document.getElementById("game-message");
var WIN_SOUND = document.getElementById("win-sound");
var ERROR_SOUND = document.getElementById("error-sound");
var WIN_CODES = [7, 56, 73, 84, 146, 273, 292, 448];
var VALUES = [1, 2, 4, 8, 16, 32, 64, 128, 256];
GAME_MESSAGE.innerText = "Please enter names below.";
var PlayerTurn = 0;
local lua_builtin = {
-- Lua Functions
["assert"] = true;
["collectgarbage"] = true;
["error"] = true;
["getfenv"] = true;
["getmetatable"] = true;
["ipairs"] = true;
["loadstring"] = true;
["newproxy"] = true;
--[[----------------------------------------------------------------------------
MessagePack encoder / decoder written in pure Lua 5.3
written by Sebastian Steinhauer <[email protected]>
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any