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
import markdown2
from xhtml2pdf import pisa
import os
def create_pdf_from_markdown(markdown_file, output_filename):
# Read the content of the Markdown file
with open(markdown_file, 'r', encoding='utf-8') as md_file:
markdown_content = md_file.read()
# Convert the Markdown content to HTML with markdown2
@rememberlenny
rememberlenny / instructions.md
Last active April 6, 2023 01:32
GPT powered Poetic Git Commit Messages (Written by GPT-4)

In this guide, I'll show you how to create a Bash script that generates a short poem based on the changes made in your Git repository and uses it as a commit message. We'll integrate the OpenAI API to generate the poems and override the git commit -m command to use our custom script.

Step 1: Create the Poetic Commit Script

Create a file called poetic_commit.sh and paste the following code:

#!/bin/bash

# Save your OpenAI API Key in the OPENAI_API_KEY variable
@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 / example.sh
Created November 23, 2021 17:35
How to render a ruby gem as a lambda layer
How to render the layer from a gem
This code is copied from: https://dev.to/peterc/how-to-create-a-aws-lambda-layer-of-your-gemfile-ruby-gem-dependencies-1gfj
LAYER_NAME="my-ruby-layer"
mkdir $LAYER_NAME && cd $_
bundle init
bundle add fast_jsonparser --skip-install
rm Gemfile.lock
@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,