Skip to content

Instantly share code, notes, and snippets.

View fijiwebdesign's full-sized avatar

Gabirieli Lalasava fijiwebdesign

View GitHub Profile
@aenain
aenain / analyze_modules.js
Last active December 7, 2022 21:26
JS script to visualize ES6 circular dependencies by producing a directed graph using dot notation.
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
@fijiwebdesign
fijiwebdesign / test-internet-connection.js
Created November 20, 2017 10:57
Test if we have an internet connection with JS
function testConnection() {
var url = location.href.match(/^https?\:/i) ? '/' : 'https://google.com'
var rand = parseInt(Math.ceil(Math.random()*Math.pow(10, 14))).toString(16)
var retry = ms => setTimeout(() => testConnection(), ms || 5000)
var notify = msg => document.body.innerHTML = `<h1 style="font-size:300%;position:fixed;top:40%;width:100%;text-align:center;">${msg}</h1>`
var handleResp = (err, msg) => {
console.log(err, new Date, msg)
notify(msg)
retry()
}
@paulirish
paulirish / what-forces-layout.md
Last active May 19, 2024 03:45
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
@CMCDragonkai
CMCDragonkai / http_streaming.md
Last active May 7, 2024 16:35
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@rbuckton
rbuckton / es7decoratorunification.md
Last active April 13, 2018 08:37
Unification of Decorators and Annotations for ES7

Summary

One issue introduced by decorators is that any attempt to use them on a function declaration would either necessitate a TDZ for the declaration, or would need to be an error. This limits the usefullness of decorators.

Another issue is that many use cases for annotations need a coherent runtime API that allows for imperative reflection for annotations of an object, its members, or the parameters of a function.

This document describes two parts to a solution for unifying decorators and annotations:

  1. Marking decorators as "early" with the @decorator decorator.
  2. Extending the Reflect API with a comprehensive set of functions for reflecting and managing metadata.
native-stream.js uses the reference implementation, compiled with babel to run
on latest io.js.
stream-bluebird.js is exactly the same as native-stream.js except it uses the
latest bluebird Promise implementation.
node-stream.js uses the node stream implementation and forced to be async by
using process.nextTick() (which is functionally equivalent to the microtask
processor)
@calvinmetcalf
calvinmetcalf / es5-readable.js
Created January 13, 2015 15:35
whatwg readable streams translated to es5
var Promise = global.Promise || require('lie');
function noop(){}
function typeIsObject(x) {
return (typeof x === 'object' && x !== null) || typeof x === 'function';
}
function ExclusiveStreamReader () {
throw new Error('not implimented');
}
function ReadableStream(opts) {
var start = opts.start || noop;
@staltz
staltz / introrx.md
Last active May 18, 2024 05:17
The introduction to Reactive Programming you've been missing