Getting started:
Related tutorial: http://cd64.de/mysql-cli
SQL joins infografic: http://cd64.de/sql-joins
// Solving Knapsack problem using Branch and Bound - Tu Hoang - rebyn@me.com | |
// The sole question of this problem is: If you have a backpack of capacity C (weight) and you have a list of items which weigh differently (w1, w2, etc) and have different values (p1, p2, etc), which is the best combination of items to meet these requirements: | |
// 1. the total weight of items doesn't exceed C, | |
// 2. the total profit is the most possible maximal. | |
// Simply speaking, if you are a thief and you are stealing stuff from a store, which items should you choose to carry with you in order that you gain the most? | |
#include <iostream> | |
#include <iomanip> | |
#include <fstream> | |
#define CAPACITY 16 |
#!/bin/bash -e | |
echo ' | |
PATH=$HOME/go/bin:$PATH | |
export GOPATH=$HOME | |
export CDPATH=.:$HOME/src/golang.org/x:$HOME/go/src:$HOME/src/github.com:$HOME/src/github.com/nf:$HOME/src/github.com/adg | |
export EDITOR=vim | |
' >> ~/.profile | |
sudo apt-get update |
# Before | |
def self.send_request_to_path(request) | |
request.execute(target_base_url) | |
rescue Intercom::ServiceUnavailableError => e | |
if endpoints.length > 1 | |
retry_on_alternative_endpoint(request) | |
else | |
raise e | |
end | |
end |
<% | |
require 'cgi' | |
require 'uri' | |
begin | |
uri = URI.parse(ENV["DATABASE_URL"]) | |
rescue URI::InvalidURIError | |
raise "Invalid DATABASE_URL" | |
end |
package main | |
import ( | |
"net/http" | |
) | |
type SingleHost struct { | |
handler http.Handler | |
allowedHost string | |
} |
Latency Comparison Numbers | |
-------------------------- | |
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 | |
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
Read 4K randomly from SSD* 150,000 ns 0.15 ms |
Getting started:
Related tutorial: http://cd64.de/mysql-cli
SQL joins infografic: http://cd64.de/sql-joins
# SSL request to hostname that is not in DNS | |
> curl -o /dev/null -w @curlformat https://beta.finance.yahoo.com | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
100 255k 0 255k 0 0 233k 0 --:--:-- 0:00:01 --:--:-- 233k | |
Size: 261255 | |
DNS: 0.522 | |
Connect: 0.536 |
#!/bin/sh | |
# OS: Ubuntu 14.01 | |
# Generate data - produces about 200GB on disk, takes a while | |
DATADIR=tpch-dbgen | |
SCALE=1000 | |
git clone https://github.com/electrum/tpch-dbgen.git | |
cd $DATADIR && make && ./dbgen -f -v -C 16 -S 1 -s $SCALE && cd - |
# post_loc.txt contains the json you want to post | |
# -p means to POST it | |
# -H adds an Auth header (could be Basic or Token) | |
# -T sets the Content-Type | |
# -c is concurrent clients | |
# -n is the number of requests to run in the test | |
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/ |