Skip to content

Instantly share code, notes, and snippets.

@cxmeel
cxmeel / README.StoryCanvas.md
Last active May 20, 2024 11:17
StoryCanvas is a component for rendering React components in Hoarcekat.

StoryCanvas

StoryCanvas is a component for rendering React components in Hoarcekat.

Screenshot of StoryCanvas being rendered in Hoarcekat

A StoryCanvas component handles mounting and unmounting of stories automatically. It features:

  • A checkered background (synced with Studio theme)
  • A UIListLayout to display components centrally and evenly spaced
@cxmeel
cxmeel / lune-build.lua
Last active May 9, 2024 11:58
A Lune script for building plugins and watching for file changes
--!strict
--[[
Usage:
Build production release:
> `lune run build`
Build dev release to Roblox/Plugins directory:
> `lune run build -- --dev`
--[[
Parses a ISO 8601 UTC offset string into a float.
parseIsoUtcOffset("-0500") --> -5
parseIsoUtcOffset("+02") --> 2
parseIsoUtcOffset("-04:30") --> -4.5
parseIsoUtcOffset("Z") --> 0
local localTimezoneOffset = os.date("%z")
parseIsoUtcOffset(localTimezoneOffset)
@cxmeel
cxmeel / useDpiScale.lua
Created April 18, 2024 16:48
React-lua hook for determining DPI scale.
local UserInputService = game:GetService("UserInputService")
local React = require(script.Parent.Parent.Packages.React)
local useState = React.useState
local useEffect = React.useEffect
local function calculateDpiScale()
local BUTTON_CONTENTID = UserInputService:GetImageForKeyCode(Enum.KeyCode.ButtonA)
local BUTTON_SCALE = BUTTON_CONTENTID:lower():match("@([%d%.]-)x%.%w+$")
@cxmeel
cxmeel / timezones.lua
Last active April 11, 2024 21:56
A Lua table of alpha-2 region codes to UTC offsets in that region.
--[[
Format:
```lua
REGION_CODE = {
{ STD, DST },
}
```
]]
return {
@cxmeel
cxmeel / PrintEnv.luau
Last active February 21, 2024 19:33
Pretty-prints the current state of the OS environment to the console
local process = require("@lune/process")
local serde = require("@lune/serde")
local AVAILABLE_FORMATS = {
json = "json",
table = "json",
yml = "yaml",
yaml = "yaml",
toml = "toml",
}
@cxmeel
cxmeel / .darklua.json
Last active February 19, 2024 23:01
Bundling lune projects and building to standalone binary
{
"bundle": {
"require_mode": "path",
"excludes": [ "@lune/**" ]
},
"generator": "dense"
}
@cxmeel
cxmeel / MD_BUTTONS_DOCS.md
Last active May 18, 2024 04:07
Documentation for markdown buttons.

Markdown Buttons

A collection of SVG buttons for displaying custom "buttons" in Markdown content. You are free to use these buttons wherever you like. All buttons were created in Figma, with (most) icons provided by the Iconify plugin.

Sponsor on GitHub View Itch.io Store

The SVG files can be found on this gist. They have been separated in order to reduce the amount of lag when loading this README file.

--!strict
local RunService = game:GetService("RunService")
local Camera = workspace.CurrentCamera
local Module = {}
Module.Position = UDim2.new(0, 0, 0, 0)
Module.Size = UDim2.new(1, 0, 1, 0)
local function UDim2Absolute(udim2: UDim2)
@cxmeel
cxmeel / README.md
Created October 23, 2023 17:05
Luau Snippets

Luau Snippets

A collection of Luau snippets that can be copied and pasted directly into your code.

UrlDecode

Decodes a URL-encoded string back into human-readable characters.

UrlDecode("https%3A%2F%2Fcreate%2Eroblox%2Ecom") -- "https://create.roblox.com"