This file contains hidden or 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 { useEffect, useRef } from 'react'; | |
export const useDebounce = (callback: Function, delay: number) => { | |
const timeoutRef = useRef<null|NodeJS.Timeout>(null); | |
useEffect(() => { | |
return () => { | |
if (timeoutRef.current) { | |
clearTimeout(timeoutRef.current); | |
} | |
}; | |
}, []); |
This file contains hidden or 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
defineField({ | |
name: 'email', | |
title: 'Email', | |
type: 'string', | |
readOnly: ({document}) => document?.origin === 'Checkin', | |
description: 'Can only be changed in Checkin if the origin is "Checkin".', | |
validation: Rule => Rule.required().email().custom(async (email: any, context: any) => { | |
const response = await client.fetch(`*[_type == "user" && email == $email && !(_id in [$draftId, $id])]`, {email, draftId: context.document._id, id: context.document._id.replace('drafts.', '')}); | |
if (response?.length > 0) { | |
return 'Email already in use'; |
This file contains hidden or 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
You might need to format the USB-stick with Mac Extended (Journaled) before starting this process. | |
This guide is primarily based on Apple's own guide (https://support.apple.com/en-us/101578), but it solves other issues which is not adressed by Apple. | |
1. Download Mist: https://github.com/ninxsoft/Mist | |
Go the the release-page and download the latest "dmg"-file. | |
https://github.com/ninxsoft/Mist/releases | |
2. Extract the app-file and place it in your Applications-folder | |
3. Open the app-file (you might need to right click it and click "Open"), then click "Open" again to proceed. |
This file contains hidden or 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
ffmpeg -y -nostdin -i a.aiff -ar 44100 -write_id3v2 1 -c:v copy b.aiff |
This file contains hidden or 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 class ShallowRouter { | |
static push(url: string): void { | |
window.history.pushState({ ...window.history.state, as: url, url }, '', url); | |
} | |
static replace(url: string): void { | |
window.history.replaceState({ ...window.history.state, as: url, url }, '', url); | |
} | |
} |
This file contains hidden or 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
/* eslint-disable react-hooks/exhaustive-deps */ | |
import { useEffect, useRef, DependencyList } from 'react'; | |
export const useEffectNonInit = (effect: Function, deps: DependencyList = []) => { | |
const isInitial = useRef<boolean>(true); | |
useEffect(() => { | |
if (isInitial.current) { | |
isInitial.current = false; | |
return; | |
} | |
effect(); |
This file contains hidden or 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 | |
echo "File type count:" | |
fileExtensions=( aiff mp3 wav m4a flac alac ) | |
totalFileCount=$(find . -name "*.aiff" -o -name "*.mp3" -o -name "*.wav" -o -name "*.m4a" -o -name "*.flac" -o -name "*.alac" | wc -l) | |
for fileExtension in "${fileExtensions[@]}" | |
do | |
fileCount=$(find . -name "*.${fileExtension}" | wc -l) |
This file contains hidden or 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
// Ensure you've installed gdrive first: https://github.com/glotlabs/gdrive | |
import { spawnSync } from 'child_process'; | |
const delimiter = ';;;'; | |
let files = []; | |
function getRawFiles(parent) { | |
const args = ['files', 'list', `--field-separator=${delimiter}`]; | |
if (parent) { | |
args.push(`--parent=${parent}`); |
This file contains hidden or 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
// These functions let's you sum columns based on their text formatting. | |
// The only flaw is that there's no text formatting change event, so you have to update the value of a field to trigger recalculation. | |
// styleRangeString (string) - The range where the text formatting should be evaluated. Example: A10:A20 | |
// sumRangeString (string) - The range where the numerical values will be summed. Should correspond with styleRangeString unless you only specify column. Example: B10:B20 | |
// attribute (string) - The text formatting attribute for conditional check during sum. | |
// Note: styleRangeString and sumRangeString must be passed as a STRING, meaning it has to be wrapped in quotes ("A10:A20"). | |
// Example: |
This file contains hidden or 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 fs from 'fs'; | |
export default class DiskCache { | |
static basePath = './.cache'; | |
static prettyPrintJson = false; | |
#filePath; | |
#cacheName; | |
#data = {}; | |
constructor(cacheName) { |