- smallstep -> installation
- lego -> installation
in the following command replace
<domain>by your domain name (example:acme.com)<email>by your email (example:tech@acme.com)
| import { dequal } from 'dequal'; | |
| export function whyDidYouUpdate<T extends object>(name: string, previous: T, current: T) { | |
| const changes = new Map<string, { from: unknown; to: unknown }>(); | |
| const keys = Reflect.ownKeys({ ...previous, ...current }); | |
| for (const key of keys) { | |
| if (previous[key] !== current[key]) { | |
| changes.set(key, { | |
| from: previous[key], |
in the following command replace
<domain> by your domain name (example: acme.com)<email> by your email (example: tech@acme.com)| /** @param {number} [ms] */ | |
| export default function formatTime(ms = 0) { | |
| const d = new Date(ms) | |
| const hour = `${d.getUTCHours()}`.padStart(2, '00').replace('00', '') | |
| const min = `${d.getUTCMinutes()}`.padStart(2, '00') | |
| const second = `${d.getUTCSeconds()}`.padStart(2, '00') | |
| return [hour, min, second].filter(Boolean).join(':') | |
| } |
| import { useCallback, useEffect, useRef, useState } from 'react' | |
| /** @param {() => unknown} callback */ | |
| export default function useAnimationFrame(callback, initial = false) { | |
| const handlerRef = useRef(callback) | |
| const [started, setStarted] = useState(initial) | |
| useEffect(() => { | |
| handlerRef.current = callback | |
| }, [callback]) |
| #! /bin/bash | |
| if ! command -v kubectl &> /dev/null | |
| then | |
| echo "kubectl is not installed" | |
| exit 1 | |
| fi | |
| function usage () { | |
| echo "Usage: restart-pods -n <namespace> -s <service>" |
| import { useEffect, useState } from 'react' | |
| import { createOperationDescriptor, getRequest } from 'relay-runtime' | |
| import { environment } from './relay' | |
| import { GraphQLTaggedNode, Variables, Snapshot } from 'react-relay' | |
| function getSnapshot(query: GraphQLTaggedNode, variables: Variables): Snapshot { | |
| const request = getRequest(query) | |
| const { fragment } = createOperationDescriptor(request, variables) | |
| return environment.lookup(fragment) |
| import { useEffect, useRef } from 'react' | |
| type Callback = () => unknown | |
| export default function useTimeout(handler: Callback, ms = 1000) { | |
| const handlerRef = useRef(handler) | |
| const handleRef = useRef<NodeJS.Timeout>(null) | |
| useEffect(() => { | |
| handleRef.current = setTimeout(() => handlerRef.current?.(), ms) |
| /** @param {string} iban */ | |
| function isValidIban(iban) { | |
| const correspond = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | |
| const withoutSpace = iban.replace(/ /g, '').toUpperCase() | |
| const rearranged = withoutSpace.slice(4) + withoutSpace.slice(0, 4) | |
| const computedRemainder = rearranged | |
| .replace(/[a-z]/gi, m => correspond.indexOf(m) + 10) | |
| .match(/([0-9]{9})([0-9]{7})([0-9]{7})([0-9]{5})/) | |
| .slice(1) | |
| .reduce((acc, k) => String(parseInt(acc + k, 10) % 97), '') |
| import { useRef, useState, useEffect } from 'react' | |
| import ResizeObserver from 'resize-observer-polyfill' | |
| interface Bounds { | |
| left: number | |
| top: number | |
| width: number | |
| height: number | |
| } |