Skip to content

Instantly share code, notes, and snippets.

Avatar
🤟

Kevin Hovsäter hovsater

🤟
View GitHub Profile
View fails.ts
function EditText<T extends React.ElementType = "h1">({
as: Component = "h1",
children
}: EditTextProps<T>) {
Component
return <Component>{children}</Component>;
}
View works.ts
function EditText<T extends React.ElementType = "h1">({
as,
children
}: EditTextProps<T>) {
const Component = as || "h1";
return <Component>{children}</Component>;
}
View Kata.elm
module Kata exposing (fromNb2Str)
fromNb2Str n modsys =
let
gcd : Int -> Int -> Int
gcd a b =
if b == 0 then
a
View invert-tree.elm
fold (\v l r -> Node v r l) Empty tree
View gist:c23e1ad81d2a8b93abfa2e2a4820576c
~/code/dte (master) $ trap -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
6) SIGABRT 7) SIGEMT 8) SIGFPE 9) SIGKILL 10) SIGBUS
11) SIGSEGV 12) SIGSYS 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGURG 17) SIGSTOP 18) SIGTSTP 19) SIGCONT 20) SIGCHLD
21) SIGTTIN 22) SIGTTOU 23) SIGIO 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGINFO 30) SIGUSR1
31) SIGUSR2
View Dockerfile
FROM ubuntu:focal
ENV LANG en_US.UTF-8
RUN apt-get update && apt-get install -y locales && locale-gen en_US.UTF-8
View ex1.ts
type TokenType = 'ASSIGN' | 'NAME' | 'NUM' | 'OP';
type TokenLiteral = string;
type Token = [TokenType, TokenLiteral];
type Tokens = ReadonlyArray<Token>;
function assert<T extends Tokens>(actual: T, expected: T): void | never {
const stringActual = JSON.stringify(actual);
const stringExpected = JSON.stringify(expected);
if (stringActual !== stringExpected) {
View dte-replace
#!/usr/bin/env bash
set -e
if [[ $# -lt 2 ]]; then
>&2 echo "usage: dte-replace <search> <replacement> [rg_args]"
exit 1
fi
rg "$1" --files-with-matches ${@:3} | xargs -n1 dte -c 'replace -c '$1' '$2'; save; quit'
View m.bash
#!/usr/bin/env bash
function m() {
local marks="$HOME/.config/m/marks"
local version="0.0.1"
# Create "$HOME/.config/m/marks" if it doesn't exist.
if ! [[ -f "$marks" ]]; then
mkdir -p "$(dirname "$marks")"
touch "$marks"
View gist:f41755c8a8aee22ae1b4381ead2fe914
{
"background": "#101010",
"colors": {
"activityBar.activeBorder": "#101010",
"activityBar.background": "#101010",
"activityBar.border": "#191919",
"activityBar.foreground": "#b4b4b4",
"activityBar.inactiveForeground": "#444444",
"activityBarBadge.background": "#626262",
"badge.background": "#262626",