Skip to content

Instantly share code, notes, and snippets.

View Puppo's full-sized avatar

Luca Del Puppo Puppo

View GitHub Profile
@Puppo
Puppo / index.ts
Created October 25, 2023 09:36
CamelCaseToSnakeCase
type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}`
? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}`
: Lowercase<S>
type KeysToCamelCase<T> = {
[K in keyof T as CamelCase<string & K>]: T[K]
}
type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` ?
@Puppo
Puppo / gitconfig
Last active April 19, 2023 19:44
gitConfig
[user]
name = Luca Del Puppo
email = email
[core]
editor = code-insiders --wait
autocrlf = input
[init]
defaultBranch = main
[filter "lfs"]
required = true
@Puppo
Puppo / git-setup.sh
Last active April 17, 2023 17:48
Git Setup
git config --global user.name "Luca Del Puppo"
git config --global user.email
git config --global core.editor "code-insiders --wait"
git config --global core.autocrlf input
git config --global pull.rebase true
@Puppo
Puppo / rename-branch.sh
Created April 21, 2022 07:28
Rename Local and Remote Branch
git checkout <old_name>
git branch -m <new_name>
git push origin -u <new_name>
git push origin --delete <old_name>
@Puppo
Puppo / clean-git-repository.sh
Created February 25, 2022 09:42
Clean Git Repository
#!/bin/bash
git remote prune origin
git branch -a -v | grep -e '\[gone\]' | awk {'print $1'} | xargs git branch -D
@Puppo
Puppo / NotEmptyArray.ts
Last active February 23, 2022 15:40
NotEmptyArray definition
export interface NonEmptyArray<A> extends ReadonlyArray<A> {
// tslint:disable-next-line: readonly-keyword
0: A;
}
type ReadOnlyNotEmptyArray<T> = Readonly<NotEmptyArray<T>>;
function isNotEmptyArray<T>(as: T[]): as is NotEmptyArray<T> {
return as.length > 0;
}
@Puppo
Puppo / enum.ts
Last active April 1, 2021 14:43
Typescript Enum from const
type KeyOf<E> = keyof E;
/**
* Convert const enum to types
* @example
* const ENUM_CONST = {
* KEY1: "VALUE1",
* KEY2: "VALUE2",
* KEY3: 3,
* KEY4: true,
* } as const;