Skip to content

Instantly share code, notes, and snippets.

View davidglezz's full-sized avatar
😃
Happy

David Gonzalez davidglezz

😃
Happy
View GitHub Profile
@OrionReed
OrionReed / dom3d.js
Last active May 7, 2024 08:58
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
@EllyLoel
EllyLoel / reset.css
Last active April 13, 2024 18: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/open-props@1.3.16/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 May 4, 2024 08:55
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
Seven different types of CSS attribute selectors
// This attribute exists on the element
[value]
// This attribute has a specific value of cool
[value='cool']
// This attribute value contains the word cool somewhere in it
[value*='cool']
@Rich-Harris
Rich-Harris / index.js
Last active January 22, 2020 22:21
whatwg stream utils
const fs = require('fs');
const { ReadableStream, TransformStream, WritableStream} = require('web-streams-polyfill/ponyfill/es2018');
function createReadStream(file, opts) {
return new ReadableStream({
start(controller) {
const stream = fs.createReadStream(file, opts);
stream.on('readable', () => {
const data = stream.read();
controller.enqueue(data);
@androideveloper
androideveloper / pre-commit
Last active October 2, 2023 21:10
Git hook to enforce branch naming policy
#!/usr/bin/env bash
LC_ALL=C
local_branch="$(git rev-parse --abbrev-ref HEAD)"
valid_branch_regex="^(feature|bugfix|improvement|library|prerelease|release|hotfix)\/[a-z0-9._-]+$"
message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. Your commit will be rejected. You should rename your branch to a valid name and try again."
if [[ ! $local_branch =~ $valid_branch_regex ]]
@mikowl
mikowl / oneliners.js
Last active March 28, 2024 20:52
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);