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 { type SanityDocument, type Reference } from 'sanity' | |
import { type UploadBody, type SanityImageAssetDocument } from '@sanity/client' | |
import { getCliClient } from 'sanity/cli' | |
const client = getCliClient() | |
interface Tag extends SanityDocument { | |
_type: 'media.tag' | |
name: { | |
_type: 'slug' |
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 getIt from 'get-it' | |
import base from 'get-it/lib/middleware/base' | |
import jsonRequest from 'get-it/lib/middleware/jsonRequest' | |
import jsonResponse from 'get-it/lib/middleware/jsonResponse' | |
import promise from 'get-it/lib/middleware/promise' | |
import headers from 'get-it/lib/middleware/headers' | |
import httpErrors from 'get-it/lib/middleware/httpErrors' | |
const API_VERSION = 'v2021-10-04' | |
const PROJECT_ID = 'xxxxxxxx' |
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 { CSS } from '@stitches/react' | |
import { theme } from './stitches.config' | |
function createScaleVariant<Scale extends string & keyof typeof theme>( | |
property: string, | |
scale: Scale, | |
): Record<keyof typeof theme[Scale], CSS> { | |
return Object.keys(theme.space).reduce( | |
(reduced, value) => ({ | |
...reduced, |
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 React from 'react' | |
import { | |
ImageConfig, | |
imageConfigDefault, | |
LoaderValue, | |
VALID_LOADERS, | |
} from 'next/dist/server/image-config' | |
if (typeof window === 'undefined') { |
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
// Sadly a full dynamic import is not compatible | |
// with webpack's `import()`. | |
import { useState } from 'react' | |
const useLazyModule = path => { | |
const [ module, setModule ] = useState() | |
;(async () => { | |
const module = await import(path) |
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
class Calculator { | |
constructor (value = 0) { | |
this.value = value | |
} | |
add (value = 0) { | |
this.value += value | |
return this | |
} |
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
const fluid = (properties, [ minVw, maxVw ], [ minVal, maxVal ]) => properties | |
.map(property => ` | |
${property}: ${minVal}; | |
@media (min-width: ${minVw}) { | |
${property}: calc(${minVal} + ${parseFloat(maxVal) - parseFloat(minVal)} * (100vw - ${minVw}) / ${parseFloat(maxVw) - parseFloat(minVw)}); | |
} | |
@media (min-width: ${maxVw}) { | |
${property}: ${maxVal}; |
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
/* sql-tag | |
mysql2 | |
minigrate */ | |
// from redux | |
function compose(...funcs) { | |
if (funcs.length === 0) { | |
return arg => arg | |
} |
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
<?php | |
abstract class IterableUtils | |
{ | |
public static function reduce(Iterable $collection, Callable $accumulator, $result = null) | |
{ | |
foreach ($collection as $item) { | |
$result = $accumulator($result, $item); | |
} |
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 React from 'react' | |
import { render } from 'react-dom' | |
import Foo from './components/foo' | |
const components = { | |
foo: Foo | |
} | |
Object.keys(components) | |
.map(name => { |
NewerOlder