Skip to content

Instantly share code, notes, and snippets.

View fnky's full-sized avatar
⚠️
TypeError: Cannot read property 'status' of undefined.

Christian Petersen fnky

⚠️
TypeError: Cannot read property 'status' of undefined.
View GitHub Profile
@fnky
fnky / news.ycombinator.com.css
Last active January 13, 2023 23:32
Stylus Dark theme for Hacker News
:root {
--color-scale-black: hsl(0, 0%, 3.5%);
--color-scale-white: #ffffff;
--color-scale-gray-1: hsl(0, 0%, 8.5%);
--color-scale-gray-2: hsl(0, 0%, 11.0%);
--color-scale-gray-3: hsl(0, 0%, 13.6%);
--color-scale-gray-4: hsl(0, 0%, 15.8%);
--color-scale-gray-5: hsl(0, 0%, 17.9%);
--color-scale-gray-6: hsl(0, 0%, 20.5%);
--color-scale-gray-7: hsl(0, 0%, 24.3%);
@fnky
fnky / react-web-resources.md
Last active November 24, 2023 15:04
Web/React Resources (Last updated Nov 3, 2022)
@fnky
fnky / use-toggle.ts
Created May 13, 2022 12:29
Simple toggle hook using useReducer w/ types for reducer with optional action.
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 December 15, 2023 19:56
Remix Form validation with zod
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 September 22, 2021 08:29
Rule110 in Rust
[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"
@fnky
fnky / BetterFixedLazyExample.jsx
Last active November 29, 2019 13:45
Lazy conditionals and refs
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 November 27, 2019 10:56
History provider with useState / useRef
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 October 18, 2019 11:15
Cheap-ish fonts

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 September 2, 2024 22:50
Awesome Variable Fonts

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 October 16, 2019 22:23
Binary serialization frameworks, libraries and tools