Skip to content

Instantly share code, notes, and snippets.

@Profesor08
Profesor08 / scripts.md
Last active April 23, 2025 12:37
Script types

Inline script

<script>
const prop = 123;

console.log(prop);
</script>
@Profesor08
Profesor08 / useFetch.ts
Created March 22, 2025 21:32
useSWR wrapper with improved types
import useSWR from "swr";
type Fetcher<FetchData, FetchKey extends Key> = (
key: FetchKey
) => FetcherResponse<FetchData>;
type FetcherResponse<FetchData = unknown> = FetchData | Promise<FetchData>;
type KeyValue =
| string
@Profesor08
Profesor08 / prettier.config.mjs
Created November 10, 2024 16:37
Prettier config
/**
* @see https://prettier.io/docs/en/configuration.html
* @type {import("prettier").Config}
*/
const config = {
/**
* Specify the line length that the printer will wrap on.
* @default 80
*/
printWidth: 120,
export const Example1 = () => {
return (
<Markdown className="terms-text" inline>
This is an exmplple of usage for [this gist](https://gist.github.com/Profesor08/63f8a23944cbb98705477198639cd3a5) in react
</Markdown>
);
};
export const Example2 = () => {
return (
@Profesor08
Profesor08 / styleToCSSProperties.ts
Last active July 10, 2024 08:53
Convert style string to CSSProperties
import camelCase from "lodash/camelCase";
export const styleToCSSProperties = (style: string = "") => {
return style
.trim()
.split(";")
.map((rule) => {
const [key, value] = rule.trim().split(":");
return {
class CharacterClass
{
private static $characterClasses = [
["code" => 0, "name" => ["full" => "Dark Wizard", "short" => "DW", "group" => "dw"], "itemClass" => "DarkWizard", "classNumber" => 1],
["code" => 1, "name" => ["full" => "Soul Master", "short" => "SM", "group" => "dw"], "itemClass" => "DarkWizard", "classNumber" => 2],
["code" => 3, "name" => ["full" => "Grand Master", "short" => "GM", "group" => "dw"], "itemClass" => "DarkWizard", "classNumber" => 3],
["code" => 7, "name" => ["full" => "Soul Wizard", "short" => "SW", "group" => "dw"], "itemClass" => "DarkWizard", "classNumber" => 4],
["code" => 16, "name" => ["full" => "Dark Knight", "short" => "DK", "group" => "dk"], "itemClass" => "DarkKnight", "classNumber" => 1],
["code" => 17, "name" => ["full" => "Blade Knight", "short" => "BK", "group" => "dk"], "itemClass" => "DarkKnight", "classNumber" => 2],
@Profesor08
Profesor08 / Open in Windows Terminal.ps1
Last active May 18, 2021 19:36
Open in Windows Terminal
<#
Hint: Allowing opening tabs in same directory
1. Open Windows Terminal settings
2. Navigate to Profiles and select one
3. Find Starting Directory config
4. Activate checkbox "Use parent process directory"
5. Repeat 2-4 for all profiles
#>
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {