Skip to content

Instantly share code, notes, and snippets.

View setup.md

iterm/terminal setup M1 Rosetta

terminal

iterm

@todgru
todgru / joi.custom.md
Created Mar 18, 2021
always force a value for a field in a schema using Joi custom validator
View joi.custom.md

Joi Custom Validtion

Adds a custom validation function to execute arbitrary code

https://joi.dev/api/?v=17.4.0#anycustommethod-description

Set a null value for any data type regardless of whats given. I used this in a nested if/when statement to only trigger under certain conditions based on other key values.

Here's the gist:

@todgru
todgru / userChrome.css
Created Mar 5, 2021
remove firefox white flash dark mode
View userChrome.css
/*
about:config
toolkit.legacyUserProfileCustomizations.stylesheets: true
create chrome directory in default release path, found in about:profiles
/Users/$user/Library/Application Support/Firefox/Profiles/xxxxx.default-release/chrome
copy userChrome.css and userContent.css to
/Users/$user/Library/Application Support/Firefox/Profiles/xxxxx.default-release/chrome
*/
@-moz-document url(chrome://browser/content/browser.xhtml) {
@todgru
todgru / iterm2-control-r.md
Last active Feb 19, 2021
after upgrade to iterm2 3.4.4 `ctrl-r`/`control-r` no longer work
View iterm2-control-r.md

it looks like the iterm2 upgrade to 3.4.4 reset keybindings. Added the following to .zshrc brought back the history search.

bindkey -v
bindkey '^R' history-incremental-search-backward

information about a similiar issue: https://bbs.archlinux.org/viewtopic.php?id=52173

@todgru
todgru / parse_ini.sh
Created Feb 9, 2021 — forked from wyllie/parse_ini.sh
Parse aws credentials file in bash
View parse_ini.sh
#!/usr/bin/env bash
INI_FILE=~/.aws/credentials
while IFS=' = ' read key value
do
if [[ $key == \[*] ]]; then
section=$key
elif [[ $value ]] && [[ $section == '[default]' ]]; then
if [[ $key == 'aws_access_key_id' ]]; then
@todgru
todgru / postgres-docker-terminating.md
Last active Feb 5, 2021
docker postgres "terminating connection due to administrator command"
View postgres-docker-terminating.md

This error happened when I was running the latest Postgres Docker image 13.1 and trying to run a migration script that used pg_dump version 9.6.

UPDATE well, maybe the verion mismatch was the issue. the script had pg_dump wrapped in { pg_dump ...} >> dev/null. The shell (sh) the script ran in exited early and the migration "terminated".

terminating connection due to administrator command
View using-multiple-github-accounts-with-ssh-keys.md

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@todgru
todgru / README.md
Created Dec 19, 2020 — forked from joyrexus/README.md
collapsible markdown
View README.md

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@todgru
todgru / peer-review.md
Last active Dec 7, 2020
The idea of a "peer review" can be applied in just about any line of work. For me it's software.
View peer-review.md

Peer Review

One of the ways I've grown as programmer is by applying suggestions given to me in peer reviews. I've often learned more by feedback given in these reviews than any google or stackoverflow search could have taught.

Unless there is a misunderstanding of the intent of the code, most of the time, the suggestions should be taken to heart. The suggestions are made to help support future maintenance, make the code easier to understand, and almost always a general improvement to the final product. It is very, very rare for a suggestion to be made based purely on an arbitrary point of view made solely for the sake of commenting.

When suggestions are made for changes to my work, it provides me an opportunity to take a second look at my work and attempt to make the work better. Often times, these suggestions are usable in any future work I do. Now the reviewer doesn't need to continue to make the same suggestions with each review. This makes their job much easier - and mine to - because I no longer get

View git-merge-squash.md

merge, squash, all commits of the feature-branch into the current branch.

git merge --squash feature-branch
git commit