Skip to content

Instantly share code, notes, and snippets.

View addnab's full-sized avatar
🏒

Abdud Dayan Adeeb addnab

🏒
View GitHub Profile
@bellbind
bellbind / main.js
Last active August 21, 2022 09:32
[nodejs][worker_threads][es2018] req/res to Worker with for-await loop of ES2018
// node.js worker_threads module example with for-await loop: main thread side
//$ node --exprimental-worker main.js
const path = require("path");
const {Worker, MessageChannel} = require("worker_threads");
// async queue as "asyncIterator" in ES2018
class Queue {
constructor() {
this.polls = [];
this.gets = [];
@DJCordhose
DJCordhose / server-side-react-redux-router.js
Created September 20, 2015 11:58
React-redux-router: How to wait until all required actions have finished before rendering on the server side
export default function renderRoute(request, reply) {
const store = configureStore();
store.dispatch(match(request.path, (error, redirectLocation, routerState) => {
if (redirectLocation) {
reply.redirect(redirectLocation.pathname + redirectLocation.search);
} else if (error) {
reply(error.message).code(500);
} else if (!routerState) {
reply('Not found').code(404);
} else {
@alojzije
alojzije / connectHTMLelements_SVG.png
Last active March 24, 2024 19:36
Connect two elements / draw a path between two elements with SVG path (using jQuery)
connectHTMLelements_SVG.png
@ifels
ifels / golang_pipe_http_response.go
Last active February 1, 2023 19:19
golang pipe the http response
package main
import (
"io"
"net/http"
"os/exec"
)
var (
BUF_LEN = 1024
@nicolashery
nicolashery / example.js
Last active April 4, 2023 11:56
Combine a pipe of multiple Node.js streams into one stream
var util = require('util')
, Transform = require('stream').Transform
, StreamCombiner = require('./streamcombiner');
var chunks1 = [];
var stream1 = new Transform();
var soFar = '';
stream1._transform = function(chunk, encoding, done) {
chunks1.push(chunk.toString());
var pieces = (soFar + chunk).split('\n');
@jboner
jboner / latency.txt
Last active May 1, 2024 14:21
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD