Skip to content

Instantly share code, notes, and snippets.

View tomlobato's full-sized avatar
🎯
Focusing

Tom Lobato tomlobato

🎯
Focusing
View GitHub Profile
@jboner
jboner / latency.txt
Last active May 10, 2024 14:27
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
@CMCDragonkai
CMCDragonkai / memory_layout.md
Last active May 9, 2024 14:12
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@troyharvey
troyharvey / deployment.yml
Last active May 9, 2024 10:55
Using Kubernetes envFrom for environment variables
# Use envFrom to load Secrets and ConfigMaps into environment variables
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: mans-not-hot
labels:
app: mans-not-hot
spec:
replicas: 1
@niieani
niieani / throttle-and-debounce.sh
Last active December 11, 2023 15:39
throttle and debounce commands in bash
#!/usr/bin/env bash
declare -i last_called=0
declare -i throttle_by=2
@throttle() {
local -i now=$(date +%s)
if (($now - $last_called >= $throttle_by))
then
"$@"
@sawanoboly
sawanoboly / check_cert_period.rb
Created July 17, 2012 07:39
Checking expiry period of cert by ruby.
#!/usr/bin/env ruby
# -*- coding:utf-8 -*-
require 'socket'
require 'openssl'
require 'timeout'
require 'pp'
include OpenSSL
timeout=15
@everbeen
everbeen / benchmark.go
Last active November 14, 2023 22:17
BSON vs. Gob vs. MessagePack encoding & decoding benchmark
package main
import (
"bytes"
"encoding/gob"
"fmt"
"github.com/ugorji/go/codec"
"io/ioutil"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
@niflostancu
niflostancu / rootfs_ubuntu_16.04_btrfs.md
Created January 4, 2017 19:55
Installing Ubuntu 16.04 on btrfs using debootstrap

Installing Ubuntu 16.04 with btrfs using debootstrap

Partition layout

First, create a GPT partition table.

  1. boot partition, label: EFI, flags: boot + ESP; size: 1GB, format to FAT32;
  2. root partition (label: root), must same size on all devices!
  3. swap partition.
@karolyi
karolyi / backup-mariadb.sh
Last active April 19, 2023 12:14
Fast backup/restore mysql databases
#!/usr/bin/env bash
mariabackup --stream=xbstream --backup --user root|pigz >mariadb-backup.gz
@nevans
nevans / gist:9374041
Last active February 16, 2023 23:12
simple ruby console histogram generator
# Pass in an enumeration of data and
# (optionally) a block to extract the grouping aspect of the data.
#
# Optional: sort_by lambda (operates on group key and count)
#
def puts_hist(data, sort_by:nil, &blk)
data = data.map(&blk) if blk
counts = data.each_with_object(Hash.new(0)) {|k,h| h[k]+=1}
max = counts.values.max
width = Pry::Terminal.size!.last
@anarchivist
anarchivist / slack_munin.sh
Last active May 3, 2022 19:21
Slack notification script for Munin
#!/bin/bash
# Slack notification script for Munin
# Mark Matienzo (@anarchivist)
#
# To use:
# 1) Create a new incoming webhook for Slack
# 2) Edit the configuration variables that start with "SLACK_" below
# 3) Add the following to your munin configuration:
#