Skip to content

Instantly share code, notes, and snippets.

View jakearchibald's full-sized avatar
💭
Tired

Jake Archibald jakearchibald

💭
Tired
View GitHub Profile
@jakearchibald
jakearchibald / gist:1168514
Created August 24, 2011 16:49
Preventing images & other media downloading
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<script id="whatever">document.write('<!'+'--')</script>
<img src="filth.jpg" />
<!---->
<script>
// filth.jpg will start loading now for users without js.
alias gs='git status'
alias gai='git add --interactive'
alias gsvn='git svn'
alias gsup='gsvn fetch && gsvn rebase'
alias gsp='gsup && gsvn dcommit'
alias gf='git fetch'
alias gr='git rebase'
alias gp='gup && git push'
alias gff='git flow feature'
alias gfr='git flow release'
@jakearchibald
jakearchibald / gist:1004177
Created June 2, 2011 09:40
Twitter widgets
(function(document){
var script = 'script',
twitterWidgets = document.createElement(script),
lastScript = document.getElementsByTagName(script)[0];
twitterWidgets.async = twitterWidgets.src = 'http://platform.twitter.com/widgets.js';
lastScript.parentNode.insertBefore(twitterWidgets, lastScript);
})(document);
// compressed 177 bytes
.whatever {
-webkit-box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
-moz-box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
-o-box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
box-shadow: 0 2px 2px rgba(0,0,0,0.5) inset;
}
var something = 'blah',
whatever = 'spaces, to make the var names line up';
if (something) {
console.log("tabbed, to indicate it's a child of a code block");
}
// But I tend to use 4 spaces when coding in python, as that's what the python
// expert I work with does.
@jakearchibald
jakearchibald / gist:909640
Created April 8, 2011 11:00
Experimenting with IE support
<!--[if IE 8]><meta http-equiv="X-UA-Compatible" content="IE=7"/><![endif]-->
<!--[if gt IE 8]><meta http-equiv="X-UA-Compatible" content="IE=edge"/><![endif]-->
I've been experimenting with this in a couple of projects.
For animations, IE8 compat mode is noticeably quicker/smoother than
IE8 strict. Since I still give 'full' support to IE7 (barring the
odd text-shadow etc which IE8 doesn't support anyway) I use the tags
above to push IE8 into compat mode for smoother animations, but allow
the much faster IE9 to try its standardsy best.
/**
* @private
* @function
* @description Get a supported css property name for a css property
* Will search common vendor prefixes for supported value.
*
* @param {string} propertyName Name without any prefix
*
* @return {string} Supported property name.
* This will be an empty string for unsupported properties.
function asyncQueue(/* function, function, ... */) {
var slice = Array.prototype.slice,
funcs = slice.call(arguments, 0),
baseArgs = [function() {
next(arguments);
}],
next = function(args) {
var nextFunc = funcs.shift();
nextFunc && nextFunc.apply(
this, baseArgs.concat( slice.call(args, 0) )
function asyncQueue(/* function, function, ... */) {
var slice = Array.prototype.slice,
funcs = slice.call(arguments, 0),
baseArgs = [function() {
next(arguments);
}],
next = function(args) {
var nextFunc = funcs.shift();
nextFunc && nextFunc.apply(
this, baseArgs.concat( slice.call(args, 0) )
function asyncQueue(/* function, function, ... */) {
var funcs = Array.prototype.slice.call(arguments, 0),
baseArgs = [function() {
next(arguments);
}],
next = function(args) {
var nextFunc = funcs.shift();
nextFunc && nextFunc.apply( this, baseArgs.concat(args) );
};
next();