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
{ | |
exampleField: { | |
_type: 'richDate', | |
local: '2024-03-12T00:00:00+01:00', | |
offset: 60, | |
utc: '2024-03-11T23:00:00.000Z', | |
timezone: 'Europe/Oslo' | |
} | |
} |
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
$indicator = new \Symfony\Component\Console\Helper\ProgressIndicator($this->output); | |
$indicator->start('Starting the process...'); | |
foreach (range(0, 10) as $i) { | |
usleep(5 * 10000); | |
$indicator->advance(); | |
} | |
$indicator->finish('Process complete!'); |
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, { useEffect, useState, useRef, useCallback } from 'react'; | |
type Props = { | |
text: string | |
maxSize?: number | |
minSize?: number | |
maxHeight?: number | |
fontStepSize?: number | |
containerWidthMargin?: number | |
initialHidden?: boolean |
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 libheif from 'libheif-js'; | |
import { ImageData, Canvas, createCanvas } from 'canvas' | |
type Props = { | |
buffer: Buffer; | |
quality: number; | |
}; | |
const processSingleImage = (image: any): Promise<any> => { | |
return new Promise((resolve, reject) => { |
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 { 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 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 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 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 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 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(); |
NewerOlder