Skip to content

Instantly share code, notes, and snippets.

View gu-stav's full-sized avatar
🍿

Gustav Hansen gu-stav

🍿
View GitHub Profile
@khalidx
khalidx / node-typescript-esm.md
Last active April 22, 2024 15:40
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@bvaughn
bvaughn / react-dom-test-selectors.md
Last active January 9, 2023 15:46
Experimental React DOM test selector API

RFC Test Selectors

Owner: Brian Vaughn


As of facebook/react/pull/22760, the experimental Test Selector API is now available in the experimental release channel.

To test the API, first install the experimental release:

@OrKoN
OrKoN / server.js
Last active February 25, 2019 13:00
Simple server with synchronization of request processing
/**
* WARNING: don't use the code in production, it only works for a single process instance and does not work in cluster mode.
*/
const express = require('express');
const app = express();
let nextRequestId = 1; // request counter
let nextPaymentId = 1; // payment counter
#![feature(lang_items)]
#![no_std]
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
// needed for no_std
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@p3t3r67x0
p3t3r67x0 / pseudo_elements.md
Last active January 16, 2024 01:17
A CSS pseudo-element is used to style specified parts of an element. In some cases you can style native HTML controls with vendor specific pseudo-elements. Here you will find an list of cross browser specific pseudo-element selectors.

Styling native elements

Native HTML controls are a challenge to style. You can style any element in the web platform that uses Shadow DOM with a pseudo element ::pseudo-element or the /deep/ path selector.

video::webkit-media-controls-timeline {
  background-color: lime;
}

video /deep/ input[type=range] {
@phamann
phamann / worker.js
Last active August 29, 2015 14:03
Simple ServiceWorker for Guardian hackday
console.log("Worker startup");
this.oninstall = function(event) {
console.log('Worker install');
event.waitUntil(
caches.create('static').then(function(cache) {
return cache.add(
//Templates
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = '/static/css/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if ( el.addEventListener ) {
el.addEventListener(ev, callback, false);
} else if ( el.attachEvent ) {
// HTML:
<div class="display-type"></div>
// CSS:
// set the content of an element depending on the media query
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing