Skip to content

Instantly share code, notes, and snippets.

View jasikpark's full-sized avatar
🏳️‍🌈
happy pride month

Caleb Jasik jasikpark

🏳️‍🌈
happy pride month
View GitHub Profile
@jasikpark
jasikpark / prefetch.ts
Created January 17, 2024 17:57
`usePrefetchQuery` with types
import { useQueryClient, type DefaultError, type FetchQueryOptions, type QueryKey } from '@tanstack/react-query';
// Type specified by `ensureQueryData` definition.
// Pulled from <https://tanstack.com/query/latest/docs/react/guides/prefetching>
export function usePrefetchQuery<
TQueryFnData,
TError = DefaultError,
TData = TQueryFnData,
TQueryKey extends QueryKey = QueryKey,
>(options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>, { enabled = false }: { enabled?: boolean } = {}) {
@jasikpark
jasikpark / are-we-formatting-yet.md
Created December 8, 2023 17:36
WIP list of all possible formatters w/ support for different languages
  • Rust
    • rustfmt
  • Go
    • gofmt
  • Javascript/Typescript
    • prettier
    • biome
  • Markdown
    • prettier
  • Python
@jasikpark
jasikpark / flake.nix
Created July 29, 2023 20:45
use an old hugo version via nix flakes
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
old-hugo-nixpkgs.url = "github:NixOS/nixpkgs/4fe31ab170bbbdd089b05b268b681542886eb642";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, old-hugo-nixpkgs, flake-utils, }:
flake-utils.lib.eachDefaultSystem
(system:
let
@jasikpark
jasikpark / Tab.tsx
Created April 25, 2023 18:53
Example of a polymorphic ariakit Tab component that can be a button or link
import { Tab as AriakitTab, type TabProps } from 'ariakit/tab';
import cn from 'classnames';
import { useLayoutEffect, useRef } from 'react';
import { useRect } from '@hooks/useRect';
import { useAnimatedTabs } from '../context/useAnimatedTabs';
import styles from './Tab.module.css';
/**
* A tab that goes at the top of a tab panel, which a user clicks on to change the UI underneath.
* This is a button by default, but can also be a react-router Link, if the `to` and `as` props are provided.
@jasikpark
jasikpark / getBgHero.ts
Created December 14, 2022 19:31
Tool to generate a responsive `background-image: url("bg-hero.jpg");` for https://defined.net homepage
import { getPicture } from "@astrojs/image";
type BgHeroCSS = {
/** perfect for use w/ define:vars to inject */
cssProperty: string;
/** the source of the regular image */
imageSrc: string;
/** the sourceset used in the image-set */
imageSet: string;
/** the set useful for preloading
@jasikpark
jasikpark / posts%slash%[slug].astro
Created March 24, 2023 18:35
Imagined example of an SSR endpoint that returns the markdown sent in the request rendered in an Astro page shell as html
---
import { Markdown } from 'astro-remote';
import MainLayout from "@layouts/MainLayout.astro";
const markdown = Astro.request.headers.get('markdown');
---
<html>
<MainLayout>
<h1>My ODB post page</h1
<!-- Disallow inline `style` attributes, but allow HTML comments -->
<Markdown content={markdown} sanitize={{ dropAttributes: { "style": ["*"] }, allowComments: true }} />
@jasikpark
jasikpark / bleck
Last active January 26, 2023 18:04
openapi: 3.1.0
servers:
- url: https://api.defined.net
description: Default server
info:
description: |
# Introduction
This API is documented in **OpenAPI format** and describes methods that can be invoked when using an api key from <https://admin.defined.net/settings/api-keys>
Each endpoint is versioned individually, under a `/vXX` endpoint, ex `/v1/hosts` would become `/v2/hosts` with a breaking change, while `/v1/host-and-enrollment-code` would remain at `/v1`
@jasikpark
jasikpark / _getAllPublishablePosts.ts
Created October 31, 2022 17:37
Helper function at `src/pages/blog/_getAllPublishablePosts.ts`
import { assert } from "assert-ts";
import type { MarkdownInstance, MDXInstance } from "astro";
import type { MarkdownFrontmatter } from "@data/posts/MarkdownFrontmatter";
export type MarkdownOrMDXInstance =
| MarkdownInstance<MarkdownFrontmatter>
| MDXInstance<MarkdownFrontmatter>;
type PartialMarkdownOrMDXInstance =
| MarkdownInstance<Partial<MarkdownFrontmatter>>
@jasikpark
jasikpark / [...slug].astro
Created October 31, 2022 16:57
Showing an attempt at a type-safe MD + MDX glob and sort for a blog
---
import BlogIndex from "@layouts/BlogIndex.astro";
import BlogPost from "@layouts/BlogPost.astro";
import { assert } from "assert-ts";
import type { MarkdownInstance, MDXInstance, Page, PaginateFunction } from "astro";
import type { AstroComponentFactory } from "astro/dist/runtime/server";
import BlogMeta from "./meta.json";
import type { MarkdownFrontmatter } from "@data/posts/MarkdownFrontmatter";
type MarkdownOrMDXInstance =
@jasikpark
jasikpark / vtech-video-painter-bending.md
Created May 3, 2021 05:19
Looking for resources about circuit bending the Vtech Video Painter, there's not a lot of specific information.

Vtech Video Painter Bending research....

Direct mention of Vtech Video Painter info

Not directly related, but possibly helpful