Skip to content

Instantly share code, notes, and snippets.

View kripod's full-sized avatar

Kristóf Poduszló kripod

View GitHub Profile
@diegohaz
diegohaz / ariakit-styles.md
Last active March 29, 2025 13:56
Ariakit Styles
@yannbertrand
yannbertrand / nr-auto-node-run.sh
Last active March 21, 2025 13:13
`nr` bash function to use `node --run` when possible
nr() {
node_version=$(node -v)
major=$(echo $node_version | cut -c 2-3)
if [[ $(($major)) -gt 21 ]]
then
echo "node $node_version, using node --run $@ ⚡\n"
node --run $@
else
echo "node $node_version, using npm run $@\n"
npm run $@
@wesbos
wesbos / Bluesky.tsx
Created November 5, 2024 17:05
Bluesky RSC
export async function BlueSkyPost() {
const url = new URL('https://bsky.app/profile/danabra.mov/post/3la62zxt4rs2j');
const details = url.pathname.split('/').filter(Boolean).reduce((acc, part, index, pathParts) => {
if (index % 2 === 0 && pathParts[index + 1]) {
acc[part] = pathParts[index + 1];
}
return acc;
}, {} as Record<'post' | 'profile' | string, string>);
const endpoint = new URL('https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread');
const params = new URLSearchParams();
@okikio
okikio / constrain-transform-stream-queues.md
Last active December 7, 2024 03:04
Queue's via TransformStreams

Using TransformStream in place of traditional queue implementations is an interesting approach that leverages the stream API's natural queuing and backpressure features. Below is a breakdown of how you might implement each queue type using TransformStream, adhering to the constraint of using no more than 2 TransformStreams per queue, and addressing any limitations that arise.

1. Simple Queue (FIFO Queue)

  • Implementation:
    • TransformStream 1: This stream simply passes data from the writable side to the readable side in FIFO order.
    • TransformStream 2: Not necessary in this case, as one TransformStream is sufficient to maintain the FIFO order.
const fifoQueue = new TransformStream(undefined, undefined, { highWaterMark: Infinity });
@ixahmedxi
ixahmedxi / eslint.config.js
Created May 15, 2024 17:24
ESLint v9 Next.js
import path from 'path';
import { fileURLToPath } from 'url';
import comments from '@eslint-community/eslint-plugin-eslint-comments/configs';
import { fixupConfigRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import jsdoc from 'eslint-plugin-jsdoc';
import * as regexpPlugin from 'eslint-plugin-regexp';
@remorses
remorses / renamer.ts
Last active May 6, 2024 21:32
Babel `BatchRenamer`, 100x faster babel `scope.rename()` when you have many identifier to rename
// original https://github.com/babel/babel/blob/9c77558234c87b9220604fbc1519089e2d6334e2/packages/babel-traverse/src/scope/lib/renamer.ts#L61
import splitExportDeclaration from '@babel/helper-split-export-declaration'
import type { Scope } from '@babel/traverse'
import { visitors } from '@babel/traverse'
import { traverseNode } from '@babel/traverse/lib/traverse-node'
import * as t from '@babel/types'
import { NodePath, Visitor } from '@babel/core'
import type { Identifier } from '@babel/types'
import Benchmark from "benchmark";
const datetimeValidationSuite = new Benchmark.Suite("datetime");
const DATA = "2020-01-01";
const MONTHS_31 = new Set([1, 3, 5, 7, 8, 10, 12]);
const MONTHS_30 = new Set([4, 6, 9, 11]);
const simpleDatetimeRegex = /^(\d{4})-(\d{2})-(\d{2})$/;
const datetimeRegexNoLeapYearValidation =

Multiple GitHub accounts (Work vs Personal)

This setup uses some tricks to ensure that the right email/name/ssh-key is used for the right repos without having to think about it ever again.

  • First generate two SSH keys, ~/.ssh/id_ed25519 and ~/.ssh/id_ed25519_work
  • Add one key to your personal account and the other to your work account

.ssh/config

@guest271314
guest271314 / javascript_engines_and_runtimes.md
Last active April 5, 2025 04:14
A list of JavaScript engines, runtimes, interpreters

V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++. It is used in Chrome and in Node.js, among others. It implements ECMAScript and WebAssembly, and runs on Windows 7 or later, macOS 10.12+, and Linux systems that use x64, IA-32, ARM, or MIPS processors. V8 can run standalone, or can be embedded into any C++ application.

SpiderMonkey is Mozilla’s JavaScript and WebAssembly Engine, used in Firefox, Servo and various other projects. It is written in C++, Rust and JavaScript. You can embed it into C++ and Rust projects, and it can be run as a stand-alone shell. It can also be [compiled](https://bytecodealliance.org/articles/making-javascript-run-fast-on

@mitchellh
mitchellh / merge_vs_rebase_vs_squash.md
Last active March 18, 2025 21:32
Merge vs. Rebase vs. Squash

I get asked pretty regularly what my opinion is on merge commits vs rebasing vs squashing. I've typed up this response so many times that I've decided to just put it in a gist so I can reference it whenever it comes up again.

I use merge, squash, rebase all situationally. I believe they all have their merits but their usage depends on the context. I think anyone who says any particular strategy is the right answer 100% of the time is wrong, but I think there is considerable acceptable leeway in when you use each. What follows is my personal and professional opinion: