Skip to content

Instantly share code, notes, and snippets.

View Steellgold's full-sized avatar
🍓

Gaëtan H Steellgold

🍓
View GitHub Profile
@Steellgold
Steellgold / color.ts
Created November 26, 2023 15:37
Your text need to be dark or white?
const textIsWhite = (color: string): boolean => {
const hex = color.replace("#", "");
const c_r = parseInt(hex.slice(0, 2), 16);
const c_g = parseInt(hex.slice(2, 4), 16);
const c_b = parseInt(hex.slice(4, 6), 16);
const brightness = ((c_r * 299) + (c_g * 587) + (c_b * 114)) / 1000;
return brightness < 155;
};
@Steellgold
Steellgold / package.json
Created November 25, 2023 15:35
To avoid errors (e.g: Type error: Type 'ZodObject<{ where: ZodLazy<ZodType[...])
"scripts": {
"prisma:generate": "prisma generate && node prisma-zod-ts-nocheck.js"
}
@Steellgold
Steellgold / Unicode.php
Last active November 25, 2023 15:40
Recover a unicode to use it. (From my private project)
<?php
namespace your/namespace;
use JsonException;
use pocketmine\utils\Config;
// use your/plugin/Main
class Unicode {
@Steellgold
Steellgold / Serializer.php
Created July 10, 2022 21:06
Serialize and unserialize contents inventory (PocketMine-MP 4)
<?php
namespace steellgold\utils;
use pocketmine\item\Item;
use pocketmine\nbt\BigEndianNbtSerializer;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\TreeRoot;
@Steellgold
Steellgold / ChancePercentage.php
Last active January 26, 2022 20:09
Chance Function PHP
<?php
namespace App\Utils;
class ChancePercentage {
public function chancePercentage(array $array = [
"myFirstValue" => [
"chance" => 3,
"name" => "Money x40000",
"content" => "This is mythic rarity! if you have luck you win this!!"
<?php
namespace App\Utils;
use Exception;
class UUID {
/**
* @throws Exception
*/