Skip to content

Instantly share code, notes, and snippets.

View sindresorhus's full-sized avatar

Sindre Sorhus sindresorhus

View GitHub Profile
@paulirish
paulirish / README.md
Created January 4, 2010 02:38
imagesLoaded() jquery plugin
@livingston
livingston / OptimizeForWeb.jsx
Created March 16, 2010 13:25
Photoshop Script for Optimizing Images for the Web - Saves images as optimized jpeg
// Photoshop Script for Optimizing Images for the Web - Saves images as optimized jpeg
// Written by: Livingston Samuel
// Version 1.0.0
// Required Adobe Photoshop CS 2 and above
//Enable double clicking on Mac Finder & Windows Explorer
#target Photoshop
//Bring app to front
app.bringToFront()
// find out what prefix this browser supports.
// usage: gimmePrefix('transform') // 'WebkitTransform'
// returns false if unsupported.
function gimmePrefix(prop){
var prefixes = ['Moz','Khtml','Webkit','O','ms'],
elem = document.createElement('div'),
upper = prop.charAt(0).toUpperCase() + prop.slice(1);
class JsonpResponse(HttpResponse):
def __init__(self, data, callback):
json_encoder = LazyEncoder(ensure_ascii=False)
json = json_encoder.encode(data)
jsonp = "%s(%s)" % (callback, json)
HttpResponse.__init__(
self, jsonp,
mimetype='application/json'
)
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@brantfaircloth
brantfaircloth / newpost.rb
Created October 3, 2010 07:23 — forked from al3x/newpost.rb
start jekyll post from commandline and stage
#!/usr/bin/ruby
# Create new jekyll post and open in textmate
# $ ruby _new.rb This is the title
# The arguments form the title
unless ARGV[0]
raise "Please provide a post title."
end
@cowboy
cowboy / jquery.ba-logselector.js
Created October 22, 2010 15:04
jQuery log selector: See what your selectors are selecting!
/*!
* jQuery log selector - v0.1pre - 6/2/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
// Log the selector used to select elements to each selected element,
/*!
* jQuery Tiny Pub/Sub - v0.X - 11/18/2010
* http://benalman.com/
*
* Original Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
* Made awesome by Rick Waldron
*
@Abizern
Abizern / update_git.py
Created January 11, 2011 10:25
Replace a Git installation in /usr/bin/ with symlinks to a preferred git installation.
#!/usr/bin/env python -tt
"""Xcode4 installs and expects to find a git installation at /usr/bin.
This is a pain if you want to control your own installation of git that
might be installed elsewhere. This script replaces the git files in
/usr/bin with symlinks to the preferred installation.
Update the 'src_directory' to the location of your preferred git installation.
"""
import sys