This file contains 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
import React from 'react' | |
import { Cress } from './path/to/Cress.js'; | |
// looks like dead-code right? | |
new Cress('.my-selector', { | |
css() { | |
return ` | |
this { | |
font-family: cursive; | |
} |
This file contains 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
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key | |
# Don't add passphrase | |
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub | |
cat jwtRS256.key | |
cat jwtRS256.key.pub |
This file contains 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
module.exports = { | |
... | |
overrides: [ | |
{ | |
files: ['src/**/*.js'], | |
rules: { | |
'some-rule': 'error', | |
'some-other-rule': 'error' | |
} | |
}, |
This file contains 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
// Either monad using discriminated unions | |
export type Either<L, R> = | |
| { type: "left"; value: L } | |
| { type: "right"; value: R }; | |
export function Left<L, R>(a: L): Either<L, R> { | |
return { | |
type: "left", | |
value: a | |
}; |
This file contains 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
#!/usr/bin/env bash | |
# enable when debugging | |
# set -o errexit | |
# set -o errtrace | |
# set -o xtrace | |
# set -o nounset | |
# set -o pipefail | |
plsno () { |
This file contains 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
// never is dropped from sum types | |
let x: string | never // string | |
let y: Exclude<'a' | 'b', 'b'> // y has the type 'a' | |
/* | |
* Explanation: | |
* Given that Exclude is defined as: type Exclude<T, U> = T extends U ? never : T | |
* Exclude<'a' | 'b', 'b'> checks if 'a' extends 'b'. | |
* It doesn't and hence 'a' is returned | |
* Type system then checks if 'b' extends 'b'. |
This file contains 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
/** | |
* @description | |
* Returns a transaction object which is composed of operations. | |
* The transaction resolves only when all operations it is made of succeed. | |
* If any operation fails, it reverts ALL operations and rejects the transaction. | |
* If any of the reverts also fail, then it rejects the transaction as well | |
* with an error that can help the developer manually make data consistent. | |
* | |
* @param {function} transaction - A function that builds operations and calls run on them | |
* |
This file contains 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
export type Either<L,R> = Left<L> | Right<R> | |
export class Left<L> { | |
constructor(private readonly value: L) {} | |
public getValue() { | |
return this.value | |
} | |
} | |
export class Right<R> { |
This file contains 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
class Foo t where | |
returnLast :: Int -> t | |
class Integral i => IntsBro i where | |
toInt :: i -> Int | |
instance IntsBro Integer where | |
-- toInt :: Integer -> Int | |
toInt i = fromIntegral i :: Int |
This file contains 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
// navigate to https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#Intersection_observer_concepts_and_usage | |
// open console and run the code below | |
const target = document.getElementById('How_intersection_is_calculated') | |
const observer = new IntersectionObserver(entries => console.log(entries[0], entries[0].isIntersecting), {root: null, threshold: 0.9}) | |
observer.observe(target) |