Skip to content

Instantly share code, notes, and snippets.

View maxjustus's full-sized avatar

Max Justus Spransy maxjustus

  • People With Jetpacks
  • Los Angeles, CA
View GitHub Profile
@wycats
wycats / 0_app.rb
Created April 19, 2012 10:22
Example of using a simple future library for parallel HTTP requests
class TicketsController < ApplicationController
def show
tickets = params[:tickets].split(",")
ticket_data = tickets.map do |ticket|
parallel { Faraday.get("http://tickets.local/#{ticket}") }
end
render json: { tickets: ticket_data.map(&:result) }
end
@jboner
jboner / latency.txt
Last active May 15, 2025 07:53
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
@eric
eric / cubism.papertrail.js
Created June 1, 2012 04:37
cubism.js source for Papertrail
/*
* Cubism source for Papertrail
* https://papertrailapp.com/
*/
cubism.context.prototype.papertrail = function(token) {
var source = {};
source.metric = function(expression, title) {
var lookup = {};
class HammingCode
attr_reader :data_bits
def initialize(number)
@number = number
@data_bits = number.to_s(2)
end
def parity_bits
indexes = []
current_index = 3
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active April 19, 2025 17:31 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
namespace :redis_failover do
task :monitor_client do
require 'redis_failover'
zookeepers = ENV['ZOOKEEPERS']
if !zookeepers && zookeepers_file = ENV['ZOOKEEPERS_FILE']
if File.exists?(zookeepers_file)
zookeepers = File.read(zookeepers_file).chomp
end
@ryandotsmith
ryandotsmith / lock.sh
Last active October 11, 2015 22:27
Locking using LOCKFILE(1)
export t=$(date +%s)
lockfile $t #create lock. Try running `lockfile $t` in another shell.
rm -f $t #delete lock
@JalfResi
JalfResi / revprox.go
Last active May 7, 2025 07:35
Simple reverse proxy in Go
package main
import(
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {