Skip to content

Instantly share code, notes, and snippets.

View adragomir's full-sized avatar

Andrei Dragomir adragomir

View GitHub Profile
#!/usr/bin/env python
import os
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-v", "--verbose", dest="verbose",
help="print verbose messages. Try -vv, -vvv for \
more verbose messages", action="count")
### Keybase proof
I hereby claim:
* I am adragomir on github.
* I am adragomir (https://keybase.io/adragomir) on keybase.
* I have a public key whose fingerprint is A51D 4079 382D A12E 53AB 3D6E 7E1F AF2F 7AE5 2C0C
To claim this, I am signing this object:
diff :: Expr -> Expr
diff e =
case e of
(Lit _) -> Lit 0
(Const _) -> Lit 0
(Exp Var) -> Exp Var
(Exp x) -> diff $ Apply (Exp Var) x
(Ln Var) -> Inv Var
(Ln x) -> diff $ Apply (Ln Var) x
(Cos Var) -> Neg $ Sin Var
package main
import (
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
[Unit]
Description=Create AWS partitions
DefaultDependencies=false
Before=local-fs-pre.target var.mount mnt-data_1.mount -.mount local-fs.target
[Service]
Type=oneshot
ExecStart=/bin/sh /etc/early-boot.sh
RemainAfterExit=yes
#!/bin/bash
# get the absolute path of the executable
SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0")
# resolve symlinks
while [ -h $SELF_PATH ]; do
# 1) cd to directory of the symlink
# 2) cd to the directory of where the symlink points
# 3) get the pwd
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Creates networking infrastructure.",
"Parameters" : {
"BastionKeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the bastion host",
"Type" : "String",

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
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 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs 4X memory

# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
@adragomir
adragomir / rate_limit.go
Created October 6, 2014 08:29
rate_limit.go
import (
"bytes"
"code.google.com/p/gopacket"
"code.google.com/p/gopacket/examples/util"
"code.google.com/p/gopacket/layers"
"code.google.com/p/gopacket/pcap"
"github.com/nsf/termbox-go"
"log"
"regexp"
)