Skip to content

Instantly share code, notes, and snippets.

@cowboy
cowboy / jquery.ba-istype.js
Created January 18, 2010 14:28
The Miller Device - jQuery Plugin
// based on http://zaa.ch/1q
$.isType = function( obj, type ) {
var opt = Object.prototype.toString,
result = opt.call( obj ).slice( 8, -1 ).toLowerCase();
if ( type === 'null' || type === 'undefined' ) {
type = type === 'null' ? opt.call( null ) : opt.call( undefined );
type = type.slice( 8, -1 ).toLowerCase();
}
// this is how I fixed IE6-8 crashing on
// dynamic insertion of at-rules inside
// stylesheets (for example @font-face)
// UPDATE:
// Fix by MS, move up the style insertion
// before the stylesheet rule manipulation
function setStyle(rules) {
var d = document,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Cross-browser kerning-pairs & ligatures</title>
<style>
body { font-family: sans-serif; background: #f4f3f3; color: rgba(40, 30, 0, 1); width: 500px; margin: 80px auto; padding: 0px; }
a { color: rgba(15, 10, 0, 0.8); text-decoration: none; border-bottom: 1px solid; padding: 1px 1px 0px; -webkit-transition: background 1s ease; }
a:hover { background: rgba(0, 220, 220, 0.2); }
p, li { line-height: 1.5; padding: 0em 1em 0em 0em; margin: 0em 0em 0.5em; }
@bramstein
bramstein / subpixel-word-spacing-detect.js
Last active September 5, 2015 07:34
Detect sub-pixel word- and letter-spacing.
var subpixelWordSpacing = false;
if (document.defaultView && document.defaultView.getComputedStyle) {
// Store the original word spacing on the document element
var originalWordSpacing = document.defaultView.getComputedStyle(document.documentElement, null).wordSpacing;
// Set the word-spacing to half a pixel
document.documentElement.style.wordSpacing = '0.5px';
// This will return either 0px or 1px if sub-pixel word-spacing is not supported, otherwise
<style>
@font-face {
font-family: 'foo';
/* this font only contains the glyphs 'f' & 'o' */
}
@font-face {
font-family: 'bar';
/* this font only contains the glyphs 'b', 'a' & 'r' */
}
.test {
build:
@echo "Combining files ..."
@cat \
js/dep/jquery.easing.js \
js/dep/jquery.jsonp.js \
js/dep/json2.js \
js/dep/toolbox.expose.js \
js/lib/jquery.transloadit2.js > build/jquery.transloadit2.js
@echo "Compiling with Closure REST API ..."
@curl \
@creationix
creationix / class.js
Created August 18, 2010 23:48
Port of my proto library, but doesn't mess with Object.prototype
// This is my proto library but without changing Object.prototype
// Then only sub-objects of Class have the special properties.
var Class = module.exports = Object.create(Object.prototype, {
// Implements a forEach much like the one for Array.prototype.forEach, but for
// any object.
forEach: {value: function forEach(callback, thisObject) {
var keys = Object.keys(this);
var length = keys.length;
for (var i = 0; i < length; i++) {
var key = keys[i];
//A somewhat conservative test for supporting characters.
//Actually, it's a test to see if the glyphs of two characters
//are identical. This tends to work, however, some implementations
//may instead replace the text with a box with the hex code
//and this wouldn't work in those cases. One way might be to detect
//the presence of a rectangular box, but that may cause issues with
//glyphs that are rectangluar boxes (eg. Mail symbol).
.antiantialias {
-webkit-transition: all 100000.0s linear;
-moz-transition: all 100000.0s linear;
-o-transition: all 100000.0s linear;
-transition: all 100000.0s linear;
-webkit-transform: translate(0px, 1px);
-moz-transform: translate(0px, 1px);
-o-transform: translate(0px, 1px);
transform: translate(0px, 1px);
}
@lenary
lenary / gitconfig.ini
Created February 18, 2011 01:21
a special excerpt of my gitconfig
$ git clone github:lenary/guides.git
Cloning into guides...
remote: Counting objects: 255, done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 255 (delta 111), reused 163 (delta 35)
Receiving objects: 100% (255/255), 1.49 MiB | 564 KiB/s, done.
Resolving deltas: 100% (111/111), done.
$ cd guides
$ git remote -v