# .zshrc
port-to-pid() {
lsof -i:$1 -Fp | sed 's/^p//' | head -n 1
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const titleizeWord = (str) => `${str[0].toUpperCase()}${str.slice(1)}`; | |
| const kebabToTitle = (str) => str.split("-").map(titleizeWord).join(" "); | |
| const toBreadcrumbs = (pathname, { rootName = "Home", nameTransform = s=>s } = {}) => | |
| pathname | |
| .split("/") | |
| .filter(Boolean) | |
| .reduce( | |
| (acc, curr, idx, arr) => { | |
| acc.path += `/${curr}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "context" | |
| "encoding/json" | |
| "fmt" | |
| "io/ioutil" | |
| "log" | |
| "math/rand" | |
| "os" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| id, | |
| jsonb_path_query(json_field::jsonb, '$.arrayfield[*] ? (@.fieldid == $fieldid)', '{"fieldid": "field-id-value-to-find"}')->>'fieldvalue' as field_value | |
| FROM table | |
| WHERE json_field::jsonb->'arrayfield' @> '[{"fieldid": "field-id-value-to-find"}]'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const midnightInterval = (fn: ()=>void) => { | |
| const midnight = new Date(); | |
| midnight.setHours( 24 ); | |
| midnight.setMinutes( 0 ); | |
| midnight.setSeconds( 0 ); | |
| midnight.setMilliseconds( 0 ); | |
| const msUntilMidnight = ( midnight.getTime() - new Date().getTime() ) / 1000; | |
| setTimeout(() => { | |
| fn() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| cd "$(dirname "$0")" | |
| find internal pkg -type d -print0 | | |
| while IFS= read -r -d '' path; do | |
| rm -f $path/mock_*.go || exit 1 | |
| rm -f $path/mocks.go || exit 1 | |
| mockery --dir $path --inpackage --name '(.*)' --quiet || exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| athena-bearer() { | |
| curl -H "Authorization: Basic $(echo -n "${ATHENA_CLIENT_ID}:${ATHENA_SECRET}" | base64)" -H 'Content-Type: application/x-www-form-urlencoded' -d "grant_type=client_credentials&scope=athena/service/Athenanet.MDP.*" "${ATHENA_BASE_URL}/oauth2/v1/token" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dountil() { | |
| s=${SLEEP:-1} | |
| until eval $*; do echo "failed.. retrying in $s sec" && sleep $s; done | |
| } |
sudo apt-get update && sudo apt-get upgradesudo apt install curl lsb-releasecurl -L https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-archive-keyring.gpg >/dev/nullpackage main
import (
"bytes"
"errors"
"fmt"
"io"
"log"OlderNewer