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 / ruby-1.9-tips.rb
Created Feb 3, 2011
Ruby 1.9 features, tips & tricks you may not know about...
View ruby-1.9-tips.rb
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@igrigorik
igrigorik / json-bq-schema-generator.rb
Last active Aug 26, 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 Aug 15, 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 / vimgolf.vimrc
Last active Aug 7, 2019
Basic vimrc to level the playing field...
View vimgolf.vimrc
" http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc
set nocompatible " use vim defaults
set scrolloff=3 " keep 3 lines when scrolling
set ai " set auto-indenting on for programming
set showcmd " display incomplete commands
set nobackup " do not keep a backup file
set number " show line numbers
set ruler " show the current row and column
@igrigorik
igrigorik / domtokenlist_feature_detection.js
Last active Jul 29, 2019 — forked from yoavweiss/domtokenlist_feature_detection.js
DOMTokenList supports() example for Preload
View domtokenlist_feature_detection.js
var DOMTokenListSupports = function(tokenList, token) {
if (!tokenList || !tokenList.supports) {
return;
}
try {
return tokenList.supports(token);
} catch (e) {
if (e instanceof TypeError) {
console.log("The DOMTokenList doesn't have a supported tokens list");
} else {
@igrigorik
igrigorik / mobile-first.html
Created Jun 15, 2012
mobile first css loading
View mobile-first.html
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="test for paint vs onload css behavior" />
<meta charset="utf-8" />
<title>Awesome mobile-first site</title>
<!--
Base stylesheet across all devices, loads first, and *needs* to be blocking to avoid
showing unstyled content.
@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 / adb_trace.py
Last active May 31, 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 / 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]
You can’t perform that action at this time.