Skip to content

Instantly share code, notes, and snippets.

@sgmac
sgmac / latency.txt
Created May 12, 2025 05:04 — 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
# Source: https://gist.github.com/808108069f709572f1bc372c65f6b5c0
###########
# Prepare #
###########
# Option 1:
# Create a Kubernetes cluster
# Install NGINX Ingress
# Install Argo CD
# Source: https://gist.github.com/84324e2d6eb1e62e3569846a741cedea
####################
# Create a Cluster #
####################
minikube start
#############################
# Deploy Ingress Controller #
@sgmac
sgmac / feed.go
Created May 1, 2018 21:05
Managing opml feeds
package main
import (
"encoding/xml"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"strings"
package main
import (
"context"
"fmt"
"os"
"os/signal"
"sync"
"syscall"
"time"
# Based on http://fearby.com/article/update-openssl-on-a-digital-ocean-vm/
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ wget ftp://ftp.openssl.org/source/openssl-1.0.2j.tar.gz # Check the last version
$ tar -xvzf openssl-1.0.2h.tar.gz
$ cd openssl-1.0.2h
$ ./config --prefix=/usr/
$ make depend
// Crear un programa que declare dos funciones anónimas. Una que cuente del 0 al 200 y otra que cuente de 200 a 0.
// Mostrar cada número con un identificador único para cada goroutine.
// Crear goroutines a partir de estas funciones.
// No permitir que main regrese hasta que ambas goroutines hayan terminado de correr.
// https://play.golang.org/p/wjhbcgFg-g
package main
// Agregar imports.
@sgmac
sgmac / pipeTee.go
Created August 18, 2015 18:10
Example using io.TeeReader and io.Pipe
package main
import (
"bufio"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"sync"
@sgmac
sgmac / cacheRatio.go
Last active August 29, 2015 14:18
memcache stats
package main
import (
"fmt"
"io/ioutil"
"log"
"net"
"regexp"
"strconv"
)
@sgmac
sgmac / 0_reuse_code.js
Created June 3, 2014 21:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console