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 / news.ycombinator.com.css
Last active Jan 13, 2023
Stylus Dark theme for Hacker News
View news.ycombinator.com.css
: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 Nov 3, 2022
Web/React Resources (Last updated Nov 3, 2022)
View react-web-resources.md
@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 Dec 18, 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 Dec 14, 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