Skip to content

Instantly share code, notes, and snippets.

@olivierlacan
olivierlacan / cleverButton.css.sass
Created August 6, 2011 22:34
cleverButton Sass mixin for Compass
// ##### cleverButton #####
// # Version: 0.3
// # Description: Sass mixin for Compass to create fully styled buttons.
// # Notes: this mixin uses Compass mixin, see http://compass-style.org for
// # installation instructions.
// # Authors: Olivier Lacan, Andrew Smith
// ### changelog
// # v0.1: July 2010, initial version
// # v0.2: Added edge extendable edge styles
// # v0.3: Added Compass CSS3 mixins for reduced code & better browser support
@peol
peol / relative-time-duration.js
Created August 5, 2011 16:19
Small, versatile relative time/duration function
/**
* Copyright(c) 2011 Andrée Hansson
* @peolanha
* http://github.com/peol
*
* License: Do whatever you want, some attribution would be nice
*
* Small, versatile relative time function, options:
* asArray: Returns the data in an array, each entry has [0] = number, [1] = string representation
* filterValues: Removes all entries with 0 as value
@addyosmani
addyosmani / visibly.js
Created August 3, 2011 12:44
Cross-browser Page Visibility API polyfill
/*!
* isVis - v0.5.5 Aug 2011 - Page Visibility API Polyfill
* Copyright (c) 2011 Addy Osmani
* Dual licensed under the MIT and GPL licenses.
*/
(function () {
window.visibly = {
b: null,
q: document,
@nzakas
nzakas / gist:1119343
Created August 2, 2011 00:38
Autofocus shim
<!-- autofocus shim for older browsers that doesn't impact newer ones -->
<input type="text" name="q" id="q" autofocus>
<script>
(function(textbox){
if (textbox.autofocus !== true){
textbox.focus();
}
})(document.getElementById("q"));
</script>
@charlesroper
charlesroper / 1. input.scss
Created July 29, 2011 09:58
Responsive Web Design with Sass (SCSS syntax)
@function pxem($pxval, $base: 16px) {
// Function to take a pixel value and divide it by a base value in order to
// return the size in ems. Default base value is 16px
@return ($pxval / $base) * 1em; // multiply by 1em to convert px to ems.
}
body {
background-color: #DCDBD9;
color: #2C2C2C;
font: normal 100% Cambria, Georgia, serif;
@ded
ded / parallel.js
Created July 21, 2011 01:10
call multiple async methods in parallel and receive the result in a callback
function parallel() {
var args = Array.apply(null, arguments)
, callback = args.pop()
, returns = []
, len = 0
args.forEach(function (el, i) {
el(function () {
var a = Array.apply(null, arguments)
, e = a.shift()
if (e) return callback(e)
@tcr
tcr / async.coffee
Created July 18, 2011 21:13
Serial/Parallel functions in CoffeeScript
# Asynchronous DSL for CoffeeScript
serial = (f) ->
next = -> arr.shift().apply(null, arguments) if arr.length
arr = (v for k, v of f(next))
next()
null
parallel = (f, after = ->) ->
res = {}; arrc = 0
@scottjehl
scottjehl / jqm-self-init-a-widget.js
Created July 8, 2011 14:29
Self-init a jQuery Mobile plugin
// First, let's define a widget/plugin called "foo"
// Either using jQuery's $.fn plugin namespace, for simple stateless plugins...
$.fn.foo = function(){
// In this scope, this refers to the element on which the plugin foo() was called
// manipulate it and return this at the end, so it can be chainable
};
@madrobby
madrobby / delayed_hover.js
Created July 5, 2011 19:45
Little Zepto "delayed hover" plugin, using this with backbone.js events
// (c) 2011 Thomas Fuchs
(function($){
$.fn.delayedHover = function(){
var timeout = null, hovering = false, element = this;
function enter(){
element.trigger('delayed_hover:enter');
timeout = null;
hovering = true;
@kayluhb
kayluhb / README
Last active August 31, 2017 23:59 — forked from joelambert/README
Drop in replacements for setTimeout()/setInterval() that makes use of requestAnimationFrame() where possible for better performance
Drop in replace functions for setTimeout() & setInterval() that
make use of requestAnimationFrame() for performance where available