Skip to content

Instantly share code, notes, and snippets.

View igrigorik's full-sized avatar
:octocat:

Ilya Grigorik igrigorik

:octocat:
View GitHub Profile
@igrigorik
igrigorik / json-bq-schema-generator.rb
Last active November 3, 2022 17:34
BigQuery JSON schema generator
require 'open-uri'
require 'zlib'
require 'yajl'
# References
# - https://developers.google.com/bigquery/preparing-data-for-bigquery#dataformats
# - https://developers.google.com/bigquery/docs/data#nested
#
def type(t)
@igrigorik
igrigorik / micro-openssl-perf.sh
Created December 15, 2013 18:54
EC2 micro instance in EC2 West...
ubuntu@ip-10-202-152-39:~$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 45
model name : Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
stepping : 7
microcode : 0x70a
cpu MHz : 1799.999
cache size : 20480 KB
@igrigorik
igrigorik / 150ms-delay.txt
Last active December 29, 2015 22:59
sudo tcpdump -ttttt host www.amazon.com ...
# 150ms in/out delay
# ~ 300 ms to complete handshake, as expected
#
00:00:00.000000 IP igrigorik.57812 > 176.32.98.166.http: Flags [S], seq 2280359597, win 65535, options [mss 1460,nop,wscale 4,nop,nop,TS val 1261175917 ecr 0,sackOK,eol], length 0
00:00:00.094100 IP 176.32.98.166.http > igrigorik.57812: Flags [S.], seq 895108428, ack 2280359598, win 8190, options [mss 1460,nop,wscale 6], length 0
00:00:00.297209 IP igrigorik.57812 > 176.32.98.166.http: Flags [.], ack 1, win 16384, length 0
00:00:00.297224 IP igrigorik.57812 > 176.32.98.166.http: Flags [P.], seq 1:79, ack 1, win 16384, length 78
# ~100 ms response time + 300 ms RTT later...
@igrigorik
igrigorik / compare.rb
Created November 27, 2013 18:39
Testing various Deflate compression parameters...
# Quick comparison of Deflate performance with respec to varios
# LZ77 window and memLevel settings. E.g...
#
# $> curl https://github.com/timeline.json -o timeline.json
# $> ruby compare.rb timeline.json
#
require "zlib"
unless file = ARGV[0]
@igrigorik
igrigorik / Gemfile
Last active December 27, 2015 15:09
source 'https://rubygems.org'
gem 'goliath'
class ConnectionInfo {
constructor(media="unknown",
className="unknown",
classId=0) {
this.media = media;
this.className = className;
this.classId = classId;
}
}
@igrigorik
igrigorik / github.bash
Last active December 22, 2023 23:55
Open GitHub URL for current directory/repo...
alias gh="open \`git remote -v | grep git@github.com | grep fetch | head -1 | cut -f2 | cut -d' ' -f1 | sed -e's/:/\//' -e 's/git@/http:\/\//'\`"
@igrigorik
igrigorik / nginx.conf
Created August 29, 2013 00:14
CH + select best candidate based on defined buckets.
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
@igrigorik
igrigorik / nginx.conf
Last active December 21, 2015 21:59
CH + DPR negotiation example for Nginx.
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;