A collection of functions in typescript that I use often in different projects.
extractRecordOptions(anyZodSchema) generates automatically a correct object { fields: "...", expand: "..." } which can be passed to the pocketbase sdk.
We can use the same schema to parse/validate and strongly type the response.
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
| <script lang="ts"> | |
| import { derived, readable, writable } from 'svelte/store' | |
| type States = 'view' | 'edit' | |
| const state = writable<States>('view') | |
| const _substate = derived(state, ($state) => { | |
| if ($state === 'edit') return writable<{ item?: number }>({}) | |
| return readable(null) | |
| }) |
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
| // Svelte flash animation for new elements | |
| // source: https://learn.svelte.dev/tutorial/svelte-options | |
| export default function flash(element) { | |
| requestAnimationFrame(() => { | |
| element.style.transition = 'none'; | |
| element.style.color = 'rgba(255,62,0,1)'; | |
| element.style.backgroundColor = 'rgba(255,62,0,0.2)'; | |
| setTimeout(() => { |
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
| use nix |
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
| v() { | |
| # runs nvim in a nix-shell with nodejs_20 | |
| # sets NPM_GLOBAL_DIR so no sudo is needed to install global npm packages | |
| NODE_STR="nodejs_20" | |
| NPM_GLOBAL_DIR="/home/$USER/.npm-global/$NODE_STR" | |
| mkdir -p $NPM_GLOBAL_DIR | |
| echo "running lvim $1" | |
| echo "within nix-shell -p $NODE_STR" | |
| PATH=$NPM_GLOBAL_DIR/bin:$PATH NPM_CONFIG_PREFIX=$NPM_GLOBAL_DIR nix-shell -p $NODE_STR --run "lvim $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
| use_flake './flake.nix' |
Bash script to convert all ChatGPT conversations from .json to .csv, for example to import into Notion as a database.
jq
- First export your personal data from ChatGPT (Account Settings > Data Controls > Export Data)
- Unzip the downloaded file