View gist:2494970
var n = 100000; | |
console.time('innerHTML'); | |
var e = document.createElement('div'); | |
e.innerHTML = Array(n+1).join('<span></span>'); | |
console.log(document.body.appendChild(e).children.length + ' inserted!'); | |
console.timeEnd('innerHTML'); | |
console.time('DOM'); | |
var d = document.createElement('div'); |
View master_regex.py
(?P<t_COMMENT>\/\*(?:[^*])*(?:\*)+(?:[^/](?:[^*])*(?:\*)+)*\/)|(?P<t_STRING>(?:(?:"(?:(?:(?:[^\n\r\f\\"])|(?:\\\n|\r\n|\r|\f)|(?:(?:(?:\\[0-9a-fA-F]{1,6}(?:(?:(?:\r\n)|(?:[ \t\r\n\f])))?)|(?:\\[^\r\n\f0-9a-fA-F])))))*")|(?:'(?:(?:(?:[^\n\r\f\\'])|(?:\\\n|\r\n|\r|\f)|(?:(?:(?:\\[0-9a-fA-F]{1,6}(?:(?:(?:\r\n)|(?:[ \t\r\n\f])))?)|(?:\\[^\r\n\f0-9a-fA-F])))))*')))|(?P<t_INVALID>(?:(?:"(?:(?:(?:[^\n\r\f\\"])|(?:\\\n|\r\n|\r|\f)|(?:(?:(?:\\[0-9a-fA-F]{1,6}(?:(?:(?:\r\n)|(?:[ \t\r\n\f])))?)|(?:\\[^\r\n\f0-9a-fA-F])))))*)|(?:'(?:(?:(?:[^\n\r\f\\'])|(?:\\\n|\r\n|\r|\f)|(?:(?:(?:\\[0-9a-fA-F]{1,6}(?:(?:(?:\r\n)|(?:[ \t\r\n\f])))?)|(?:\\[^\r\n\f0-9a-fA-F])))))*)))|(?P<t_EMS>(?:(?:(?:[0-9])*\.(?:[0-9])+)|(?:(?:[0-9])+))(?:(?:e)|(?:\\0{0,4}(?:(?:45)|(?:65))(?:(?:(?:\r\n)|(?:[ \t\r\n\f])))?))(?:(?:m)|(?:\\0{0,4}(?:(?:4d)|(?:6d))(?:(?:(?:\r\n)|(?:[ \t\r\n\f])))?)))|(?P<t_EXS>(?:(?:(?:[0-9])*\.(?:[0-9])+)|(?:(?:[0-9])+))(?:(?:e)|(?:\\0{0,4}(?:(?:45)|(?:65))(?:(?:(?:\r\n)|(?:[ \t\r\n\f])))?))(?:(?:x)|(?:\\0{0,4}(?:(?:58)|(?:7 |
View get-coffee.bash
#!/bin/bash | |
while true; do | |
echo -n ' '; | |
head -10 /dev/urandom | hexdump -C | head -3 | cut -d' ' -f2-18 | tr "\n" " " | \ | |
sed -e 's/[0-9a-f][0-9a-f]/\x1b[34m&\x1b[0m/g' | \ | |
sed -e 's/[a-c][0-3]/\x1b[41m&\x1b[0m/g' | \ | |
sed -e 's/[d-f][4-6]/\x1b[42m&\x1b[0m/g' | \ | |
sed -e 's/[0-3][0-3]/\x1b[9m&\x1b[0m/g' | \ | |
sed -e 's/[4-6][4-6]/\x1b[7m&\x1b[0m/g' | \ |
View chromium-status-utc-to-local-time.js
javascript:(function(){var y=', '+new Date().getFullYear(),j={0:'Sun',1:'Mon',2:'Tue',3:'Wed',4:'Thu',5:'Fri',6:'Sat'},m={0:'Jan',1:'Feb',2:'Mar',3:'Apr',4:'May',5:'Jun',6:'Jul',7:'Aug',8:'Sep',9:'Oct',10:'Nov',11:'Dec'};[].forEach.call(document.querySelectorAll('table[border] td:nth-of-type(2)'),function(el,i){if(i==0){el.width=160;}else{var d,p=el.textContent.split(',');p.splice(1,0,y);d=new Date(p.join(''));el.textContent=j[d.getDay()]+' '+m[d.getMonth()]+' '+(d.getDate()<10?'0':'')+d.getDate()+', '+(d.getHours()>12?(d.getHours()-12==0?'12':d.getHours()-12):(d.getHours()==0?'12':d.getHours()))+':'+(d.getMinutes()<10?'0':'')+d.getMinutes()+' '+(d.getHours()>12?'p':'a')+'m';}});}()); |
View check_links.pl
#!/usr/bin/env perl | |
# Author: Dan Beam <dan@danbeam.org> | |
# Requires: Test::WWW::Mechanize (libtest-www-mechanize-perl in apt-get, Test::WWW::Mechanize in CPAN) | |
# Usage: ./check_links.pl 'http://google.com' 'http://yahoo.com' | |
use strict; | |
use warnings; | |
use Test::More tests => 2 * scalar(@ARGV); | |
use Test::WWW::Mechanize; |
View update-nodejs.bash
#!/bin/bash | |
sudo apt-get -qq install build-essential g++ apache2-utils libssl-dev curl | |
latest_dir="http://nodejs.org/dist/latest/"; | |
latest_version=$(curl -s "$latest_dir" | grep "tar\.gz" | sed -re 's/.*?href="node-(v[0-9\.]+)\.tar\.gz".*/\1/'); | |
cleanup() { | |
rm -rf "$temp"; | |
} |
View size-of-dnd-ntp4-stuff.sh
$ cd chromium/src/chrome/browser/resources/ntp4/ | |
$ du -sh drag_wrapper.js apps_page.js bookmarks_page.js most_visited_page.js | |
4.0K drag_wrapper.js | |
28K apps_page.js | |
24K bookmarks_page.js | |
12K most_visited_page.js | |
$ ( du -sh drag_wrapper.js apps_page.js bookmarks_page.js most_visited_page.js | awk '{print $1}' | tr "K" "+" && echo 0 ) | xargs | bc |
View gist:1297765
dig gmail.com txt | grep redirect= | cut -d'=' -f3- | cut -d'"' -f1 | xargs -I{} dig {} txt | egrep '^[^;].*TXT' | cut -d'"' -f2 | tr " " "\n" | grep ^ip4: | cut -d':' -f2- | xargs -I{} sudo ufw allow from {} to any proto tcp port 25 |
View console-unicode-bug.js
// put on JavaScript console, press enter | |
'\u00a0\u00a0\u25b2\u000a\u00a0\u00a0\u25b2\u00a0\u25b2\u000a\u00a0\u25b2\u00a0\u25b2\u00a0\u25b2' |
View clientrect-contains.js
// Why aren't we native yet? | |
ClientRect.prototype.contains = function (x, y) { | |
// support 1 arg of {x: ##, y: ##} | |
if (x && x.x && !y) { | |
y = x.y; | |
x = x.x; | |
} | |
return (x >= this.left && x <= this.right && | |
y >= this.top && y <= this.bottom); | |
}; |