Skip to content

Instantly share code, notes, and snippets.

@keturn
keturn / loopback-latency.sh
Created August 20, 2010 22:35
use netem to add latency to loopback network traffic
#!/bin/bash
#
# Add latency to all outgoing traffic on $DEV on tcp/udp $PORT,
# in the amount of $DELAY.
#
# This is matching on both source port and destination port, which
# may hit you twice if you're accessing a local resource.
#
# To see what's currently in effect,
# tc -s qdisc show dev lo
@moraes
moraes / gist:2141121
Last active May 1, 2023 19:02
LIFO Stack and FIFO Queue in golang
package main
import (
"fmt"
)
type Node struct {
Value int
}
@jboner
jboner / latency.txt
Last active April 18, 2024 17:18
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
@swannodette
swannodette / gist:3217582
Created July 31, 2012 14:52
sudoku_compact.clj
;; based on core.logic 0.8-alpha2 or core.logic master branch
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
@mislav
mislav / OpenSSL fix.md
Last active June 8, 2023 07:48
Fix OpenSSL certificate errors on Ruby 2.0

The reason why you might get certificate errors in Ruby 2.0 when talking HTTPS is because there isn't a default certificate bundle that OpenSSL (which was used when building Ruby) trusts.

Update: this problem is solved in edge versions of rbenv and RVM.

$ ruby -rnet/https -e "Net::HTTP.get URI('https://github.com')"
net/http.rb:917:in `connect': SSL_connect returned=1 errno=0 state=SSLv3
  read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)

You can work around the issue by installing a certificate bundle that you trust. I trust Mozilla and curl.

@pbailis
pbailis / list.md
Last active April 15, 2018 08:54
Quick and dirty (incomplete) list of interesting, mostly recent data warehousing/"big data" papers

A friend asked me for a few pointers to interesting, mostly recent papers on data warehousing and "big data" database systems, with an eye towards real-world deployments. I figured I'd share the list. It's biased and rather incomplete but maybe of interest to someone. While many are obvious choices (I've omitted several, like MapReduce), I think there are a few underappreciated gems.

###Dataflow Engines:

Dryad--general-purpose distributed parallel dataflow engine
http://research.microsoft.com/en-us/projects/dryad/eurosys07.pdf

Spark--in memory dataflow
http://www.cs.berkeley.edu/~matei/papers/2012/nsdi_spark.pdf

@dustin
dustin / progress.go
Last active December 19, 2015 16:18
Uploading a ton of stuff to S3, I decided I wanted something that would take this boring *os.File and give me a progress indicator. Here's the thing I threw together. Sends this sort of thing to stdout ('\r'ing over itself every second): 10MB/72MB (14.6%)
package main
import (
"fmt"
"io"
"os"
"time"
"github.com/dustin/go-humanize"
)

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption
@chengyin
chengyin / linkedout.js
Last active July 11, 2021 15:23
Unsubscribe all LinkedIn email in "one click". For an easier to use version, you can check out the bookmarklet: http://chengyin.github.io/linkedin-unsubscribed/
// 1. Go to page https://www.linkedin.com/settings/email-frequency
// 2. You may need to login
// 3. Open JS console
// ([How to?](http://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers))
// 4. Copy the following code in and execute
// 5. No more emails
//
// Bookmarklet version:
// http://chengyin.github.io/linkedin-unsubscribed/
@kyleburton
kyleburton / bot-verbs.txt
Last active November 7, 2023 21:43
The list of 'bot-verbs' that we give to new team members.
Philosophical:
* writing lines of code is one of the least valuable things I can do
* cultivate your impatience
* reject the status quo, unless we can re-derive it from first-principles
* engineers imprint on the first languages (techniuqes, frameworks or technology) that we find success with (unconsciously seen as caregivers, which we defend w/o always knowing why)
* we tend to overvalue the familiar/known; we tend to undervalue the unfamiliar/unknown, this interferes with our receptiveness to new ideas and personal growth
* we're 90% composed of bad habits; many of our best habits become bad as time passes; this allows us to filter for the fundamental; the great
* make doing the right thing easier than any other thing, or we will fail to achieve greatness, or break bad habits
* be conscious, be intentional
* "is this the highest we can aim?" (I prefer this over "is this the best we can do", the former is aspirational, the latter is judgemental)