-
-
Save tcodes0/fcd1fac083a9c7f792c70fb49a71177c to your computer and use it in GitHub Desktop.
| RTL relay testings | |
| https://github.com/facebook/relay/blob/master/packages/relay-test-utils/__tests__/RelayMockEnvironmentWithComponents-test.js | |
| https://github.com/entria/entria-fullstack/pull/109/files | |
| Very easy native splash screen on Xcode | |
| https://medium.com/@kelleyannerose/react-native-ios-splash-screen-in-xcode-bd53b84430ec | |
| Init rn app on specific rn version | |
| (rn cli 2.0.1+) | |
| react-native-cli init --version="[email protected]" my project | |
| // correct CRA usage | |
| yarn create react-app my-app | |
| // mongo regex example | |
| db.Event.find({ title: {$regex: new RegExp("tom", "i")} })[0] | |
| // rn network debug | |
| https://github.com/jhen0409/react-native-debugger/issues/382 | |
| ``` | |
| // add to index.js | |
| global.XMLHttpRequest = global.originalXMLHttpRequest || global.XMLHttpRequest; | |
| global.FormData = global.originalFormData || global.FormData; | |
| if (window.FETCH_SUPPORT) { | |
| window.FETCH_SUPPORT.blob = false; | |
| } else { | |
| global.Blob = global.originalBlob || global.Blob; | |
| global.FileReader = global.originalFileReader || global.FileReader; | |
| } | |
| ``` | |
| Renato Bohler's tmux config | |
| ``` | |
| set-option -g default-shell /bin/zsh | |
| set -g utf8 | |
| set-window-option -g utf8 on | |
| set -g status off | |
| set -g default-terminal "screen-256color" | |
| set -g prefix C-a | |
| unbind C-b | |
| set -sg escape-time 1 | |
| set-option -g base-index 1 | |
| setw -g pane-base-index 1 | |
| bind r source-file ~/.tmux.conf \; display "Reloaded!" | |
| bind | split-window -h | |
| bind - split-window -v | |
| ``` | |
| // calculate ssh key fingerprint | |
| - cat public key, remove leading strings, copy base64payload | |
| - echo -n $base64payload | base64 -D | md5 | |
| // replaceAtIndex helper | |
| export const replaceAtIndex = <Item = any>(array: Item[], index: number, item: Item): Item[] => { | |
| return [...array.slice(0, index), item, ...array.slice(index + 1)]; | |
| }; | |
| export const ONE_SECOND_IN_MILLISECONDS = 1000; | |
| export const ONE_MINUTE_IN_MILLISECONDS = 60 * ONE_SECOND_IN_MILLISECONDS; | |
| export const ONE_HOUR_IN_MILLISECONDS = 60 * ONE_MINUTE_IN_MILLISECONDS; | |
| export const ONE_DAY_IN_MILLISECONDS = 24 * ONE_HOUR_IN_MILLISECONDS; | |
| export const SEVEN_DAYS_IN_MILLISECONDS = 7 * ONE_DAY_IN_MILLISECONDS; | |
| json to typescript type conversion | |
| https://transform.tools/json-to-typescript | |
| awesome phone regex | |
| https://regex101.com/r/MNWXbW/3 | |
| convert salaries between year/hour/month | |
| new Array(130).fill(0).map((x, i) => (i+4) * 5000).map(year => ({ year, hour: (year/1920.1755589082431).toFixed(0), month: (year/12).toFixed(0) })) | |
| cool thoughts articles tweets ideas | |
| https://stopa.io | |
| github gif how to | |
|  | |
| kill branches that have no remotes | |
| ```bash | |
| git branch -vv | grep ': gone]'| grep -v "\*" | awk '{ print $1; }' | xargs -r git branch -D | |
| ``` | |
| twitter bot translation google translate npm library | |
| https://github.com/vitalets/google-translate-api | |
| how to grep git source code | |
| ``` | |
| git grep <regexp> $(git rev-list --all) | |
| ``` | |
| how to grep git commit msg | |
| ``` | |
| <your fav git log alias> --grep="foo" | |
| ``` | |
| git push a few commits to origin | |
| ``` | |
| git push origin 91143c3:fix-52-2 | |
| ``` | |
| where 91143c3 is the last commit you want to push, and fix-52-2 is the branch on origin to push to. | |
| this actually pushes all child commits of 91143c3 to origin because commits are chained together. | |
| so, if you'd like to push a range, push the head commit with this technique. | |
| when doing complex stuff, find the simples code that works and build from there |
Go
Installing private repos as packages
update ~/.gitconfig with
[url "ssh://[email protected]/"]
insteadOf = https://github.com/
run go env -w GOPRIVATE=github.com/eleanorhealth/* and add to shell init file export GOPRIVATE=github.com/eleanorhealth/*
run ssh-keyscan github.com > ~/.ssh/known_hosts
try to run go mod download "github.com/eleanorhealth/member-server@<latest commit on main>" and see if you get no errors, if so, run go get "github.com/eleanorhealth/member-server@<latest commit on main>" to add the package
notes
omitting the commit hash doesn't work
ssh-key add may be needed on mac, it will prompt you for password
code must be merged to main
coverage unit
go get golang.org/x/tools/cmd/cover
go test -race -coverprofile .coverage ./svc/server/application/application/...
go tool cover -html=.coverage/**
* Maybe captures the result of some operation that may fail.
* If there is an non null error, attempting to retrieve result will throw.
*/
export class Maybe<T> {
#result: T | null
#error: Error | null
// constructor(data: Data | null, error: Error | null) {
constructor() {
this.#result = null
this.#error = null
}
/**
* throws unless error() returns null.
*/
result(): T {
if (this.#error) {
throw this.#error
}
if (this.#result === null) {
throw new Error("null data")
}
return this.#result
}
/**
* if null, result() is safe to call
*/
error() {
return this.#error
}
/**
* error must be null for result to be read
*/
setResult(data: T) {
this.#result = data
}
/**
* blocks result from being read
*/
setError(message: string) {
this.#error = new Error(message)
}
}
AI
52.7k words on member-server codebase
244 non mock non test files
find . -type f -name *.go | grep -Ev test.go | grep -Ev mock
avg 314 words per file (handlers)
avg 215 word per file (codebase)
say 5k words for a massive conversation context with ai
have 59k words of context to use with ai
Cookie cliker