Skip to content

Instantly share code, notes, and snippets.

View Steellgold's full-sized avatar

Gaëtan H Steellgold

View GitHub Profile
import { dayJS } from "./day-js";
export const completeDateIfNecessary = (dayInput: string): string => {
const dateRegex = /^\d{2}\/\d{2}\/\d{4}$/;
if (dateRegex.test(dayInput)) {
console.log("Format correct :", dayInput);
return dayInput;
}
@Steellgold
Steellgold / Test.md
Last active February 12, 2025 10:48

Comment utiliser GitHub

Alors, partager du code c'est bien, mais le faire correctement c'est encore mieux. [...]

Premiers pas

Une fois que vous aurez créé un compte, vous aurez une interface de ce type :

Home of GitHub after creating an account

@Steellgold
Steellgold / index.php
Created January 31, 2025 09:20
Jonathan
<?php
function genTables($n, $m = 10) {
$result = [];
for ($i = 1; $i <= $m; $i++) {
$result[$i] = "$n x $i = " . ($n * $i);
}
return $result;
}
@Steellgold
Steellgold / lego-card.js
Created January 27, 2025 19:17
HTML CSS JS Component
class LegoItemCard extends HTMLElement {
constructor() {
super();
}
static get observedAttributes() {
return ['image', 'price', 'name', 'age', 'bricks'];
}
connectedCallback() {
<?php
namespace wapy\faction\blocks;
use pocketmine\block\Block;
use pocketmine\block\Transparent;
use pocketmine\data\bedrock\block\convert\BlockStateReader;
use pocketmine\data\bedrock\block\convert\BlockStateWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Bucket;
{"name":"JS","settings":"{\"settings\":\"{\\r\\n // Suppression de la sauvegarde automatique :\\r\\n \\\"files.autoSave\\\": \\\"off\\\",\\r\\n\\r\\n // Taille des tabulations par défaut :\\r\\n \\\"editor.tabSize\\\": 2,\\r\\n \\\"editor.formatOnSave\\\": false,\\r\\n\\r\\n // Linting & formatting on save :\\r\\n \\\"editor.codeActionsOnSave\\\": {\\r\\n \\\"source.fixAll.eslint\\\": \\\"explicit\\\"\\r\\n },\\r\\n \\\"[prisma]\\\": {\\r\\n \\\"editor.formatOnSave\\\": true,\\r\\n },\\r\\n \\r\\n \\\"editor.wordWrap\\\": \\\"bounded\\\",\\r\\n \\\"editor.wrappingIndent\\\": \\\"indent\\\",\\r\\n \\\"editor.wordWrapColumn\\\": 150,\\r\\n \\r\\n \\\"editor.rulers\\\": [\\r\\n {\\r\\n \\\"column\\\": 150,\\r\\n \\\"color\\\": \\\"#b1b1b127\\\"\\r\\n }\\r\\n ],\\r\\n \\r\\n \\\"javascript.updateImportsOnFileMove.enabled\\\": \\\"always\\\",\\r\\n \\\"typescript.updateImportsOnFileMove.enabled\\\": \\\"always\\\",\\r\\n\\r\\n // Theme :\\r\\n \\\"workbench.colorTheme\\\
@Steellgold
Steellgold / zero.tsx
Created May 4, 2024 18:18
The addZero function is used to format numbers by adding a zero in front of those less than 10, thereby enhancing the visual presentation of digital displays, such as times or dates, to make them more aesthetically pleasing and consistent.
import { ReactElement } from "react";
export const TimeDisplay = (): ReactElement => {
const currentHour = new Date().getHours();
const currentMinute = new Date().getMinutes();
const formattedHour = addZero(currentHour);
const formattedMinute = addZero(currentMinute);
return <p>Current Time: {formattedHour}:{formattedMinute}</p>;
@Steellgold
Steellgold / minimize.tsx
Created May 4, 2024 16:13
The function is a React component that displays different text depending on whether the browser window is wider or narrower than 640 pixels, using a responsive design approach.
"use client";
import { ReactElement } from "react";
import { useWindowSize } from "usehooks-ts";
export const Child = (): ReactElement => {
const { width } = useWindowSize();
const minimize = (wLarge: string, wMobile: string) => {
return width < 640 ? wMobile : wLarge;
import type { Dispatch, ReactElement, SetStateAction } from "react";
export type Component<Props> = (props?: Props) => ReactElement;
export type AsyncComponent<Props> = (props?: Props) => Promise<ReactElement>;
export type NPComponent<> = () => ReactElement;
export type NPAsyncComponent<> = () => Promise<ReactElement>;
export type SetState<T> = Dispatch<SetStateAction<T>>;
import type { ReactElement } from "react";
import { useState } from "react";
import { Button } from "react-native-paper";
import { useAsync } from "../../hooks/useAsync";
import { APP_VERSION } from "../../../../v";
import { supabase } from "../../db/supabase";
import type { Database } from "../../db/supabase.types";
import RNFetchBlob from "rn-fetch-blob";
import ApkInstallerModule from "../../../../apkinstaller";