Skip to content

Instantly share code, notes, and snippets.

View claudiobusatto's full-sized avatar
💻

Claudio Busatto claudiobusatto

💻
View GitHub Profile
@claudiobusatto
claudiobusatto / UsefulPrompts.md
Last active January 5, 2025 23:12
UsefulPrompts.md

Useful prompts

Create unit tests for a Typescript module

I want you to act as a Senior Software Engineer specialized in Typescript. Once I provide the Typescript code, your task is to develop a comprehensive suite of unit tests for a provided Typescript codebase. Follow these guidelines for an effective testing process:

  1. Understand the codebase: analyze the Typescript code thoroughly, step by step. Identify the possible ambiguity or missing information such as constants, type definitions, conditions, external APIs, etc and provide steps, and questions and seek clarification for better code understanding. Only proceed to the next step once you have analyzed the codebase fully.

  2. Testing framework: for this task, you can assume vitest testing framework is available in the project.

@claudiobusatto
claudiobusatto / minimal-react.js
Created November 27, 2022 19:51
Minimal React example
const React = (() => {
let hooks = [];
let idx = 0;
function useState(initValue) {
let state = hooks[idx] || initValue;
let _idx = idx;
let setState = (newValue) => {
hooks[_idx] = newValue;
};
@claudiobusatto
claudiobusatto / wait_for_http_200.sh
Created December 22, 2021 13:27 — forked from rgl/wait_for_http_200.sh
Wait for an HTTP endpoint to return 200 OK with Bash and curl
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9000)" != "200" ]]; do sleep 5; done'
# also check https://gist.github.com/rgl/c2ba64b7e2a5a04d1eb65983995dce76
@claudiobusatto
claudiobusatto / template_update_using_forloop.sql
Created September 15, 2021 12:20
Template of an update using a for loop in plpgsql
do $$
declare
data_values record;
begin
for data_values in (select * from table)
loop
update table
set column_value = (select column_value from another_table where id = data_values.id)
where id = data_values.id;
end loop;

Aligning images

left alignment

This is the code you need to align images to the left:

@claudiobusatto
claudiobusatto / count_dir.sh
Created February 22, 2020 19:55
Count files inside a directory
function count_dir {
ls -1 $1 | wc -l
}
@claudiobusatto
claudiobusatto / .zshrc
Created December 23, 2019 12:33
My ~/.zhrc configuration
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH="$HOME/bin:/usr/local/bin:$JAVA_HOME/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$PATH"
# Path to your oh-my-zsh installation.
export ZSH="/Users/cbusa/.oh-my-zsh"
export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# functions
@claudiobusatto
claudiobusatto / create-node.sh
Last active December 23, 2019 12:29
Function to scaffold node projects faster
# This gist is based on https://philna.sh/blog/2019/01/10/how-to-start-a-node-js-project/
# 1. Configure your npm
npm set init.author.name "Your name"
npm set init.author.email "[email protected]"
npm set init.author.url "https://your-url.com"
npm set init.license "MIT"
npm set init.version "1.0.0"
# 2. Include this function to your bash_profile, e.g. ~/.zshrc
function create-node {
@claudiobusatto
claudiobusatto / setup_airbnb_codestyle.sh
Last active December 12, 2019 17:13
Include Prettier, ESLint and Airbnb code style to a NodeJS project on Visual Studio Code
# This gist is based on https://blog.echobind.com/integrating-prettier-eslint-airbnb-style-guide-in-vscode-47f07b5d7d6a
# Download the ESLint and Prettier extensions for VSCode.
code --install-extension esbenp.prettier-vscode
code --install-extension dbaeumer.vscode-eslint
# Install the ESLint and Prettier libraries into our project. In your project’s root directory, you will want to run:
npm install -D eslint prettier
# Install the Airbnb config. If you’re using npm 5+, you can run this shortcut to install the
# config and all of its dependencies:
@claudiobusatto
claudiobusatto / runPgAdminDocker.sh
Created December 11, 2019 17:31
pgAdmin running on Docker
docker container run \
-e [email protected] \
-e PGADMIN_DEFAULT_PASSWORD=123456 \
-p 80:80 \
dpage/pgadmin4
# pgAdmin4 will be available on http://localhost:80