Skip to content

Instantly share code, notes, and snippets.

@cxmeel
cxmeel / 01.README.md
Last active December 2, 2023 13:34
Hover cards for the Roblox website.

A custom fetch/GM_xmlhttpRequest wrapper for UserScripts.

Fetch Options

Extends the default fetch options. If using GM_xmlhttpRequest (useFetch: false), the timeout is 60 seconds.

local function parseImageString(imageString: string)
local contentId = imageString:match("(%w+://%S+)")
local width = tonumber(select(1, imageString:match("[wW](%d+)")))
local height = tonumber(select(1, imageString:match("[hH](%d+)")))
local x = tonumber(select(1, imageString:match("[xX](%d+)")))
local y = tonumber(select(1, imageString:match("[yY](%d+)")))
local color = imageString:match("(#%x+)")
local transparency = tonumber(select(1, imageString:match("(%d+)%%")))
type Set<T> = { [T]: true }
-- Asymmetric difference
local function difference<V>(set: Set<V>, ...: Set<V>): Set<V>
local diff = table.clone(set)
for index, nextSet in { ... } do
for value in nextSet do
diff[value] = nil
end
@cxmeel
cxmeel / README.md
Last active December 10, 2024 22:43
Markdown buttons

Markdown Buttons

The documentation has been moved to this gist in order to reduce lag.

@cxmeel
cxmeel / generate-flag-emoji.lua
Created December 3, 2022 20:01
Generate a flag emoji from the player's region
--!strict
local regionalIndicators = { A = "๐Ÿ‡ฆ", B = "๐Ÿ‡ง", C = "๐Ÿ‡จ", D = "๐Ÿ‡ฉ", E = "๐Ÿ‡ช", F = "๐Ÿ‡ซ", G = "๐Ÿ‡ฌ", H = "๐Ÿ‡ญ", I = "๐Ÿ‡ฎ", J = "๐Ÿ‡ฏ", K = "๐Ÿ‡ฐ", L = "๐Ÿ‡ฑ", M = "๐Ÿ‡ฒ", N = "๐Ÿ‡ณ", O = "๐Ÿ‡ด", P = "๐Ÿ‡ต", Q = "๐Ÿ‡ถ", R = "๐Ÿ‡ท", S = "๐Ÿ‡ธ", T = "๐Ÿ‡น", U = "๐Ÿ‡บ", V = "๐Ÿ‡ป", W = "๐Ÿ‡ผ", X = "๐Ÿ‡ฝ", Y = "๐Ÿ‡พ", Z = "๐Ÿ‡ฟ" }
local function constructFlagEmoji(region: string): string
local flag = {}
for _, char in region:split("") do
table.insert(flag, regionalIndicators[char:upper()])
end
[[afterAll.args]]
type = "function"
[[afterEach.args]]
type = "function"
[[beforeAll.args]]
type = "function"
[[beforeEach.args]]
(function(namespace) {
function Create(className = "span", attributes = {}, ...children) {
const node = document.createElement(className)
let onInit = null
const events = {
event: {},
}
for (const [attributeName, attributeValue] of Object.entries(attributes)) {
--!strict
local Creator = {}
type PropsType = { [any]: any }
type SymbolicKey<T> = { type: string, value: T }
type PublicSymbolicKey<T> = (value: T) -> SymbolicKey<T>
local function SymbolicKey(name: string, valueType: string?)
return function(value: any)
if valueType ~= nil and valueType ~= "*" then
--!strict
local POLYNOMIAL = 0xEDB88320
local HASH_TABLE = {}
for index = 0, 255 do
local value = index
for _ = 1, 8 do
if value % 2 == 1 then