Skip to content

Instantly share code, notes, and snippets.

@prescottprue
prescottprue / jest-to-vitest.sh
Last active November 27, 2024 02:14
Replace Jest With Vitest
#!/bin/bash
# Based off https://gist.github.com/wojtekmaj/6defa1f358daae28bd52b7b6dbeb7ab6 with a few fixes and
# additions/removals including no git interactions
join_by() {
local d=${1-} f=${2-}
if shift 2; then
printf %s "$f" "${@/#/$d}"
fi
@lambdaxyzt
lambdaxyzt / image.jsx
Last active April 8, 2025 21:37
Remix Image Component ( use cache 'cacashe library' , stream base , sharp library )
// resource route component
import React from "react";
import { PassThrough } from "node:stream"
import fs from "node:fs"
import {createReadableStreamFromReadable} from "@remix-run/node"
import { defaultQuality,widths,mainImageReadStream,generatedImageReadstream, isThereImage,BadImageResponse } from "../../util/image.server"
export const loader = async ({ request }) => {
const url = new URL(request.url);
const src = url.searchParams.get("src");
@wojtekmaj
wojtekmaj / jest-to-vitest.sh
Last active October 14, 2025 06:40
Automatically migrate Jest project to Vitest
#!/bin/bash
# Ensure we're working on the latest version of the main branch
git switch main
git fetch
git pull
# Create a new branch
git switch -c vitest
@alanbsmith
alanbsmith / styling-thoughts.md
Created October 19, 2022 23:14
Some brief styling thoughts

On CSS-in-JS

Overview

This is not an argument for or against any particular library or solution for styling UI. Instead I’d like to bring a bit of context and nuance to the conversation in a way that doesn’t add to the ongoing flame war.

First-Gen CSS-in-JS Wins

There are some things Emotion and Styled Components do very well, especially considering the styling landscape when they was created.

@jacob-ebey
jacob-ebey / image.ts
Last active September 18, 2024 19:12
Remix Image Component
import { createHash } from "crypto";
import fs from "fs";
import fsp from "fs/promises";
import path from "path";
import https from "https";
import { PassThrough } from "stream";
import type { Readable } from "stream";
import type { LoaderFunction } from "remix";
import sharp from "sharp";
import type { Request as NodeRequest } from "@remix-run/node";
@sarahbethfederman
sarahbethfederman / flexgap.tsx
Created May 6, 2021 06:43
Flex gap polyfill
import { useState, useLayoutEffect, useEffect } from 'react';
// remove this once safari support ships
function checkFlexGap() {
// create flex container with row-gap set
const flex = document.createElement('div');
flex.style.display = 'flex';
flex.style.flexDirection = 'column';
flex.style.rowGap = '1px';
@scottjehl
scottjehl / whichones.js
Created August 21, 2020 15:40
which elements are wider than the viewport?
var list = [];
document.querySelectorAll("body *")
.forEach(function(elem){
if(elem.getBoundingClientRect().width > document.body.getBoundingClientRect().width){
list.push(elem.outerHTML.split('>')[0] + '>');
}
});
confirm( "these elements are wider than the viewport:\n\n " + list.join("\n") )
@carolstran
carolstran / testing-pyramid-resources.md
Last active June 27, 2022 09:12
Resources from my wtfuzz video on the testing pyramid 🔼
@daimagine
daimagine / download-blob.js
Created April 15, 2019 06:12
Download file from API blob result
// 'download-blob.js', inspired by this gist:
// 'dreamyguy/downloadFile.js' https://gist.github.com/dreamyguy/6b4ab77d2f118adb8a63c4a03fba349d
// I added some handler to make it works in Chrome, Safari, and Firefox on iOS
const downloadBlob = (
result,
defaultFilename = 'content.dat',
mime = 'application/octet-stream'
) => {
if (window && result && result.data) {
@swyxio
swyxio / 7rules-for-intemediate-developers-3.md
Last active October 28, 2021 19:29
Clone Open Source Apps

3. Clone Open Source Apps

You already know you should be making projects to learn things and potentially add to your portfolio. You've read your Malcolm Gladwell, you know that you need 10,000 hours of deliberate practice. Given you're just starting out, I have a slightly contentious suggestion for you: DON'T make anything new.

Your decision-making is a scarce resource. You start every day with a full tank, and as you make decisions through the day you gradually run low. We all know how good our late-late-night decisions are. Making a new app involves a thousand micro decisions - from what the app does, to how it should look, and everything in between. Decide now: Do you want to practice making technical decisions or product decisions?

Ok so you're coding. You know what involves making zero product decisions? Cloning things. Resist the urge to make your special snowflake (for now). Oh but then who would use yet another Hacker News clone? I've got news for you: No one was gonna use your thing anyway. You