Hello everyone! In today's post, we'll explore the use()
hook introduced with React v19. This innovation allows frontend developers to easily use async functions without needing boilerplate code or external libraries (like React Query).
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
// executeAsync is golang like function that returns [result,err] pair. | |
export async function executeAsync<T>(fn: () => Promise<T>): Promise<[T | null, any]> { | |
try { | |
const result = await fn(); | |
return [result, null]; | |
} catch (error) { | |
return [null, error]; | |
} | |
} |
You are an expert TypeScript/Tailwindcss/Next.js v15 (app directory) developer focused on writing clean, maintainable code. Prioritize these qualities:
- Minimal - Absolute minimum code needed
- Self-documenting - Code explains itself through:
- Precise naming (verbs for functions, nouns for variables)
- Single-responsibility components
- Obvious data flow
- Add short comments when necessary
- Type-Exact - Strict TypeScript types with zero
any
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 telethon import TelegramClient, events | |
import re | |
import os | |
from datetime import datetime | |
from colorama import init, Fore, Style | |
from solders.pubkey import Pubkey | |
import base58 | |
# Initialize colorama for cross-platform colored output | |
init() |
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
/* | |
"dependencies": { | |
"@solana/web3.js": "^1.95.4", | |
"bip39": "^3.1.0", | |
"bs58": "^6.0.0" | |
} | |
*/ | |
const bs58 = require("bs58"); | |
const { Keypair } = require("@solana/web3.js"); |
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
/* | |
// manifest.json | |
{ | |
"manifest_version": 3, | |
"name": "GitHub Gist Displayer for Twitter", | |
"version": "1.0", | |
"description": "Displays GitHub Gist content directly on Twitter posts", | |
"permissions": [ | |
"activeTab", | |
"https://api.github.com/*", |
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
# docker run --rm --init \ | |
# --name bytebase \ | |
# --publish 8080:8080 --pull always \ | |
# --volume ~/.bytebase/data:/var/opt/bytebase \ | |
# bytebase/bytebase:2.20.0 | |
version: '3.8' | |
services: | |
bytebase: |
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
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--flannel-backend=none --disable-network-policy --cluster-cidr=10.87.0.0/16" sh - | |
export K3S_URL=https://10.19.180.103:6443 | |
export K3S_TOKEN= | |
curl -sfL https://get.k3s.io | K3S_URL=https://serverip:6443 =mytoken sh - | |
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
# Usage | |
# Start: docker compose up | |
# With helpers: docker compose -f docker-compose.yml -f ./dev/docker-compose.dev.yml up | |
# Stop: docker compose down | |
# Destroy: docker compose -f docker-compose.yml -f ./dev/docker-compose.dev.yml down -v --remove-orphans | |
name: supabase | |
version: "3.8" | |
services: |
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
# SHORT: one line below: | |
# CONTENT=$(cat plantuml.dot | python -c "import sys; import base64; import zlib; print(base64.urlsafe_b64encode(zlib.compress(sys.stdin.read().encode('utf-8'), 9)).decode('ascii'))") curl -X POST https://kroki.io/excalidraw/svg --data-binary '@app.dot' -o app.svg | |
# create file | |
cat <<EOF > plantuml.dot | |
skinparam ranksep 20 | |
skinparam dpi 125 | |
skinparam packageTitleAlignment left | |
rectangle "Main" { |
NewerOlder