Skip to content

Instantly share code, notes, and snippets.

View antoniopresto's full-sized avatar

antoniopresto

  • São Paulo - Brasil
View GitHub Profile
#!/bin/bash
# Check if an argument is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <path_to_Dockerfile | image_name>"
exit 1
fi
# Function to list the contents of a Docker image in a tree format
list_image_contents() {
export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH=/Users/$USER/.pyenv/versions/2.7.18/bin:$PATH
alias reload="source ~/.zshrc"
alias w="webstorm"
alias zshrc="idea ~/.zshrc"
alias i="pm install"
alias rr="cargo-watch -x run"
echopm(){
@antoniopresto
antoniopresto / clear-webstorm-cache.sh
Created February 16, 2024 02:20
Clear WebStorm cache
# https://www.jetbrains.com/help/webstorm/directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#plugins-directory
rm -rf ~/Library/Caches/JetBrains/WebStorm*
@antoniopresto
antoniopresto / reset.sh
Last active February 9, 2024 02:08
Full reset project
#!/bin/sh
git add .
COMMIT_SUCCESS=false
if git commit -m 'temp'; then
COMMIT_SUCCESS=true
fi
git clean -fdx
if [ "$COMMIT_SUCCESS" = true ]; then
git reset --soft HEAD~1
function createWorker(items: string[]) {
const code = makeCode(JSON.stringify(items));
const blob = new Blob(code, {
type: 'text/javascript',
});
const blobUrl = URL.createObjectURL(blob);
const worker = new Worker(blobUrl);
@antoniopresto
antoniopresto / .zshrc
Created February 20, 2023 02:54
Creates a .nosync file in all directories that start with a dot or are named node_modules on npm install
# will run after npm install
function npm() {
if [[ $1 == "install" ]]; then
command npm "$@"
# Creates a .nosync file in all directories that start with a dot or are named node_modules
find . -mindepth 1 -maxdepth 1 -type d \( -name ".*" -o -name "node_modules" \) ! -name ".git" -exec touch {}/.nosync \; -exec echo "File .nosync created in {}" \;
else
command npm "$@"
fi
}
@antoniopresto
antoniopresto / typescript_debug_diagnostics.sh
Created November 21, 2022 22:42
Degug typescript (diagnostics) types
tsc --diagnostics' > './logs/diagnostics-$(date +%Y%m%d%H%M%S).log'
# option found on https://rocksthinkpoorly.com/guide/2021/06/01/debug-tsc-builds.html#diagnostics
import cx from 'classnames';
import { createType, Infer, tuple, tupleNum } from 'backland';
export const ViewportSizeEnum = tuple('xs', 'sm', 'md', 'lg', 'xl');
export const ViewportSizes = Object.values(ViewportSizeEnum);
export type ViewportSize = typeof ViewportSizes[number];
export const ViewportSizeType = createType('ViewportSize', {
enum: ViewportSizes,
optional: true,
const userSchema = createSchema({
name: 'string?',
age: 'int',
gender: ['f', 'm', 'o'],
address: {
type: 'schema',
def: {
name: 'string',
number: [['float', 'string']],
},
@antoniopresto
antoniopresto / NullableToPartial.ts
Last active January 27, 2022 16:21
Typescript convert Nullable (null or undefined) to Partial / not required
export type NullableToPartial<T> = T extends { [K: string]: any }
? {
[K in keyof ({
[K in NullableKeys<T>]?: T[K];
} & {
[K in RequiredKeys<T>]-?: T[K];
})]: ({
[K in NullableKeys<T>]?: T[K];
} & {
[K in RequiredKeys<T>]-?: T[K];