Skip to content

Instantly share code, notes, and snippets.

@karlhorky
karlhorky / css-is-complex.md
Last active December 25, 2023 19:14
CSS is Complex. We can do better.

CSS is Complex. We can do better.

Posted on https://twitter.com/karlhorky/status/1082622697325166592

Ok, thread time.

CSS is unnecessarily complex. And we can do better.

There have been side conversations here and there, but I want to consolidate the information and opinions here. This will be a running thread, and I'll add to it as new things crop up.

@karlhorky
karlhorky / .eslintrc.cjs
Created November 3, 2023 09:14
Avoid await within arrays passed to Promise.all() https://twitter.com/alvarlagerlof/status/1720182566135779582
// https://twitter.com/karlhorky/status/1720368118193651903
/** @type {import('@typescript-eslint/utils').TSESLint.Linter.Config} */
const config = {
'no-restricted-syntax': [
'warn',
{
selector:
'CallExpression[callee .object.name=Promise][callee .property.name=all] > ArrayExpression > AwaitExpression',
message: 'Avoid await within array passed to Promise.all() to avoid waterfalls',
@karlhorky
karlhorky / pr.md
Last active November 2, 2023 13:44 — forked from piscisaureus/pr.md
Fetch all GitHub pull requests to local tracking branches

NOTE

You may not need local branches for all pull requests in a repo.

To fetch only the ref of a single pull request that you need, use this:

git fetch origin pull/7324/head:pr-7324
git checkout pr-7324
# ...
@karlhorky
karlhorky / set-methods.js
Created August 25, 2023 16:39
Set Methods demo
const hosts = new Set(["Wes", "Scott", "Snickers"]);
const team = new Set(["Wes", "Scott", "Kaitlin", "Ben"]);
const fans = new Set(["Paige", "Nick", 1]);
// Difference between two sets
console.log(team.difference(hosts)); // Set { 'Kaitlin', 'Ben' }
// Overlap between two sets
console.log(team.intersection(hosts)); // Set { 'Wes', 'Scott' }
@karlhorky
karlhorky / .gitconfig
Last active July 18, 2023 01:28 — forked from gnarf/..git-pr.md
Fetch and delete refs to GitHub pull request branches
[alias]
fetch-pr = "!f() { git fetch origin refs/pull/$1/head:pr/$1; } ; f"
delete-prs = "!git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done"
const CH_BRACE_L = 0x7b as const;
const CH_BRACE_R = 0x7d as const;
const CH_SQUARE_L = 0x5b as const;
const CH_SQUARE_R = 0x5d as const;
const CH_QUOTE_D = 0x22 as const;
const CH_ESCAPE = 0x5c as const;
const CH_COMMA = 0x2c as const;
const CH_COLON = 0x3a as const;
const CH_DOT = 0x2e as const;
const CH_MINUS = 0x2d as const;
@karlhorky
karlhorky / .bash_profile
Last active May 5, 2023 14:10 — forked from SherryQueen/.bash_profile
git-bash
alias ...=../..
alias ....=../../..
alias .....=../../../..
alias ......=../../../../..
alias 1='cd -'
alias 2='cd -2'
alias 3='cd -3'
alias 4='cd -4'
alias 5='cd -5'
alias 6='cd -6'
@karlhorky
karlhorky / signature.scpt
Last active April 28, 2023 17:16
Add HTML Signature to Outlook 2016 on macOS without Attachment Bug
#!/usr/bin/osascript
-- To fix error with Outlook 2016 HTML signature images showing up as attachments
-- Ref: http://mydesignpad.com/how-to-create-an-attractive-html-email-signature-for-microsoft-outlook-2016-for-mac/#comment-36065
-- To use, add your signature name (under `name`) and signature (under `content`) and paste and run this code in Script Editor
tell application id "com.microsoft.Outlook"
make new signature with properties {name:"Google Signature", content:"<table><tr><td><img src='https://www.google.de/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png' width='120' height='44'></td></tr></table>"}
end tell
@karlhorky
karlhorky / alpine-linux-deploy.log
Created April 6, 2023 07:51
Alpine Linux deploy logs: corepack prepare pnpm@latest --activate
2023-04-03T07:53:27.8474256Z Requested labels: ubuntu-latest
2023-04-03T07:53:27.8474294Z Job defined at: upleveled/next-js-example-winter-2023-vienna-austria/.github/workflows/test-playwright-and-deploy-to-fly-io.yml@refs/heads/main
2023-04-03T07:53:27.8474316Z Waiting for a runner to pick up this job...
2023-04-03T07:53:28.1009892Z Job is waiting for a hosted runner to come online.
2023-04-03T07:53:30.6303409Z Job is about to start running on the hosted runner: GitHub Actions 2 (hosted)
2023-04-03T07:53:32.8886204Z Current runner version: '2.303.0'
2023-04-03T07:53:32.8913724Z ##[group]Operating System
2023-04-03T07:53:32.8914198Z Ubuntu
2023-04-03T07:53:32.8914499Z 22.04.2
2023-04-03T07:53:32.8914804Z LTS
@karlhorky
karlhorky / _app.js
Created November 3, 2022 14:34 — forked from claus/_app.js
Restore scroll position after navigating via browser back/forward buttons in Next.js
import useScrollRestoration from "utils/hooks/useScrollRestoration";
const App = ({ Component, pageProps, router }) => {
useScrollRestoration(router);
return <Component {...pageProps} />;
};
export default App;