Skip to content

Instantly share code, notes, and snippets.

const FocusDemo = () => {
// with callback
const [inputRef, setInputFocus] = useFocus<HTMLInputElement>();
// on component mount
const ref = useAutoFocus<HTMLInputElement>();
return (
<>
<button onClick={setInputFocus} >
@moritzsalla
moritzsalla / test.yml
Created August 2, 2023 16:01
Github action - Unit test
name: Tests
on:
pull_request:
jobs:
Unit:
runs-on: ubuntu-latest
strategy:
@moritzsalla
moritzsalla / skip-build.sh
Created February 4, 2023 22:24
Skip Vercel build step
#!/bin/bash
echo "VERCEL_GIT_COMMIT_MESSAGE: $VERCEL_GIT_COMMIT_MESSAGE"
if [[ "$VERCEL_GIT_COMMIT_MESSAGE" != *"[skip build]"* ]] ; then
# Proceed with the build
exit 1;
else
# Don't proceed with the build
@moritzsalla
moritzsalla / hook-fallback.tsx
Last active January 7, 2023 20:35
Some react tricks
// fallback for a partially supported hook
// source https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/hooks/use-id.ts
import React from 'react'
import { useIsoMorphicEffect } from './use-iso-morphic-effect'
import { useServerHandoffComplete } from './use-server-handoff-complete'
import { env } from '../utils/env'
export let useId =
// Prefer React's `useId` if it's available.
@moritzsalla
moritzsalla / contour-shader.md
Last active May 25, 2022 20:37
Contour tracer shader
// contour isoline cartography shader
export const frag = `
  #extension GL_OES_standard_derivatives : enable
  #ifdef GL_ES
   precision highp float;
  #endif

  varying vec2 var_vertTexCoord;

Shell cheatsheet

Count all words in specific file type in sub directory

find . -name "*.md" -type f -exec cat {} + | wc -w
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.