Skip to content

Instantly share code, notes, and snippets.

@madrobby
madrobby / gist:9476733
Created Mar 10, 2014
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
View gist:9476733
curl -H 'Authorization: token INSERTACCESSTOKENHERE' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/owner/repo/contents/path
@madrobby
madrobby / gist:5489174
Created Apr 30, 2013
Install Phantom.js on Ubuntu 10.04 and tweak for better rendering quality.
View gist:5489174
sudo apt-get update
sudo apt-get install libfreetype6 libfreetype6-dev libfontconfig
# /etc/apt/sources.list should contain these:
# deb http://us.archive.ubuntu.com/ubuntu/ lucid multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ lucid multiverse
# deb http://us.archive.ubuntu.com/ubuntu/ lucid-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ lucid-updates multiverse
sudo echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
View gist:5329c625888fa1065b33
<style>
div {
width: 300px;
height: 400px;
position: absolute;
left:50%;
margin-left:-150px;
background: url('data:image/jpg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAoHBwcIBwoICAoOCQgJDhENCgoNERQQEBEQEBQTDxEQEBEPExMXFxkXFxMeHiAgHh4sKysrLDExMTExMTExMTH/2wBDAQsJCQsMCw0LCw0RDg4OERQODg4OFBgQEBEQEBgeFhMTExMWHhsdGRkZHRshIR4eISEpKSgpKTExMTExMTExMTH/wgARCAGQASwDASIAAhEBAxEB/8QAHAAAAQUBAQEAAAAAAAAAAAAAAgABAwQFBgcI/9oACAEBAAAAAOWseh5mtrV+a2YfHx6R9e1q95keZh6k1Dr8jaBpHhpQbar+d+N6fs9Lyj2rVo4tPyU+ty9frS7LC81i9hyanWQ7NWhPJNh3NpNX+YpvRO48f77aHl280i6OK9tTelZ/ktT2vmtDeySqRX2t40NyHEi5el1Hp3kk/U4HPXcbC2H6Krpeory2v6zz1vQ4avqWd/K6nnumnzA1/n3k+m9h8k7Opg0rk8xz2LQ2npgnnDOkt3NqDo6u2uZ6WDw2C76TxudZ2LTNGTPLZjTysDSEVerVt6G/rLkdDguMS9gwpSEAJ3mKLU1sR7xxwwnIE8Vatr9Q+blcnyVOafT39OOuSFHo6Fis19sm1Ll1IbW7chxqXZzhy2dy5ZFuxhUrF+7pWdEbG7rV5U+VoAqFeVuZ5rB6j2B8znsKGWply6urJmZehVw6TBLoa2pl2JgJp7efhWbNj06HDwavnlIt+1asSyyS2JZ5Yq0YWqFmUHJDXpxw2PUaXLZtrzS1cFWJppZJCc3JE5IhdOKrVYoNnu+doNhcoG5Zwb1iaQzMykYk5sTIkLU69Wv0t6tz2vgYMW72nn
View gist:1182372
<a href="javascript:$('#footer,#impact_legend,#caption,.pagehead,#header').hide(),$('#main').css({background:'#fff'}),$('#impact_graph').css({overflow:'visible',border:0,margin:0,padding:0,width:'auto'}),$('.site').css({width:'auto',margin:'0'})">GH impact graph whole page</a>
View escapeHTML.js
function escapeHTML(s,r){r='replace';return s[r](/&/g,'&amp;')[r](/>/g,'&gt;')[r](/</g,'&lt;')}
@madrobby
madrobby / gist:3161015
Created Jul 22, 2012
Detect retina support. Tested on iOS, Android 2.x, Chrome for Android, Safari on MacBook Pro Retina, Firefox mobile (beta) for Android, Opera Mobile (Android)
View gist:3161015
function isRetina(){
return (('devicePixelRatio' in window && devicePixelRatio > 1) ||
('matchMedia' in window && matchMedia("(min-resolution:144dpi)").matches))
}
View gist:2282429
<script>
document.write('<script src=' +
('__proto__' in {} ? 'zepto' : 'jquery') +
'.js><\/script>')
</script>
@madrobby
madrobby / gist:3733875
Created Sep 16, 2012
Fade out elements on WebKit and Firefox
View gist:3733875
<style>
.fade-right {
-webkit-mask-image: -webkit-gradient(linear, left top, right top, from(rgba(0,0,0,1)), color-stop(0.75, rgba(0,0,0,1)), to(rgba(0,0,0,0)));
mask: url(#fade_right_svg_mask);
}
#mask_demo {
background: #d0d0d0;
height: 100px;
width: 500px;
padding: 10px;
View extreme.html
<h1>Demo code for "Extreme JavaScript Performance" @ JSConf.eu</h1>
<script>
var benchmark = function(m,i){
var d1 = new Date, d2, r;
while(i--) r = m();
d2 = new Date;
console.log(d2.getTime()-d1.getTime());
// if(r) console.log(r);
}
@madrobby
madrobby / gist:3906580
Created Oct 17, 2012
CSS background from hell
View gist:3906580
position: relative;
display: block;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 100%;
height: 50px;
border-radius: 0px;
border-bottom-right-radius: 10px;