Skip to content

Instantly share code, notes, and snippets.

@jckw
jckw / cloudSettings
Last active February 28, 2022 19:08
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-07-12T19:49:30.768Z","extensionVersion":"v3.4.3"}
@jckw
jckw / Stack.tsx
Created October 25, 2021 20:39
Stitches Stack component for Figma-style positioning.
import { styled } from "@stitches/react"
const Stack = styled("div", {
display: "flex",
variants: {
dir: {
col: { flexDirection: "column" },
row: { flexDirection: "row" },
},
@jckw
jckw / Card.tsx
Last active November 3, 2021 21:31
Super simple Tinder-style swipeable Card component with Reanimated 2
import { Text } from "react-native"
import React from "react"
import { PanGestureHandler } from "react-native-gesture-handler"
import Animated, {
runOnJS,
useAnimatedGestureHandler,
useAnimatedStyle,
useSharedValue,
withSpring,
} from "react-native-reanimated"
@jckw
jckw / testflight.yml
Created November 9, 2021 21:05
A simple Github Actions workflow for releasing TestFlight builds with Fastlane.
name: Release to TestFlight internally and bump build number
on: [workflow_dispatch]
jobs:
internal_testflight:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
# We use a deploy key (i.e. public key) in the Houston-App/certificates repo to
@jckw
jckw / roam_to_obsidian.py
Created November 14, 2021 10:56
Rename Roam daily notes to Obsidian format.
import os
import dateutil
import glob
# Assumes you're working in a directory with only the Daily Notes
# Files that aren't parseable dates will fail
files = map(lambda n: n[2:-2], glob.glob("./*.md"))
for f in files:
d = dateutil.parser.parse(f)
@jckw
jckw / uuid_rename.py
Created December 22, 2021 14:51
Rename simple files to UUID names. Useful for renaming folders of photos for slideshows.
import pathlib
import os
import uuid
if __name__ == "main":
files = os.listdir()
for f in files:
suffix = pathlib.Path(f).suffix
@jckw
jckw / $addr.tsx
Created December 26, 2021 21:08
Display NFTs for a Tezos wallet with Remix.
import { json, LoaderFunction, useCatch, useLoaderData } from 'remix'
type BCDBalance = {
contract: string
token_id: number
name: string
description: string
artifact_uri: string
display_uri: string
thumbnail_uri: string
@jckw
jckw / PrimitiveMasonry.tsx
Created December 30, 2021 17:49
Naive approach to Masonry layout in React with CSS Grid
import React from 'react'
interface Props {
colCount: number
gap: number
children: React.ReactNode[]
}
const PrimitiveMasonry: React.FC<Props> = ({
colCount = 2,
@jckw
jckw / utils.ts
Created January 12, 2022 22:43
GraphQL Utils for using Urql SSR with Next.js and getServerSideProps
import {
GetServerSideProps,
GetServerSidePropsContext,
GetServerSidePropsResult,
NextPage,
} from 'next'
import { initUrqlClient, SSRData, withUrqlClient } from 'next-urql'
import {
cacheExchange,
Client,
@jckw
jckw / variants.ts
Last active February 23, 2023 18:42
Stitches-inspired variant helper function for Tailwind. Complete with TypeScript autocomplete for variant fields.
type Classnames = string[] | string
type VariantConfig = {
[variant: string]: { [option: string]: Classnames }
}
type Config<V extends VariantConfig> = {
base: Classnames
variants: V
compoundVariants?: ({