Skip to content

Instantly share code, notes, and snippets.

@cxmeel
cxmeel / BasicState.lua
Last active September 8, 2020 08:39
A really simple state management solution for Roblox.
local State = {}
local function JoinDictionary(...)
local NewDictionary = {}
for _, Dictionary in next, { ... } do
for Key, Value in next, Dictionary do
NewDictionary[Key] = Value
end
end
@cxmeel
cxmeel / Signal.lua
Last active March 24, 2021 17:29
Pure Lua Signal
--[[
Signal class in pure Lua.
Based on Roblox's BindableEvents.
Signal.new(): Signal
-- Creates a new Signal object
Signal:Connect(Callback: function): SignalConnection
-- Binds a function to invoke when the Signal is fired
@cxmeel
cxmeel / class.lua
Created May 17, 2020 02:50
Lua Class Template
local Module = {}
Module.__index = Module
function Module.new()
local self = setmetatable({}, Module)
return self
end
@cxmeel
cxmeel / native-hash.js
Last active August 11, 2020 15:02
Native SHA hashing in Chrome/Chromium simplified using ES6 Promises
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
function hash(message = "", algorithm = hash.sha256) {
return new Promise((resolve, reject) => {
const textEncoder = new TextEncoder()
const encodedData = textEncoder.encode(message)
crypto.subtle.digest(algorithm, encodedData)
.then(arrayBuffer => {
const hashArray = Array.from(new Uint8Array(arrayBuffer))
@cxmeel
cxmeel / patreon-icon.jsx
Created August 11, 2020 16:22
Patreon Icon for Material-UI React
import React from "react"
import createSvgIcon from "@material-ui/icons/utils/createSvgIcon"
export default createSvgIcon(
<path d="M15.386.524c-4.764 0-8.64 3.876-8.64 8.64c0 4.75 3.876 8.613 8.64 8.613c4.75 0 8.614-3.864 8.614-8.613C24 4.4 20.136.524 15.386.524M.003 23.537h4.22V.524H.003" />,
"Patreon"
)
@cxmeel
cxmeel / remote-fireclients.lua
Created August 25, 2020 12:04
Fire RemoteEvents to selected Clients
local Module = {}
local Players = game:GetService("Players")
--[[
ResolvePlayers(
PlayerList: Player | Player[] | string | string[] | number | number[]
): table
Converts an array of values (or single value) into an Array of Players.
--]]
@cxmeel
cxmeel / motion-calc.lua
Last active September 5, 2020 17:52
Roblox Module for speed/distance/time calculations.
--!strict
local Motion = {}
function Motion.GetDistance(Speed: number, Time: number): number
return Speed * Time
end
function Motion.GetTime(Distance: number, Speed: number): number
return Distance / Speed
end
@cxmeel
cxmeel / EventHandler.lua
Last active September 8, 2020 17:55
Handles running time-based events in Roblox
--[[
EventHandler by csqrl (ClockworkSquirrel)
Version: 0.0.2
Documentation:
EventHandler.new(EventLength: number): Handler
Methods:
Handler:Start(): void
Handler:Pause(): void
@cxmeel
cxmeel / A_RawSignal.lua
Last active November 8, 2022 15:56
Recreation of Roblox RBXScriptSignals in pure Lua
--[[
RawSignal by csqrl (ClockworkSquirrel)
Version: 0.0.2
License: MIT
Originally uploaded to Dcoder.
Documentation:
Signal:
Methods:
@cxmeel
cxmeel / LICENSE
Last active October 7, 2023 07:26
Copies a short URL for the current page to the clipboard, using ShortBlox by @railworks2
Copyright 2020 csqrl (ClockworkSquirrel)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH