Skip to content

Instantly share code, notes, and snippets.

idudinov / prerenderPlugin.js
Last active Jun 16, 2021
PrerenderPlugin for HtmlWebpackPlugin – Pre-renders html during Webpack build phase
View prerenderPlugin.js
const HtmlWebpackPlugin = require('html-webpack-plugin');
const jsdom = require('jsdom');
/** @typedef {import("webpack/lib/Compiler.js")} WebpackCompiler */
/** @typedef {import("webpack/lib/Compilation.js")} WebpackCompilation */
/** @typedef {(import 'jsdom').ResourceLoaderConstructorOptions} ResourceLoaderConstructorOptions */
class PrerenderHtmlPlugin {
constructor(options) {
this._options = options || { };
View Infrastructure.js
let cache = new Map();
let pending = new Map();
function fetchTextSync(url) {
if (cache.has(url)) {
return cache.get(url);
if (pending.has(url)) {
throw pending.get(url);
tcnksm /
Last active Dec 14, 2021
Small note of gRPC Best Practice @ CoreOSFest 2017
PDO::FETCH_FUNC without validation
10: 0.001568078994751
100: 0.0012631416320801
CMCDragonkai / flock_timeout.php
Last active Sep 23, 2021
PHP: Simulating Lock Timeout with PHP's Flock
View flock_timeout.php
* Acquires a lock using flock, provide it a file stream, the
* lock type, a timeout in microseconds, and a sleep_by in microseconds.
* PHP's flock does not currently have a timeout or queuing mechanism.
* So we have to hack a optimistic method of continuously sleeping
* and retrying to acquire the lock until we reach a timeout.
* Doing this in microseconds is a good idea, as seconds are too
* granular and can allow a new thread to cheat the queue.
View ConfigController.php
class ConfigController {
const MODEL = 'App\Models\Config';
// see RestControllerTrait. sends less data on indexing the list of the model
// protected $indexFields = [ 'name' ];
protected $triggers = [
// 'show' => 'extendObject',
// 'update' => 'dataFormatFix',
View RFC 3339 regex
JamesMessinger / circular-refs.js
Created Jul 16, 2015
JSON Schema Circular $Refs
View circular-refs.js
"definitions": {
"thing": {
"$ref": "#/definitions/thing" // circular reference to self
"person": {
"properties": {
"name": {
"type": "string"
CMCDragonkai /
Last active Jan 8, 2022
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