Skip to content

Instantly share code, notes, and snippets.

View sureshg's full-sized avatar
🚀
☕️

Suresh sureshg

🚀
☕️
View GitHub Profile
@jboner
jboner / latency.txt
Last active December 7, 2025 11:28
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
@mostlygeek
mostlygeek / demo.rb
Created January 24, 2012 21:29
Chef ruby_block and dynamic resource creation
ruby_block "sync_build_from_s3" do
action :nothing
block do
# latest_file contains path to the latest.txt, which lists files to sync
file = File.new(latest_file, "r");
run_context = Chef::RunContext.new(node, {})
#
# Create the directory to hold the new build files
#
package com.koushikdutta.nio;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.util.LinkedList;
import junit.framework.Assert;
public class ByteBufferList {
private static final String LOGTAG = "Tether";
@joelgwebber
joelgwebber / fetch_natgeo_2011.py
Created December 21, 2011 06:43
Quick python hack to fetch the desktop versions of all the National Geographic 2011 Photo Contest winners and editors' picks
import urlparse
from urllib import urlretrieve
base_url = 'http://ngm.nationalgeographic.com/'
urls = [ \
"/u/H6yMi6fUB_1JR964xxG8RxsYArlNNn1lR5PWutchJ4t_YnYgRQSgSbjtWe2l0Iy-oLGsA9CsqdnrlLhmR0g3rCSzBRF7/", \
"/u/H6yMi6fUB_1JR964xxG8RxsYArlNNn1lR5PWutchJ4t_Y-BNZaUHGX3GhRGQkkys1pZ0r6MMH1tkBqLFL_pSFt3xA3Oi/", \
"/u/H6yMi6fUB_1JR964xxG8RxsYArlNNn1lR5PWutchJ4t6VV_HIvlh3DLvd9e4D4G0uBFWsZpxfwWu_TJ9TchpFQyt2qg8/", \
"/u/H6yMi6fUB_1JR964xxG8RxsYArlNNn1lR5PWutchJ4rkKJOkhh6J27Lg1KkOxF6sBxFqALR33By8KpJ5CndmMknK8Yyx/", \
@zaius
zaius / background.sh
Created January 16, 2011 23:29
How to redirect a running process output to a file and log out
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
@indy
indy / improved-perlin-noise.java
Created February 6, 2010 12:22
Perlin noise - Java implementation
// JAVA REFERENCE IMPLEMENTATION OF IMPROVED NOISE - COPYRIGHT 2002 KEN PERLIN.
public final class ImprovedNoise {
static public double noise(double x, double y, double z) {
int X = (int)Math.floor(x) & 255, // FIND UNIT CUBE THAT
Y = (int)Math.floor(y) & 255, // CONTAINS POINT.
Z = (int)Math.floor(z) & 255;
x -= Math.floor(x); // FIND RELATIVE X,Y,Z
y -= Math.floor(y); // OF POINT IN CUBE.
z -= Math.floor(z);