Skip to content

Instantly share code, notes, and snippets.

View grilme99's full-sized avatar
💜
:o

Brooke Rhodes grilme99

💜
:o
View GitHub Profile
@grilme99
grilme99 / Icon.tsx
Last active October 18, 2024 16:50
SVG rendering in Unity with SkiaSharp + OneJS
import { h } from "onejs-preact";
import { useEffect, useMemo, useRef } from "onejs-preact/hooks";
import { useSvgTexture } from "src/contexts/svg-cache/use-svg-texture";
import { tv } from "tailwind-variants";
import filledIcons from "src/generated/icons/filled.json";
import outlinedIcons from "src/generated/icons/outlined.json";
export type IconSize = "x-small" | "small" | "medium" | "large" | "x-large" | "xx-large";
@grilme99
grilme99 / binding-utils.luau
Last active August 29, 2024 22:20
React-lua hooks for Ripple
--[[
Returns whether the given value is a binding.
@param value The value to check.
@return Whether the value is a binding.
]]
local function isBinding(value: unknown): boolean
return ReactIs.isBinding(value)
end
--[[
@grilme99
grilme99 / use-px.luau
Last active August 12, 2024 21:55
use-px hook for React
-- Based on this Typescript implementation by Littensy:
-- https://github.com/littensy/charm-example/blob/7def4fbbfafe13d482edd7b6b89417d4ee42516b/src/client/composables/use-px.ts
local React = require("@pkg/react")
local useState = React.useState
local useCallback = React.useCallback
local useEffect = React.useEffect
local useMemo = React.useMemo
@grilme99
grilme99 / BedWarsTypes.d.lua
Created August 19, 2023 17:59
Luau type declarations for the BedWars scripting API
-- GLOBAL TYPES
export type Array<T> = {T}
export type Map<K, V> = {[K]: V}
export type String = {
includes: (a: string, b: string) -> boolean,
startsWith: (a: string, searchTerm: string) -> boolean,
endsWith: (a: string, searchTerm: string) -> boolean,
lower: (str: string) -> string,
@grilme99
grilme99 / DynamicMesh.lua
Last active August 10, 2024 22:38
Example of Roblox's new DynamicMesh class, generated using ChatGPT. Works at runtime in an ordinary LocalScript.
-- Create a new DynamicMesh instance
local dynamicMesh = Instance.new("DynamicMesh")
-- Function to get perlin noise
local function perlinNoise(x, y, scale, height)
return math.noise(x * scale, y * scale) * height
end
local size = 50 -- Size of the terrain
local scale = 0.1 -- Scale factor for Perlin noise
@grilme99
grilme99 / Spring.cs
Last active May 18, 2023 18:20
Spring implementation for Unity based on Nevermore
// A physical model of a spring, based off:
// https://github.com/Quenty/NevermoreEngine/blob/2ad8cea7dd3ad79a39afd7d7b785b489b90553fd/src/spring/src/Shared/Spring.lua
//
// A spring is an object that will compute based upon Hooke's law. Properties only evaluate upon index making this class
// good for lazy applications.
using System;
using UnityEngine;
public class Spring
@grilme99
grilme99 / ElevatedPluginDemoter.lua
Last active September 8, 2023 15:20
Roblox elevated/internal plugin demoter
--[[
ELEVATED PLUGIN DEMOTER
"One-click" script to demote elevated (usually internal) plugins by removing or
replacing their elevated API calls.
NOTE:
I've only tested this on the "Developer" Storybook plugin (the irony). It will probably
need some modification for other internal plugins, like the Roact Inspector.
STEPS TO USE: