Skip to content

Instantly share code, notes, and snippets.

View rememberlenny's full-sized avatar

Leonard Bogdonoff rememberlenny

View GitHub Profile
@rememberlenny
rememberlenny / latency.markdown
Created February 5, 2024 17:55 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@rememberlenny
rememberlenny / latency.txt
Created February 5, 2024 17:52 — forked from jboner/latency.txt
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
@rememberlenny
rememberlenny / management.md
Created May 19, 2022 16:48 — forked from samlambert/management.md
Management @ PlanetScale

We want PlanetScale to be the best place to work. But every company says that, and very few deliver. Managers have a role in creating an amazing work experience, but things go awry when the wrong dynamic creeps in.

We have all seen those managers who collect people as “resources” or who control information as a way to gain “power.” In these cultures, people who “can’t” end up leading the charge. This is management mediocrity.

What will make us different? At PlanetScale, we won’t tolerate management mediocrity. We are building a culture where politics get you nowhere and impact gets you far. Managers are here to support people who get things done. They are as accountable to their team as their team is accountable to them.

We evaluate managers on the wellbeing and output of their team, how skillfully they collaborate with and influence others, and how inclusively and transparently they work.

You can expect your manager to:

  • Perceive a better version of you and support you in getting there
@rememberlenny
rememberlenny / post.md
Created February 5, 2022 03:26 — forked from mitchellh/post.md
Originally posted on Tumblr on Feb 25, 2011.

THIS WAS ORIGINALLY POSTED ON MY TUMBLR ON FEB 25, 2011. I forgot I had a Tumblr account. I recently logged in (in light of the acquisition by Automattic), found some old posts, and I'm republishing them exactly as they were with zero modifications.


CloudFormation: The Big Picture

Amazon announced CloudFormation to the public yesterday, and while the general opinion I could glean from various sources shows that people are excited about this new technology, many are still unsure what it is and how it fits into their current cloud workflow. I feel as though I have a firm grasp on CloudFormation and will attempt to answer some questions here.

Note: I'm definitely not a representative of Amazon in any way, and anything here is simply my educated opinion on the matter.

@rememberlenny
rememberlenny / sidekiq_monitoring
Created January 2, 2022 19:40 — forked from ngsmrk/sidekiq_monitoring
Sidekiq queue checking via rails console
stats = Sidekiq::Stats.new
stats.queues
stats.enqueued
stats.processed
stats.failed
@rememberlenny
rememberlenny / Dockerfile
Created November 4, 2021 18:57 — forked from chrisn/Dockerfile
Compile audiowaveform in Docker for amazonlinux:1
FROM amazonlinux:1
RUN yum -y update
RUN yum -y install make wget tar gcc gcc-c++ file diffutils
RUN wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz && \
tar -xzvf cmake-3.7.2.tar.gz && cd cmake-3.7.2 && \
./bootstrap && make && make install
RUN yum -y install cmake autogen automake libtool \
gzip zip libcurl-devel zlib-static libpng-static xz git \
boost-static boost-devel \
bzip2-devel which gd-devel
@rememberlenny
rememberlenny / States-v3.md
Created June 11, 2021 14:01 — forked from andymatuschak/States-v3.md
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@rememberlenny
rememberlenny / gist:c0f7c3c87d25583aa9334cebc23a2c56
Created June 8, 2021 13:14
redux toolkit testing strategy
counterSlice.js
------------------
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit'
import fakeFetch from './fakeFetch';
export const lazyAdd = createAsyncThunk('counter/lazyAdd',
async (payload, thunkAPI) => {
// throw ('error in thunk!')
const response = await fakeFetch(payload);
return response;
@rememberlenny
rememberlenny / async-foreach.js
Created December 13, 2020 19:25 — forked from Atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@rememberlenny
rememberlenny / gcloud-quota.MD
Created October 31, 2020 07:53 — forked from Tknott95/gcloud-quota.MD
Google Cloud FIX for - IN_USE_ADDRESSES | 8 Used Quota | exceeded quotas 8+ needed 1

Google Cloud Deploy fix for 8 used quota limit issue 8+ 1 needed

(visually see servers in pic)

Gcloud Logo

** error message **

IN_USE_ADDRESSES | 8 Used Quota | exceeded quotas 8+ needed 1