Skip to content

Instantly share code, notes, and snippets.

Ilya Grigorik igrigorik

Block or report user

Report or block igrigorik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@igrigorik
igrigorik / links.md
Created Aug 28, 2012
HAR Show links & resources
View links.md
@igrigorik
igrigorik / compare.rb
Created Nov 27, 2013
Testing various Deflate compression parameters...
View compare.rb
# 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 / igvita.har.json
Created Aug 28, 2012
Sample HAR capture of igvita.com homepage
View igvita.har.json
{
"log": {
"version": "1.2",
"creator": {
"name": "WebInspector",
"version": "537.1"
},
"pages": [
{
"startedDateTime": "2012-08-28T05:14:24.803Z",
@igrigorik
igrigorik / index.html
Created Jun 8, 2013
XHR streaming example
View index.html
<p>Hello
<script>
var xhr = new XMLHttpRequest();
xhr.open('GET', '/stream');
xhr.seenBytes = 0;
xhr.onreadystatechange = function() {
console.log("state change.. state: "+ xhr.readyState);
@igrigorik
igrigorik / json-bq-schema-generator.rb
Last active Apr 18, 2019
BigQuery JSON schema generator
View json-bq-schema-generator.rb
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 / github.bash
Last active Apr 14, 2019
Open GitHub URL for current directory/repo...
View github.bash
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 / adb_trace.py
Last active Feb 23, 2019
ADB script for remote chrome://tracing debugging!
View adb_trace.py
#!/usr/bin/python
import subprocess
import re
import os
import sys
import optparse
import time
def call_checked(*args):
r = subprocess.call(args)
@igrigorik
igrigorik / gist:3148848
Created Jul 20, 2012
Convert any YouTube video into an audio file you can listen to on the go...
View gist:3148848
# Convert any YouTube video into an audio file you can listen to on the go, using:
# http://rg3.github.com/youtube-dl/
{ ~ } > brew install ffmpeg
{ ~ } > wget https://raw.github.com/rg3/youtube-dl/2012.02.27/youtube-dl
{ ~ } > chmod u+x youtube-dl
# Pick which video format you want to download.. (use any YT video link)
{ ~ } > ./youtube-dl -s -F http://www.youtube.com/watch?v=vT1KmTQ-1Os
@igrigorik
igrigorik / webapp.rb
Created Nov 13, 2010
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
View webapp.rb
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@igrigorik
igrigorik / drive-appscript.js
Last active Oct 23, 2018
Sample BigQuery queries for the HTTP Archive dataset.
View drive-appscript.js
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: "Run Query", functionName: "runQuery"} ];
ss.addMenu("HTTP Archive + BigQuery", menuEntries);
}
function runQuery() {
var projectNumber = 'httparchive';
var sheet = SpreadsheetApp.getActiveSheet();
You can’t perform that action at this time.