Skip to content

Instantly share code, notes, and snippets.


Paul Irish paulirish

View GitHub Profile
View detect IE and version number through injected conditional comments.js
//EnhanceJS isIE test idea
//detect IE and version number through injected conditional comments (no UA detect, no need for cond. compilation / jscript check)
//version arg is for IE version (optional)
//comparison arg supports 'lte', 'gte', etc (optional)
function isIE(version, comparison) {
var cc = 'IE',
b = document.createElement('B'),
paulirish /
Last active Feb 11, 2020 — forked from jasonLaster/inspector.js
how to issue commands and monitor the devtools protocol

Playing with the protocol

You can send arbitrary commands over the protocol fairly easily.

Main.sendOverProtocol('Emulation.setDeviceMetricsOverride', nexus5XMetrics());

// It returns a promise
paulirish /
Last active Jul 22, 2019 — forked from xiaom/
install mosh locally (updated june 2017)
# 2017-06 (paulirish): updated for latest sources
# and incorporated fixes from my comments here:
# 2015-ish (zmil): this script does absolutely ZERO error checking. however, it worked
# for me on a RHEL 6.3 machine on 2012-08-08. clearly, the version numbers
# and/or URLs should be made variables. cheers,
set -x
View debugger.js
var Chrome = require('chrome-remote-interface')
chooseTab: function(tabs) {
var idx = 0
tabs.forEach(function(tab, i) {
if (tab.url === 'http://localhost:9966/')
idx = i
return idx
View geolocation.js
if (!navigator.geolocation) {
navigator.geolocation = (function (window) {
function getCurrentPosition(callback) {
// NOTE: for some reason, chaging the url is *allowed* with this service. Useful, but random
// source:
// The source is open source, as per:, but doesn't discuss specific license use. Hopefully it's just free to use - yay internet!
var geourl = '' + Math.random(),
iframe = document.createElement('iframe'),
doc, win;
paulirish / USA_data.js
Created Jan 8, 2012 — forked from kforeman/USA_data.js
d3 SVG treemap
View USA_data.js
{'name': 'data', 'children': [
{'name':'A', 'desc':"Communicable, maternal, perinatal and nutritional conditions", 'children':[
{'name':'A01', 'desc':"Tuberculosis", '90FE':0, '90FL':0, '90FP':.000484, '90F1':.000857, '90F5':.000954, '90F10':.000915, '90F15':.000679, '90F20':.001865, '90F25':.002201, '90F30':.002423, '90F35':.001872, '90F40':.001363, '90F45':.001124, '90F50':.000934, '90F55':.000866, '90F60':.000818, '90F65':.000846, '90F70':.00086, '90F75':.000809, '90F80':.000549, '00FE':0, '00FL':0, '00FP':.000539, '00F1':.001017, '00F5':.000981, '00F10':.000816, '00F15':.000609, '00F20':.001216, '00F25':.001175, '00F30':.001267, '00F35':.000935, '00F40':.000713, '00F45':.000735, '00F50':.000596, '00F55':.000584, '00F60':.000544, '00F65':.000565, '00F70':.000608, '00F75':.000603, '00F80':.000399},
{'name':'A02', 'desc':"HIV/AIDS", '90FE':.023124, '90FL':.002457, '90FP':.023525, '90F1':.098902, '90F5':.103213, '90F10':.06633, '90F15':.078107, '90F20':.142801, '90F25':.114696, '90F30':.122893, '90F35'
View index.html
<meta name="viewport" content="width=device-width">
paulirish /
Last active Oct 7, 2018 — forked from rvagg/ - simple script to fetch Node.js nightlies on OS X and Linux (x86, x64 & ARM)
# Usage:
# bash
hasxz=$(which xzcat)
os=$(uname | tr '[A-Z]' '[a-z]')
arch=$(uname -m)
View matchMedia.js
* matchMedia() polyfill - test whether a CSS media type or media query applies
* authors: Scott Jehl, Paul Irish, Nicholas Zakas
* Copyright (c) 2010 Filament Group, Inc
* MIT license
* in Chrome since m10:
View JavaScript preload() function
* JavaScript preload() function
* Preload images, CSS and JavaScript files without executing them
* Script by Stoyan Stefanov –
* Slightly rewritten by Mathias Bynens –
* Demo:
function preload(arr) {
var i = arr.length,