# .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
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
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
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}`; |
NewerOlder