Skip to content

Instantly share code, notes, and snippets.

View csandman's full-sized avatar

Chris Sandvik csandman

View GitHub Profile
@csandman
csandman / Typesense Search.md
Created February 10, 2026 02:34
Typesense Search.md

Search

In Typesense, a search consists of a query against one or more text fields and a list of filters against numerical or facet fields. You can also sort and facet your results.

let searchParameters = {
@csandman
csandman / convert-address-components.js
Last active November 22, 2025 20:50
Convert the address components from a google places api request to a readable format
// ---------------------------------------------------------------------- //
// https://developers.google.com/maps/documentation/geocoding/intro#Types //
// ---------------------------------------------------------------------- //
// returns:
// {
// address_1
// address_2
// city
@csandman
csandman / makemkvcon-usage.txt
Created February 18, 2020 01:25
Documentation for makemkvcon
makemkvcon [options] Command Parameters
General options:
--messages=file
Output all messages to file. Following special file names are recognized:
-stdout - stdout
-stderr - stderr
-null - disable output
Default is stdout
@csandman
csandman / react-scripts-env-priorities.md
Last active December 6, 2024 15:09
The priorities of different .env files used in different React scripts

What other .env files can be used?

Note: this feature is available with react-scripts@1.0.0 and higher.

  • .env: Default.
  • .env.local: Local overrides. This file is loaded for all environments except test.
  • .env.development, .env.test, .env.production: Environment-specific settings.
  • .env.development.local, .env.test.local, .env.production.local: Local overrides of environment-specific settings.

Files on the left have more priority than files on the right:

@csandman
csandman / itunes.js
Last active October 29, 2024 00:07
Grab the response from the iTunes API for a book search and get the hi-res cover url in the process
import { URLSearchParams } from "url";
/**
* Check whether a URL string is in a proper format
*
* @param {string} str A URL string to check for the correct structure
* @returns
*/
const isUrl = (str) => {
if (typeof str !== "string") {
@csandman
csandman / seat-map.tsx
Last active July 29, 2024 20:33
A wrapper for the seats.io `SeatsioSeatingChart` component which prevents stale value references in the callback functions, and attaches the SeatingChart object to a forwarded ref
import { forwardRef, useCallback, useRef } from 'react';
import { SeatsioSeatingChart } from '@seatsio/seatsio-react';
import type {
BookableObject,
Category,
ChartRendererCallbacks,
ChartRendererConfigOptions,
EventManager,
HoldToken,
Region,
import { transform } from "@svgr/core";
import { readdir, readFile, writeFile, mkdir } from "fs/promises";
import path from "path";
import { rimraf } from "rimraf";
import prettier from "prettier";
const defaultProps = `/** These can be modified to change the default props for all icons */
const defaultProps: IconProps = {
stroke: "currentColor",
strokeLinecap: "round",
@csandman
csandman / debounce-swr.js
Last active November 17, 2023 09:12
Debounce useSwr
// originally from: https://github.com/vercel/swr/issues/110#issuecomment-552637429
import useSWR from 'swr';
import useDebounce from 'hooks/use-debounce';
const App = () => {
const [search, setSearch] = useState('');
const debouncedSearch = useDebounce(search, 1000);
const { data: res, isValidating } = useSWR(
() => debouncedSearch ? `/api/suggestion?value=${debouncedSearch}` : null,
Api.fetcher,
@csandman
csandman / README.md
Last active October 11, 2023 10:23
Chakra UI React Select

Chakra React Select

UPDATE: I finally made an NPM package for this component! It is made with TypeScript, and now has a fully customizable styling system. It is also far ahead of this wrapper at this point. Check it out here if you'd like: https://github.com/csandman/chakra-react-select

In order to use this component, you can implement it and use it like you would normally use react-select. It should accept all of the props that the original takes, however customizing the theme or the components could break this implementation. There are also a few extra things you can do with this wrapper that pull from the chakra library.

  • You can pass the size prop with either sm, md, or lg. These will reflect the sizes available on the Chakra <Input /> component (with the exception of xs because it's too small to work).
  • In your options objects, you can add the key isFixed to emulate the exa
@csandman
csandman / path.ts
Created July 20, 2023 04:06
The `Path` TypeScript utility function used in react-hook-form to generate a type for every possible object dot path
/* eslint-disable @typescript-eslint/no-explicit-any */
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
/**
* Checks whether T1 can be exactly (mutually) assigned to T2
* @typeParam T1 - type to check
* @typeParam T2 - type to check against
* ```
* IsEqual<string, string> = true
* IsEqual<'foo', 'foo'> = true