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 | |
| # | |
| # Mirrored as a public gist (embedded in the write-up) — if you edit this file, | |
| # update the gist too: https://gist.github.com/antlis/3301eae14f771e31340cd4781c948682 | |
| # Article: https://antlis.is-a.dev/blog/rofi-cheatsheets | |
| # | |
| # AyuGram / Telegram Desktop keybindings cheatsheet | |
| # Reads from AyuGramDesktop or TelegramDesktop shortcuts JSON. | |
| # Also includes hardcoded Telegram shortcuts not in the JSON. | |
| # On Enter: focus the AyuGram window and replay the shortcut with xdotool |
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 | |
| # | |
| # Mirrored as a public gist (embedded in the write-up) — if you edit this file, | |
| # update the gist too: https://gist.github.com/antlis/25aaf19b306045f21e0a4afff22cdf81 | |
| # Article: https://antlis.is-a.dev/blog/rofi-cheatsheets | |
| # | |
| # rofi-i3-cheatsheet — fullscreen i3 keybinding cheatsheet that ALSO acts: | |
| # selecting an entry performs its binding (exec commands run in a detached | |
| # shell; i3 commands are dispatched via i3-msg). | |
| # |
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 | |
| # Universal keybindings cheatsheet launcher | |
| # Select which keybindings to view, then browse & optionally execute them. | |
| # | |
| # Mirrored as a public gist (embedded in the write-up) — if you edit this file, | |
| # update the gist too: https://gist.github.com/antlis/d3d5e46e52cee4ac7c23e2ad0bc89725 | |
| # Article: https://antlis.is-a.dev/blog/rofi-cheatsheets | |
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
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
| export function defineLazyComponent(loader: () => Promise<any>) { | |
| return defineAsyncComponent({ | |
| loader, | |
| suspensible: false, | |
| }) | |
| } |
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
| // From gist | |
| export function useAbortableFetch() { | |
| let controller: AbortController | null = null | |
| return async function fetchWithAbort<T>(url: string, opts: any = {}) { | |
| if (controller) controller.abort() | |
| controller = new AbortController() | |
| try { |
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
| export function useDebouncedRef<T>(value: T, delay = 300) { | |
| const state = ref(value) | |
| const debounced = ref(value) | |
| let timer: any | |
| watch(state, (val) => { | |
| clearTimeout(timer) | |
| timer = setTimeout(() => { | |
| debounced.value = val |
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
| export function useAsyncDataSafe<T>( | |
| key: string, | |
| handler: () => Promise<T> | |
| ) { | |
| return useAsyncData<T>(key, handler, { | |
| server: true, | |
| lazy: false, | |
| default: () => 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
| export function useApi() { | |
| const config = useRuntimeConfig() | |
| const token = useCookie('token') | |
| return async function apiFetch<T>(url: string, opts: any = {}): Promise<T> { | |
| try { | |
| return await $fetch<T>(url, { | |
| baseURL: config.public.apiBase, | |
| headers: { | |
| Authorization: token.value ? `Bearer ${token.value}` : undefined, |
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
| export function groupBy(arr, keyFn) { | |
| return arr.reduce((acc, item) => { | |
| const key = keyFn(item); | |
| (acc[key] ||= []).push(item); | |
| return acc; | |
| }, {}); | |
| } |
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
| export async function retry(fn, { | |
| retries = 3, | |
| delay = 300, | |
| factor = 2 | |
| } = {}) { | |
| let attempt = 0; | |
| while (true) { | |
| try { | |
| return await fn(); |
NewerOlder