Skip to content

Instantly share code, notes, and snippets.

View davidglezz's full-sized avatar
😃
Happy

David Gonzalez davidglezz

😃
Happy
View GitHub Profile
@mmazzarolo
mmazzarolo / transform-barrel-file-imports.ts
Created November 10, 2024 19:37
Codemod to kill barrel file references
/**
* This script/codemod transforms imports from barrel files into direct imports.
* It's designed to work with jscodeshift to modify TypeScript/JavaScript files.
*
* Features:
* - Handles multiple barrel files
* - Transforms both value and type imports
* - Maintains correct relative paths
* - Handles re-exports within barrel files
*
@conartist6
conartist6 / index.js
Created May 11, 2024 15:23
StreamIterable
export const getStreamIterator = (obj) => {
return obj[Symbol.for('@@streamIterator')]?.() || obj[Symbol.iterator]?.();
};
export class SyncGenerator {
constructor(embeddedGenerator) {
if (!embeddedGenerator.next) throw new Error();
this.generator = embeddedGenerator;
@OrionReed
OrionReed / dom3d.js
Last active April 19, 2025 12:06
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@gquittet
gquittet / 0-url-json-compress-client-node.js
Last active October 1, 2023 22:30
JSON compression for URL
import zlib from 'node:zlib';
import example from './example.json' assert { type: "json" };
const text = JSON.stringify(example);
const compressed = zlib.gzipSync(text).toString('base64').replace(/\//g, '_').replace(/\+/g, '-').replace(/=/g, '');
// H4sIAAAAAAAAE-3KsQ2AIBCG0V3-GhPu1ObmsJJQkGBhb2fcXRZggy955Suv7q7Y9qTenkshz74u2YfDLMyHU1_i8Xg8Ho_H4_F4PB6Px-PxeDwejzd99Qd5g3u1cRcAAA
@palashmon
palashmon / Prettify.ts
Created May 13, 2023 16:11
A super useful type helper in TypeScript by Matt Pocock from Twitter
/**
* A TypeScript type alias called `Prettify`.
* It takes a type as its argument and returns a new type that has the same properties as the original type,
* but the properties are not intersected. This means that the new type is easier to read and understand.
*/
type Prettify<T> = {
[K in keyof T]: T[K];
} & {};
@wojtekmaj
wojtekmaj / jest-to-vitest.sh
Last active March 27, 2025 15:05
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
@EllyLoel
EllyLoel / reset.css
Last active January 24, 2025 09:14
CSS Reset
/*
Made by Elly Loel - https://ellyloel.com/
With inspiration from:
- Josh W Comeau - https://courses.joshwcomeau.com/css-for-js/treasure-trove/010-global-styles/
- Andy Bell - https://piccalil.li/blog/a-modern-css-reset/
- Adam Argyle - https://unpkg.com/[email protected]/normalize.min.css / https://codepen.io/argyleink/pen/KKvRORE
Notes:
- `:where()` is used to lower specificity for easy overriding.
*/
@danielroe
danielroe / fromEntries.ts
Created June 1, 2022 12:40
fromEntries typing
type Entries<T extends Readonly<Array<readonly [string, any]>>> = {
[Index in keyof T]: { [K in T[Index][0]]: T[Index][1] }
}[number]
type UnionToIntersection<U> =
(U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never
const fromEntries = <T extends Readonly<Array<readonly [string, any]>>>(entries: T): UnionToIntersection<Entries<T>> =>
Object.fromEntries(entries) as any
@danielroe
danielroe / settings.json
Last active April 19, 2025 06:36
VScode settings for a minimal UI
{
// Disable telemetry
"telemetry.telemetryLevel": "off",
// Zen mode
"zenMode.fullScreen": false,
"zenMode.hideTabs": true,
"zenMode.centerLayout": false,
// Theming
"workbench.iconTheme": "city-lights-icons-vsc",
"editor.fontFamily": "Dank Mono",
@Raaghu
Raaghu / environment-step.js
Created December 1, 2021 14:02
Run Jest Tests as sequence of steps
/* eslint-disable */
import NodeEnvironment from "jest-environment-node";
/**
* Enables to run as steps of a pipeline
*
* Features
* - run all previous tests before running the current test
* - Skip all future steps if current step fails