Skip to content

Instantly share code, notes, and snippets.

ddprrt / resizeobserver.d.ts
Last active Jul 16, 2020
Resize Observer IDL
View resizeobserver.d.ts
type ResizeObserverBoxOptions = "border-box" | "content-box" | "device-pixel-content-box";
interface ResizeObserverOptions {
box?: ResizeObserverBoxOptions;
interface ResizeObservation {
readonly lastReportedSizes: ReadonlyArray<ResizeObserverSize>;
readonly observedBox: ResizeObserverBoxOptions;
readonly target: Element;
ddprrt / curry.ts
Created Jun 22, 2020
Currying with variadic tuple types
View curry.ts
function curry<T extends unknown[], U extends unknown[], V>(
f: (...ts: [...T, ...U]) => V,
...a: T
): (...b: U) => V {
return (...b) => f(...a, ...b);
const input = (a: number, b: string, c: boolean, d: symbol) =>
[a, b, c, d] as const;
curry(input, 1, "123", true, Symbol())();
ddprrt / all-elements.ts
Created May 27, 2020
All HTML Element types
View all-elements.ts
type AllElements = {
'a': HTMLAnchorElement;
'div': HTMLDivElement;
'span': HTMLSpanElement;
'ul': HTMLUListElement;
'title': HTMLTitleElement;
'textarea': HTMLTextAreaElement;
'template': HTMLTemplateElement;
'tfoot': HTMLTableSectionElement;
'thead': HTMLTableSectionElement;
ddprrt / typedef.js
Created Jul 15, 2019
My code shares on Twitter. As a gist. Primarily for #a11y
View typedef.js
* @typedef {Object} Article
* @property {string} title
* @property {number} price
* @property {number} vat
* @property {number} stock
* @property {string} description
/** @type {Article} */
let article;
View index.html
<input type="color" />
ddprrt / Gulpfile.js
Created Oct 29, 2015
Gulp task system and Promises
View Gulpfile.js
* Bluebird allows us to promisify existing Node.js
* technologies. So fs.writeFile and fs.readFile
* are usable with Promises.
* `fetch` fetches Ressources. This code fetches
* jQuery, and saves the responses body in a file
var gulp = require('gulp');
ddprrt / Gulpfile.js
Last active May 8, 2020
Gulp: Grabbing JavaScript assets from a CDN to add to your build pipeline
View Gulpfile.js
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var request = require('request');
var merge = require('merge2');
var concat = require('gulp-concat');
var buffer = require('gulp-buffer');
* 1. We request the latest jQuery version from the jQuery CDN. The
* request package allows for streaming. What we get in return
View lessig.less
@color: blue;
body {
background-color: @color;
You can’t perform that action at this time.