Skip to content

Instantly share code, notes, and snippets.

View upphiminn's full-sized avatar
❄️

Corneliu Sugar upphiminn

❄️
View GitHub Profile
@upphiminn
upphiminn / http_streaming.md
Created September 27, 2023 20:23 — forked from CMCDragonkai/http_streaming.md
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

@upphiminn
upphiminn / http2.js
Created October 1, 2019 12:26 — forked from davidgilbertson/http2.js
HTTP2 server with compression and caching
const http2 = require('http2');
const fs = require('fs');
const path = require('path');
const zlib = require('zlib');
const brotli = require('brotli'); // npm package
const PORT = 3032;
const BROTLI_QUALITY = 11; // slow, but we're caching so who cares
const STATIC_DIRECTORY = path.resolve(__dirname, '../dist/');
const cache = {};
@upphiminn
upphiminn / err.js
Last active February 6, 2019 22:25
err...
async function doSomething() {
return new Promise((resolve, reject) => {
setTimeout(() => resolve("done!"), 1000)
});
}
// Rejection case
async function doSomethingBad() {
return new Promise((resolve, reject) => {
setTimeout(() => reject("crap!"), 1000)
@upphiminn
upphiminn / airlines.xml
Last active November 8, 2019 11:48
Example of d3-ForceEdgeBundling on US airline routes graph.
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key id="x" for="node" attr.name="x" attr.type="double"/>
<key id="tooltip" for="node" attr.name="tooltip" attr.type="string"/>
<key id="y" for="node" attr.name="y" attr.type="double"/>