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 function jsonAgg<T extends Record<string, AnyColumn>>(select: T) { | |
const chunks: SQL[] = []; | |
Object.entries(select).forEach(([key, column], index) => { | |
if (index > 0) chunks.push(sql`,`); | |
chunks.push(sql.raw(`'${key}',`), sql`${column}`); | |
}); | |
return sql<InferColumnsDataTypes<T>[]>` | |
coalesce( |
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
const fileSchema = z.union([ | |
z.object({ | |
type: z.literal('image'), | |
width: z.number().int(), | |
height: z.number().int(), | |
}), | |
z.object({ | |
type: z.literal('pdf'), | |
pages: z.number().int(), | |
}), |
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 { SchemaFormElements, SchemaFormProperties, SchemaFormType } from 'jtd'; | |
import { get, set } from 'lodash'; | |
import { Merge } from 'type-fest'; | |
const RE_TAG = /\{+\s*(.*?)\s*\}+/g; | |
const RE_THIS = /this.?/; | |
const RE_WITH = /#with\s+/; | |
const RE_EACH = /#each\s+/; | |
const RE_OPTIONAL = /#(if|unless)\s+/; |
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 Link from 'next/link'; | |
import { useRouter } from 'next/router'; | |
import { api } from '@chapterchat/sdk'; | |
import { useAuth } from 'lib/stores/auth_store'; | |
import { Logo } from 'svg'; | |
import { Button } from '../button'; | |
import { | |
AvatarIcon, | |
CaretDownIcon, |
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 { ChangeEvent, useState } from 'react'; | |
type InputEvent = ChangeEvent<HTMLInputElement | HTMLSelectElement>; | |
type BindValueType = (e: InputEvent) => void; | |
export type BindInputType<T> = ( | |
name: keyof T | |
) => { | |
name: typeof name; | |
value: T[typeof name]; |
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
function createSentenceArray(str) { | |
const arr = str.split(" "); | |
const newArr = []; | |
for (let index = 0; index < arr.length; index++) { | |
const word = arr[index]; | |
if (DO_YOUR_REGEX_THING) { | |
// if it is a mention push a span | |
newArr.push(<span>{word}</span>) |
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
<!--[if lte IE 8]> | |
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script> | |
<![endif]--> | |
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script> | |
<script> | |
hbspt.forms.create({ | |
portalId: "7229407", | |
formId: "3acc29ec-3985-4f68-afd3-4b1abdd130ec", | |
cssClass: 'bg-dark', |
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
setInterval(() => { | |
const btn = document.querySelector(".community-points-summary button.tw-button--success"); | |
btn && btn.click(); | |
}, 15000) |
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 { useState } from "preact/hooks"; | |
export function useInputHandler(defaultState) { | |
const [state, setState] = useState(defaultState); | |
return [ | |
state, | |
event => setState({ ...state, [event.target.name]: event.target.value }), | |
newState => setState({ ...state, ...newState }) | |
]; |
NewerOlder