Skip to content

Instantly share code, notes, and snippets.

View cyrus01337's full-sized avatar

Cyrus cyrus01337

View GitHub Profile
@cyrus01337
cyrus01337 / deprecated-alternatives.md
Last active May 31, 2024 13:26
A curated list of deprecated methods and their alternatives, including coverage from devforum posts
@cyrus01337
cyrus01337 / FindPartsInRay.lua
Created July 12, 2023 10:08
Function to raycast and get back multiple instances the raycast skewers
type Parts = {BasePart}
local function findTopmostModelAncestor(instance: Instance): Instance?
local modelAncestorFound = instance:FindFirstAncestorOfClass("Model")
while modelAncestorFound do
local newModelAncestorFound = instance:FindFirstAncestorOfClass("Model")
if modelAncestorFound and newModelAncestorFound == nil then
@cyrus01337
cyrus01337 / Server.lua
Created July 7, 2023 12:50
PlayerAdded and PlayerRemoving connections without suspecting memory leaks.
local Players = game:GetService("Players")
local characterAddedConnections: { [Player]: RBXScriptConnection } = {}
local function onPlayerAdded(player: Player)
characterAddedConnections[player] = player.CharacterAdded:Connect(function(playerChar)
local Humanoid = playerChar:WaitForChild("Humanoid")
print(playerChar.Parent, Humanoid.Parent.Parent)
Humanoid.WalkSpeed = 0
@cyrus01337
cyrus01337 / 1 Embed.py
Created March 29, 2023 04:45
Example of custom Embed sub-class that avoids method calls by passing data as kwargs and hiding calls in the initialiser. This concept can also be thought of as providing sensible defaults to simplify developer input when creating embeds en masse.
# src/utils.py
from __future__ import annotations
from collections import namedtuple
import discord
Author = namedtuple("Author", ["name", "url", "icon_url"])
Footer = namedtuple("Footer", ["text", "icon_url"])
Field = namedtuple(
@cyrus01337
cyrus01337 / Devices.jsx
Created January 5, 2023 11:36
Responsive component that conditionally renders based on resolution
import { useEffect, useState } from "react";
const MOBILE_WIDTH = 1024;
export const isDesktop = (limit = MOBILE_WIDTH) => window.innerWidth > limit;
export const isMobile = (limit = MOBILE_WIDTH) => window.innerWidth <= limit;2
const useResolutionChecker = ({ desktop, mobile }) => {
const [inMobileResolution, setInMobileResolution] = useState(isMobile());
:root {
--default-emoji-size: 1.375rem;
--default-emoji-jumboable-size: 3rem;
--emoji-size: calc(var(--default-emoji-size) * 2);
--emoji-jumboable-size: calc(var(--default-emoji-jumboable-size) * 2);
}
/* Change emoji size */
[class*="messageContent"]:not([class*="repliedTextContent"]) .emoji {
height: var(--emoji-size) !important;
@cyrus01337
cyrus01337 / 1 FEATURES.md
Last active December 6, 2022 05:46
Curated list of Discord bot commands to be used as a reference (for creating the ultimate bot in history duh /s)

List of Commands

General

  • Standard and edit snipes
  • Display invite info
  • Reminders
  • Member inspection (Whois)

Logging

  • Kicks (fetch audit logs to verify)
@cyrus01337
cyrus01337 / global.code-snippets
Created June 16, 2022 15:45
Zustand useStore snippet
"useStore Hook": {
"scope": "javascript,typescript,javascriptreact",
"prefix": ["use", "usestore"],
"body": [
"let ${0:slice} = useStore(state => state.${0:slice});"
]
},
@cyrus01337
cyrus01337 / QueueSystem.lua
Created May 6, 2022 03:48
My attempt at a queue system for event callbacks.
type QueueKey = {
RBXScriptSignal,
(...)
}
local arguments = { [QueueKey]: {any}? }
local connections: { [QueueKey]: RBXScriptConnection } = {}
local queues: { [QueueKey]: number } = {}
@cyrus01337
cyrus01337 / get_emoji_format.py
Created February 16, 2021 15:37
Function that grabs emotes based on name - useful for those without Nitro attemping to grab the formatting of animated emotes.
import os
import discord
def get_emoji_format(name: str):
guild_obj: discord.Guild = None
if os.environ.get("JISHAKU_NO_UNDERSCORE", False):
guild_obj = guild