Skip to content

Instantly share code, notes, and snippets.

View cameronpcampbell's full-sized avatar

Cameron Campbell cameronpcampbell

View GitHub Profile
@cameronpcampbell
cameronpcampbell / StudioColor.lua
Last active January 16, 2024 22:39
StudioColor
--!strict
--> Packages ------------------------------------------------------------------------------------------
local Fusion = require(--[[Put path to Fusion module here.]])
local Value, peek, Computed = Fusion.Value, Fusion.peek, Fusion.Computed
-------------------------------------------------------------------------------------------------------
--> Types ---------------------------------------------------------------------------------------------
--[[
Copyright 2024 Cameron Campbell
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 THE U
@cameronpcampbell
cameronpcampbell / init.luau
Created August 22, 2024 20:47
Component Helper (Fusion)
--!strict
--> Modules -------------------------------------------------------------------------------------------
local Fusion = require(script.Parent.Fusion) -- Replace with path to fusion.
-------------------------------------------------------------------------------------------------------
--> Types ---------------------------------------------------------------------------------------------
type Scope = Fusion.Scope<typeof(Fusion)>
--!strict
--> Modules -------------------------------------------------------------------------------------------
local Fusion = require(Packages.Fusion) -- Make sure to put path to Fusion here.
-------------------------------------------------------------------------------------------------------
--> Functions -----------------------------------------------------------------------------------------
local function ComputeUDim(scope: Fusion.Scope<typeof(Fusion)>, scale: Fusion.UsedAs<number>, offset: Fusion.UsedAs<number>)
--[[
Copyright 2024 Cameron Campbell
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 THE U
@cameronpcampbell
cameronpcampbell / mock_web_framework.luau
Last active December 15, 2024 04:00
mock_web_framework.luau
--!strict
type AppRunConfig = {
port: number
}
type function _stringSplitOnce(str: string, delimiter: string)
local start, finish = string.find(str, delimiter, 1, true)
if start then
local before = string.sub(str, 1, start - 1)
--!strict
--!nolint LocalUnused
--!nolint LocalShadow
local task = nil -- Disable usage of Roblox's task scheduler
--[[
A special key for property tables, which applies any given tags onto
an instance.
]]
--!strict
--!nolint LocalUnused
--!nolint LocalShadow
local task = nil -- Disable usage of Roblox's task scheduler
--[[
A special key for property tables, which parents any given descendants into
an instance.
]]
@cameronpcampbell
cameronpcampbell / StringToPascal.luau
Created February 19, 2025 14:39
StringToPascal.luau
--!strict
type function _safeIs(input: any, isType: any)
if typeof(input) ~= "userdata" then return false end
local is = input.is
if not is then return false end
return is(input, isType)
end
--!strict
--!nolint LocalShadow
export type TrieNode = {
is_end: boolean,
children: { [number]: TrieNode }
}
local function table_is_empty(tble: { [any]: any })
for _ in tble do return false end