Skip to content

Instantly share code, notes, and snippets.

View asyarb's full-sized avatar

Anthony Yarbrough asyarb

View GitHub Profile
@asyarb
asyarb / resize-img.ts
Created July 1, 2024 22:27
Client-side image resizing in TS.
export async function resizeImg(file: File, size = 256): Promise<File> {
const canvas = document.createElement("canvas")
const ctx = canvas.getContext("2d")
invariant(ctx, "Failed to convert image -- (ctx).")
canvas.width = size
canvas.height = size
const bitmap = await createImageBitmap(file)
const { width, height } = bitmap
:root {
--root-font-size: 16;
--root-line-height: 1.2;
font-size: var(--root-font-size);
line-height: var(--root-line-height);
}
.font-inter {
--cap-height: 2048;
--ascent: 2728;
@asyarb
asyarb / capsize.css
Last active May 12, 2022 00:40
Capsize implemented using CSS variables
:root {
--root-font-size: 16;
--root-line-height: 1.2;
font-size: var(--root-font-size);
line-height: var(--root-line-height);
}
.text {
--font-size: 24;
--line-height: 1.25;
@asyarb
asyarb / movies.json
Last active November 19, 2020 00:34
Movies
{
"movies": [
{
"coverImage": "https://images-na.ssl-images-amazon.com/images/I/71VZVXPhmKL._AC_SL1106_.jpg",
"title": "Iron Man 2",
"rating": 4.7,
"ticketPrice": 1200,
"description": "With the world now aware of his identity as Iron Man, Tony Stark must contend with both his declining health and a vengeful mad man with ties to his father's legacy."
},
{