Skip to content

Instantly share code, notes, and snippets.

View hyoban's full-sized avatar
🏠
Working from home

Stephen Zhou hyoban

🏠
Working from home
View GitHub Profile
function fromRecords<T>(items: T[], key: keyof T, value: keyof T) {
return Object.fromEntries(items.map(({ [key]: k, [value]: v }) => [k, v]))
}
const users = [
{ id: 'id1', name: 'Alice', email: 'alice@example.com' },
{ id: 'id2', name: 'Bob', email: 'bob@example.com' },
]
const userMap = fromRecords(users, 'id', 'name')
@theodorosploumis
theodorosploumis / Nework_throttling_profiles.md
Last active May 11, 2024 04:18
Web development - Custom network throttling profiles
Profile download (kb/s) upload (kb/s) latency (ms)
Native 0 0 0
GPRS 50 20 500
56K Dial-up 50 30 120
Mobile EDGE 240 200 840
2G Regular 250 50 300
2G Good 450 150 150
3G Slow 780 330 200
@hermanbanken
hermanbanken / Dockerfile
Last active April 22, 2024 10:53
Compiling NGINX module as dynamic module for use in docker
FROM nginx:alpine AS builder
# nginx:alpine contains NGINX_VERSION environment variable, like so:
# ENV NGINX_VERSION 1.15.0
# Our NCHAN version
ENV NCHAN_VERSION 1.1.15
# Download sources
RUN wget "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -O nginx.tar.gz && \