Skip to content

Instantly share code, notes, and snippets.

View BobToninho's full-sized avatar
🐘

Roberto Tonino BobToninho

🐘
View GitHub Profile
@BobToninho
BobToninho / dont-initialize-until-accessed.ts
Created July 23, 2023 14:52
Make an object that will pretend to be a pool but not initialize itself until someone tries to access a property on it
// Shamelessly stolen from https://github.com/vercel/storage/blob/6104c9fa9731b9610d9e4e8b68652b27d355b0ba/packages/postgres/src/index.ts
import type { QueryResult, QueryResultRow } from '@neondatabase/serverless';
import { type VercelPool, createPool } from './create-pool';
import type { Primitive } from './sql-template';
export * from './create-client';
export * from './create-pool';
export * from './types';
export { postgresConnectionString } from './postgres-connection-string';
function navigate-projects {
cd $(fd . ~/dev/ --maxdepth 1 --type d | fzf --cycle)
}
alias np="navigate-projects"
function gch {
BRANCH=$(git branch | fzf --cycle | tr -d '[:space:]')
if [[ $BRANCH =~ '^\*' ]] then
echo "current branch selected, nothing to do"
return 0
fi
if [[ -n $BRANCH ]] then
git checkout $BRANCH
# huge inspiration from https://scriptingosx.com/2019/07/moving-to-zsh-06-customizing-the-zsh-prompt/
export PROMPT='%(?.%F{green}√.%F{red}?%?)%f %B%F{blue}%1~%f%b %(!.#.❯) '
@BobToninho
BobToninho / shortcuts.txt
Last active January 10, 2025 09:47
Collection of useful shortcuts for any type of app
Re-open the last closed tab.
CTRL + SHIFT + t
COMMAND + SHIFT + t
App: Chrome, Edge, Brave, Firefox
Switch to another window of the same program on MacOS
COMMAND + `
App: /
def --env np [] {
cd (fd . ~/dev/ --maxdepth 1 --type d | fzf --cycle)
}
def gch [] {
let branch = git branch | fzf --cycle | tr -d '[:space:]'
git checkout $branch
}
# From https://stackoverflow.com/a/17029936
# git branch -d keeps us on the safe side
git fetch -p ; git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
@BobToninho
BobToninho / init.vim
Created January 10, 2025 09:46
Make neovim behave like vim (taken from rwxrob's video)
set runtimepath^=~/.vim runtimepath+=~/.vim/after
"runtimepath+=/opt/homebrew/share/vim/vim91/pack/
let &packpath = &runtimepath
source ~/.vimrc
@BobToninho
BobToninho / git_blame_current_line.vim
Last active February 4, 2025 14:52
git_blame_current_line.vim
nnoremap <leader>b <Cmd>echo system("git blame " .. expand("%") .. " -L " .. line(".") .. "," .. line("."))<CR>