Skip to content

Instantly share code, notes, and snippets.

Avatar
⚠️
TypeError: Cannot read property 'status' of undefined.

Christian Petersen fnky

⚠️
TypeError: Cannot read property 'status' of undefined.
View GitHub Profile
@fnky
fnky / use-toggle.ts
Created May 13, 2022
Simple toggle hook using useReducer w/ types for reducer with optional action.
View use-toggle.ts
import React from "react";
type ReducerWithOptionalAction<S> = (prevState: S, action?: S) => S;
type ReducerStateWithOptionalAction<S> = React.ReducerState<ReducerWithOptionalAction<S>>;
type DispatchWithOptionalAction<S> = React.Dispatch<S> & React.DispatchWithoutAction;
type ReducerValueWithOptionalAction<S> = [
ReducerStateWithOptionalAction<S>,
React.DispatchWithOptionalAction<S>,
];
@fnky
fnky / login.tsx
Last active Jan 20, 2022
Remix Form validation with zod
View login.tsx
import { json, ActionFunction, useActionData, Form } from "remix";
import { z } from "zod";
// This type infer errors from a ZodType, as produced by `flatten()` of a parsed schema.
type inferSafeParseErrors<T extends z.ZodType<any, any, any>, U = string> = {
formErrors: U[];
fieldErrors: {
[P in keyof z.infer<T>]?: U[];
};
};
@fnky
fnky / Cargo.toml
Created Sep 22, 2021
Rule110 in Rust
View Cargo.toml
[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"
@fnky
fnky / BetterFixedLazyExample.jsx
Last active Nov 29, 2019
Lazy conditionals and refs
View BetterFixedLazyExample.jsx
function BetterFixedLazyExample({ lazyValue }) {
// Initialize with null value.
const myRef = useRef(null);
useLayoutEffect(() => {
console.log(myRef.current); // => HTMLDivElement DOM node
}, []);
// Make sure the ref setter is not blocked by conditionals.
return (
@fnky
fnky / history-with-outer.jsx
Last active Nov 27, 2019
History provider with useState / useRef
View history-with-outer.jsx
import React from 'react';
import { createBrowserHistory } from 'history';
export const historyContext = React.createContext(null);
const HistoryContextProvider = historyContext.Provider;
// This is initialized at the time the file/module is imported, and not on component mount.
const history = createBrowserHistory();
export function History(props) {
@fnky
fnky / fonts.md
Created Oct 18, 2019
Cheap-ish fonts
View fonts.md

Cheap-ish fonts

A list of cheap-ish fonts, that doesn't put a dent in my wallet.

@fnky
fnky / variable-fonts.md
Last active May 7, 2022
Awesome Variable Fonts
View variable-fonts.md

Awesome Variable Fonts

A list of open source and free* variable fonts.

* Some fonts may require a license to be used for commerical use.

Open Source

@fnky
fnky / serialization-tools.md
Created Oct 16, 2019
Binary serialization frameworks, libraries and tools
@fnky
fnky / stripe-keys-and-ids.tsv
Last active Jun 21, 2022
Stripe keys and IDs
View stripe-keys-and-ids.tsv
Prefix Description Notes
ac_ Platform Client ID Identifier for an auth code/client id.
acct_ Account ID Identifier for an Account object.
ba_ Bank Account ID Identifier for a Bank Account object.
card_ Card ID Identifier for a Card object.
cbtxn_ Customer Balance Transaction ID Identifier for a Customer Balance Transaction object.
ch_ Charge ID Identifier for a Charge object.
cn_ Credit Note ID Identifier for a Credit Note object.
cs_live_ Live Checkout Session ID Identifier for a checkout Session object in live mode.
cs_test_ Test Checkout Session ID Identifier for a checkout Session object in test mode.
View query-order.graphql
# Query order pattern from GitHub GraphQL API
# Can be used in conjunction with Relay pagination.
"""
Possible directions in which to order a list of items when provided an `orderBy` argument.
"""
enum OrderDirection {
"""
Specifies an ascending order for a given `orderBy` argument.
"""