Skip to content

Instantly share code, notes, and snippets.

View karfau's full-sized avatar
🎯
Focusing

Christian Bewernitz karfau

🎯
Focusing
  • bettermarks GmbH
  • Saxony / Germany
  • 23:47 (UTC +01:00)
View GitHub Profile
@karfau
karfau / CachedPromise.ts
Created November 6, 2023 04:48
An (rxjs) observable cached promise
import {
BehaviorSubject,
filter,
type Observable,
type Subscription,
tap,
} from 'rxjs';
const noop => () => {};
@karfau
karfau / EntityDecl.expanded
Created February 13, 2022 00:12
XML1.1 DOCTYPE and ENTITIES expanded
/*
https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-S
[3] S ::= (#x20 | #x9 | #xD | #xA)+
https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-Name
[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
[5] Name ::= NameStartChar (NameChar)*
https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EntityValue
@karfau
karfau / checks-trap-or-verbose.sh
Last active January 24, 2022 07:29
Bash status checks with option to switch between "print every line" and "only print last failed"
#!/usr/bin/env bash
## these comments explain what happens in the next line(s)
# set options explained, source https://wiki.bash-hackers.org/commands/builtin/set
# -e errexit
# When set, the shell exits when a simple command in a command list exits non-zero (FALSE).
# This is not done in situations, where the exit code is already checked (if, while, until, ||, &&)
# -E errtrace
# ERR-traps are inherited by by shell functions, command substitutions, and commands executed in a subshell environment.
# -T functrace
# DEBUG- and RETURN-traps are inherited by subsequent environments, like -E for ERR trap.
@karfau
karfau / machine.js
Last active May 28, 2021 06:26
Generated by XState Viz: https://xstate.js.org/viz
const formField = Machine({
id: 'formField',
initial: 'clean',
context: {
initialValue: '',
value: '',
feedback: undefined,
pending: false,
@karfau
karfau / machine.js
Created February 2, 2021 20:09
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@karfau
karfau / functional.spec.ts
Last active December 11, 2020 09:43
some cypress example
describe("Basic flow control in Cypress", () => {
before(() => {
cy.window().then(window => {
window.document.write(`
<ul>
<li>
<a>1a</a>
<a>1b</a>
</li>
<li>
@karfau
karfau / nvm-install
Last active August 15, 2024 11:10
A script that can be sourced in shell scripts to enable nvm support
# shellcheck shell=sh
# https://gist.github.com/karfau/dcf98c6eefc2f2132c160f5c14d2112f
# v2024.8.15
# needs to be sourced as part of your script
# 1. tries to configure nvm and run `nvm install`
# 2. checks if the node version is correct based on ./.nvmrc
# if both doesn't work, exits with code 1 and some helpful messages
# Sometimes we prefer `nvm use` over `nvm install`
@karfau
karfau / Unsupported.md
Last active November 26, 2020 10:23
Unsupported browser user agents
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions