Skip to content

Instantly share code, notes, and snippets.

@psxcode
psxcode / xor.ts
Created March 21, 2024 10:20
XOR Typescript type
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never }
type XOR<T, U> = (T | U) extends object
? (Without<T, U> & U) | (Without<U, T> & T)
: T | U
// Example
type RenderProps = XOR<
{ children: (api: API) => ReactNode },
{ render: (api: API) => ReactNode }
@psxcode
psxcode / .gitattributes
Created August 16, 2021 20:28
Unity LFS attributes
* text=auto
# Unity files
*.asset linguist-generated -text -merge=unityamlmerge
*.mat linguist-generated -text -merge=unityamlmerge
*.meta linguist-generated -text -merge=unityamlmerge
*.prefab linguist-generated -text -merge=unityamlmerge
*.unity linguist-generated -text -merge=unityamlmerge
# Image formats
@psxcode
psxcode / remove-yarn-cache.ts
Created August 2, 2020 15:41
Auto hook to clear packages from yarn cache
import type { THook, THookProps } from '@auto/core'
import type { TReadonly } from 'tsfn'
const getYarnCacheDir = async () => {
const { default: execa } = await import('execa')
const { stdout: yarnCacheDir } = await execa('yarn', ['cache', 'dir'])
return yarnCacheDir
}
@psxcode
psxcode / config.yml
Last active August 16, 2021 20:26
Verdacio config
max_body_size: 100mb
storage: /opt/verdaccio/storage
auth:
htpasswd:
file: /opt/verdaccio/htpasswd
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@*/*':
@psxcode
psxcode / vscode-tooltip.css
Created October 20, 2019 00:22
change tooltip size in vscode
/* https://marketplace.visualstudio.com/items?itemName=be5invis.vscode-custom-css */
/* https://marketplace.visualstudio.com/items?itemName=lehni.vscode-fix-checksums */
/* sudo chown -R $(whoami) /Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron */
/* code ~/.vscode-custom.css */
.monaco-editor-hover-content {
max-width: 2000px !important;
max-height: 1000px !important;
}
if git apply --check --ignore-space-change --ignore-whitespace --directory node_modules/typescript/ typescript.patch 2> /dev/null; then
git apply --verbose --ignore-space-change --ignore-whitespace --directory node_modules/typescript/ typescript.patch
fi
@psxcode
psxcode / cloudserver.sh
Created June 4, 2019 19:41
Cloudserver use case snippets
[local]
aws_access_key_id = accessKey1
aws_secret_access_key = verySecretKey1
docker run --name srv -d -p 8000:8000 -e REMOTE_MANAGEMENT_DISABLE=1 -e S3BACKEND=mem zenko/cloudserver
aws --profile local --endpoint-url http://127.0.0.1:8000/ s3 ls
aws --profile local --endpoint-url http://127.0.0.1:8000/ s3 mb 123
@psxcode
psxcode / git.md
Last active January 30, 2019 13:54
git commands

Diff

  • git diff HEAD^^ HEAD main.c
  • git diff HEAD^^..HEAD -- main.c
  • git diff revision_1:file_1 revision_2:file_2

Diff Tool

  • git difftool --tool=meld HEAD~..HEAD

Show

  • git show
@psxcode
psxcode / .gitconfig
Last active June 1, 2020 14:08
Git config
[color]
ui = auto
[user]
name = psxcode
email = psxcode@gmail.com
[credential]
helper = osxkeychain
[alias]
st = status
co = checkout
@psxcode
psxcode / .babelrc
Last active February 11, 2019 08:42
js setup
{
"env": {
"production": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "8"
},