Skip to content

Instantly share code, notes, and snippets.

View csandman's full-sized avatar

Chris Sandvik csandman

View GitHub Profile
@baumandm
baumandm / Chakra-UI x React-datepicker.md
Last active March 4, 2023 20:56
Chakra-UI x React-datepicker

⚠️ I'd recommend using this fork by @igoro00 which has better theme support.


Tiny wrapper component for React-Datepicker to stylistically fit with Chakra-UI 1.x.

<DatePicker selectedDate={myDate} onChange={(d) => console.log(d)} />
@fixpunkt
fixpunkt / remove-empty-directories.js
Last active June 18, 2023 20:14
nodejs: remove empty directories recursively, async version of https://gist.github.com/jakub-g/5903dc7e4028133704a4
const fsPromises = require('fs').promises;
const path = require('path');
/**
* Recursively removes empty directories from the given directory.
*
* If the directory itself is empty, it is also removed.
*
* Code taken from: https://gist.github.com/jakub-g/5903dc7e4028133704a4
*
@fazlurr
fazlurr / ContentEditor.vue
Last active April 30, 2024 15:39
tiptap alignment And custom image handler
<template>
<!-- WYSIWYG Editor -->
<div class="editor mb-4">
<editor-menu-bar class="editor-bar" :editor="editor">
<div slot-scope="{ commands, isActive, focused, getMarkAttrs }">
<!-- Image -->
<label
class="btn btn-plain mb-0"
:class="{ 'is-loading': isUploading }"
v-tooltip="'Add Image'">
@mallendeo
mallendeo / syslinux.conf
Last active September 20, 2023 21:10
Unraid boot config
kernel /bzimage
append
isolcpus=2-7,10-15
pcie_acs_override=downstream,multifunction
pci-stub.ids=14e4:43a0
vfio-pci.ids=8086:a348,10de:10f8,10de:1ad8,1b73:1100,8086:24f3,14e4:43a0
pci=noaer
modprobe.blacklist=amdgpu,wl,bluetooth,b43
kvm.ignore_msrs=1
vfio_iommu_type1.allow_unsafe_interrupts=1
@jensmeder
jensmeder / Dockerfile
Last active March 23, 2024 21:13
Dockerfile for running x86 applications with Wine in Alpine Docker Containers
FROM i386/alpine:3.10.2
# Wine 32Bit for running EXE
RUN apk add --no-cache wine=3.0.4-r1 freetype=2.10.0-r0
# Configure Wine
RUN winecfg
# Install wget
RUN apk add --no-cache wget=1.20.3-r0
@jonahallibone
jonahallibone / ScrollToTop.js
Created May 28, 2019 16:41
Hook for scroll to top
import React, { useEffect, useRef } from "react";
import { withRouter } from 'react-router-dom';
function usePrevious(value) {
const ref = useRef();
useEffect(() => {
ref.current = value;
@gaearon
gaearon / uselayouteffect-ssr.md
Last active May 16, 2024 14:13
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
@russss
russss / deskew.py
Created September 10, 2018 12:05
Automatic scanned image rotation/deskew with OpenCV
import cv2
import numpy as np
def deskew(im, max_skew=10):
height, width = im.shape
# Create a grayscale image and denoise it
im_gs = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
im_gs = cv2.fastNlMeansDenoising(im_gs, h=3)
@LinusU
LinusU / generate.js
Last active September 22, 2023 19:44
Stripe TypeScript definition generation
const input = require('./spec3.json')
function titleCase(snake) {
return snake.replace(/(^|_)([a-z])/g, (s) => s.replace('_', '').toUpperCase())
}
function isPrimitive(schema) {
switch (schema.type) {
case 'boolean':
case 'number':
@hubgit
hubgit / SelectField.tsx
Last active December 29, 2023 03:41
Use react-select with Formik
import { FieldProps } from 'formik'
import React from 'react'
import Select, { Option, ReactSelectProps } from 'react-select'
export const SelectField: React.SFC<ReactSelectProps & FieldProps> = ({
options,
field,
form,
}) => (
<Select