Skip to content

Instantly share code, notes, and snippets.

View philippetedajo's full-sized avatar
😝
Sky isn’t the limit

Philippe Tedajo philippetedajo

😝
Sky isn’t the limit
View GitHub Profile
@philippetedajo
philippetedajo / postgres-cheatsheet.md
Created June 7, 2021 09:07 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
echo '.env' >> .gitignore
git rm -r --cached .env
git add .gitignore
git commit -m 'untracking .env'
git push origin master
@philippetedajo
philippetedajo / alias
Created January 14, 2022 13:49 — forked from ieschalier/alias
git
[user]
email = [email protected]
name = Igor ESCHALIER
[alias]
co = checkout
br = branch
sts = status --short
last-log = log -5 --pretty --oneline
who = shortlog -sn
@philippetedajo
philippetedajo / eslint_prettier_airbnb.md
Last active January 22, 2022 15:11 — forked from bradtraversy/eslint_prettier_airbnb.md
ESLint, Prettier & Airbnb Setup

ESLint, Prettier & Airbnb Setup

1. Install ESLint & Prettier extensions for VSCode

Optional - Set format on save and any global prettier options

2. Install Packages

npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-config-node

Do not use forEach with async-await

TLDR: Use for...of instead of forEach in asynchronous code.

The problem

Array.prototype.forEach is not designed for asynchronous code. (It was not suitable for promises, and it is not suitable for async-await.)

For example, the following forEach loop might not do what it appears to do:

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@philippetedajo
philippetedajo / useRect.js
Created July 29, 2022 11:18 — forked from morajabi/useRect.js
useRect — getBoundingClientRect() React Hook with resize handler
import { useLayoutEffect, useCallback, useState } from 'react'
export const useRect = (ref) => {
const [rect, setRect] = useState(getRect(ref ? ref.current : null))
const handleResize = useCallback(() => {
if (!ref.current) {
return
}
@philippetedajo
philippetedajo / homebrew-install-older-version.md
Created February 1, 2023 16:03
Homebrew: Install an older version of a formula

Homebrew: Install an older version of a formula

kubernetes-cli (v1.10.3) taken as example

  1. Downgrade Homebrew to the commit which upgrades the formula to the specific version that we want
$ cd "$(brew --repo homebrew/core)"
$ git log Formula/kubernetes-cli.rb

...