Skip to content

Instantly share code, notes, and snippets.

@antlis
antlis / rofi-ayugram-keybindings
Last active September 12, 2026 20:39
rofi-ayugram-keybindings — AyuGram/Telegram shortcut cheatsheet that focuses the app (i3 criteria) and replays the key via xdotool. See https://antlis.is-a.dev/blog/rofi-cheatsheets
#!/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
@antlis
antlis / rofi-i3-cheatsheet
Last active September 12, 2026 20:39
rofi-i3-cheatsheet — live i3 keybinding cheatsheet that also RUNS the selected action (parsed from i3-msg -t get_config). See https://antlis.is-a.dev/blog/rofi-cheatsheets
#!/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).
#
@antlis
antlis / rofi-keybindings
Last active September 12, 2026 21:29
rofi-keybindings — picker that opens a keybinding cheatsheet (i3 / AyuGram). See https://antlis.is-a.dev/blog/rofi-cheatsheets
#!/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)"
@antlis
antlis / define-lazy-component.ts
Created April 16, 2026 20:19
Lightweight helper for lazy-loading components to improve performance metrics like LCP and INP.
export function defineLazyComponent(loader: () => Promise<any>) {
return defineAsyncComponent({
loader,
suspensible: false,
})
}
@antlis
antlis / use-abortable-fetch.ts
Last active August 6, 2026 03:28
Cancels previous in-flight requests when a new one is triggered. Ideal for search inputs and rapid UI interactions.
// 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 {
@antlis
antlis / use-debounced-ref.ts
Last active August 6, 2026 03:29
Reactive debounced ref for handling user input (search, filters) without excessive API calls.
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
@antlis
antlis / use-async-data-safe.ts
Created April 16, 2026 20:16
Safer wrapper around useAsyncData with sensible defaults to avoid duplicate requests and undefined state issues.
export function useAsyncDataSafe<T>(
key: string,
handler: () => Promise<T>
) {
return useAsyncData<T>(key, handler, {
server: true,
lazy: false,
default: () => null,
})
}
@antlis
antlis / use-api.ts
Last active April 16, 2026 20:16
A composable wrapper around Nuxt $fetch that centralizes API configuration, authentication headers, and error handling.
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,
@antlis
antlis / group-by.js
Created April 16, 2026 20:13
Groups array items by a computed key. Lightweight alternative to Lodash groupBy.
export function groupBy(arr, keyFn) {
return arr.reduce((acc, item) => {
const key = keyFn(item);
(acc[key] ||= []).push(item);
return acc;
}, {});
}
@antlis
antlis / retry.js
Last active April 16, 2026 20:12
Retries async operations with exponential backoff. Useful for flaky network requests or transient failures.
export async function retry(fn, {
retries = 3,
delay = 300,
factor = 2
} = {}) {
let attempt = 0;
while (true) {
try {
return await fn();