Skip to content

Instantly share code, notes, and snippets.

View nhoizey's full-sized avatar
👋

Nicolas Hoizey nhoizey

👋
View GitHub Profile
@maxfenton
maxfenton / postcss.config.js
Created May 1, 2023 19:15
PostCSS config for a legacy SASS project
module.exports = {
parser: "postcss-scss",
plugins: [
require("postcss-easy-import")({ // Enables globs in @import. See style.css.
prefix: false,
skipDuplicates: false,
warnOnEmpty: false,
}),
require("postcss-advanced-variables"), // Sass-style @ vars, looping, and @import
require("postcss-custom-media"), // Custom reusable media queries

Design Mode - Bookmarklet

Ce bookmarklet permet d'éditer le contenu d'une page web.

Totalement copié inspiré de https://css-tricks.com/web-development-bookmarklets/

Comment installer un bookmarklet ? https://mreidsma.github.io/bookmarklets/installing.html

javascript: if(document.designMode!='on'){document.designMode='on';let div = document.createElement('div');div.id='design-mode-on';div.style.position='fixed';div.style.inset='0';div.style.zIndex=20000;div.style.pointerEvents='none';div.style.boxShadow='inset 0 0 0 6px fuchsia';document.body.appendChild(div);}else{document.designMode='off';document.getElementById('design-mode-on').remove();}void 0;

@LewisJEllis
LewisJEllis / getRelativeTimeString.ts
Last active March 6, 2024 13:31
Simplified getRelativeTimeString
// from https://twitter.com/Steve8708/status/1504131981444980739
// simplified to a function body of 8 tidy lines
// no loop needed, no 2d array of 3-tuples needed
// just 2 arrays, a findIndex call, and some indexing :)
export function getRelativeTimeString(
date: Date | number,
lang = "en"
): string {
const timeMs = typeof date === "number" ? date : date.getTime();
@rik
rik / index.html
Last active October 22, 2021 13:20 — forked from davidbgk/index.html
Opening details tag on hash/anchor
<!doctype html><!-- This is a valid HTML5 document. -->
<!-- Screen readers, SEO, extensions and so on. -->
<html lang="en">
<!-- Has to be within the first 1024 bytes, hence before the `title` element
See: https://www.w3.org/TR/2012/CR-html5-20121217/document-metadata.html#charset -->
<meta charset="utf-8">
<meta name="color-scheme" content="light dark">
<!-- Why no `X-UA-Compatible` meta: https://stackoverflow.com/a/6771584 -->
<!-- The viewport meta is quite crowded and we are responsible for that.
See: https://codepen.io/tigt/post/meta-viewport-for-2015 -->
@davidbgk
davidbgk / index.html
Last active October 22, 2021 12:38
Opening details tag on hash/anchor
<!doctype html><!-- This is a valid HTML5 document. -->
<!-- Screen readers, SEO, extensions and so on. -->
<html lang="en">
<!-- Has to be within the first 1024 bytes, hence before the `title` element
See: https://www.w3.org/TR/2012/CR-html5-20121217/document-metadata.html#charset -->
<meta charset="utf-8">
<!-- Why no `X-UA-Compatible` meta: https://stackoverflow.com/a/6771584 -->
<!-- The viewport meta is quite crowded and we are responsible for that.
See: https://codepen.io/tigt/post/meta-viewport-for-2015 -->
<meta name="viewport" content="width=device-width,initial-scale=1">
html {
--max-width: 1200px;
--columns: 6;
--gutter: 1.5rem;
}
* {
--grid: minmax(var(--gutter), 1fr)
repeat(
var(--columns),
minmax(
@rviscomi
rviscomi / web-app-manifest.js
Created May 12, 2021 03:59
WebPageTest custom metric: web app manifest
[web-app-manifest]
const response_bodies = $WPT_BODIES;
const manifestURLs = new Set(Array.from(document.querySelectorAll('link[rel=manifest]')).map(link => {
const base = new URL(location.href).origin;
const href = link.getAttribute('href');
return new URL(href, base).href;
}));
const manifests = response_bodies.filter(har => {
@malchata
malchata / react-bias.md
Last active May 29, 2021 14:23
React Bias

React Bias

It may seem like a bold suggestion that we as web developers can choose the wrong tools for the job because we tend to be swayed by appeals to popularity or authority, but simple statistics imply just that. For example, React (https://reactjs.org/) is a JavaScript framework that emphasizes componentization and simplified state management. It enjoys strong advocacy from a vocal and dedicated userbase within the developer community.

Despite React’s apparent popularity, however, The HTTP Archive observed in 2020 that React only accounted for 4% of all libraries in use across the 7.56 million origins it analyzed (https://almanac.httparchive.org/en/2020/javascript#libraries).

For context, The State of JS 2020 Survey (https://2020.stateofjs.com/en-US/), which surveyed roughly 23,765 respondents, offers the following statistics:

  • 70.8% of respondents identified as white.
  • 91.1% identified as male, whereas 5.8% identified as female and 0.9% identified as non-binary/third gender.
@tkadlec
tkadlec / perf-diagnostics.css
Last active June 8, 2023 17:47
CSS used to highlight potential performance issues
:root {
--violation-color: red; /* used for clear issues */
--warning-color: orange; /* used for potential issues we should look into */
}
/* IMAGES */
/*
* Lazy-Loaded Images Check
* ====