Skip to content

Instantly share code, notes, and snippets.

View kolinw's full-sized avatar

Kolin Weidmann kolinw

View GitHub Profile
// ----------------------------------------------------------
// 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) {}
@chrisdickinson
chrisdickinson / smooth_sortable_animating.html
Created January 29, 2011 05:39
smoothly animate jquery sortable lists.
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
ul { float:left; margin-right:20px; }
body { color:white; font-family:Helvetica, sans-serif; text-shadow:1px 1px 1px rgba(0,0,0,0.2); }
ul { width:512px; overflow:hidden; border-radius:6px; }
@jasonwyatt
jasonwyatt / MySingleton.js
Created July 26, 2011 15:09
Singleton Pattern with Require JS
define(function(){
var instance = null;
function MySingleton(){
if(instance !== null){
throw new Error("Cannot instantiate more than one MySingleton, use MySingleton.getInstance()");
}
this.initialize();
}
@elebescond
elebescond / gist:1433137
Created December 5, 2011 10:24
Generate a pot template from a wordpress theme - xgettext
find . -iname "*.php" > /tmp/my_theme_file_list.txt
# new template
xgettext --from-code=utf-8 -d my_theme -f /tmp/my_theme_file_list.txt --keyword=__ -o languages/my_theme.pot
# update template
xgettext --from-code=utf-8 -d my_theme -j -f /tmp/my_theme_file_list.txt --keyword=__ -o languages/my_theme.pot
@elidupuis
elidupuis / handlebars-helpers.js
Last active December 7, 2021 02:24
Simple Handlebars.js helpers
/*! ******************************
Handlebars helpers
*******************************/
// debug helper
// usage: {{debug}} or {{debug someValue}}
// from: @commondream (http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/)
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
@gre
gre / easing.js
Last active April 30, 2024 04:58
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
@zachleat
zachleat / gist:2008932
Created March 9, 2012 21:56
Prevent zoom on focus
// * iOS zooms on form element focus. This script prevents that behavior.
// * <meta name="viewport" content="width=device-width,initial-scale=1">
// If you dynamically add a maximum-scale where no default exists,
// the value persists on the page even after removed from viewport.content.
// So if no maximum-scale is set, adds maximum-scale=10 on blur.
// If maximum-scale is set, reuses that original value.
// * <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=2.0,maximum-scale=1.0">
// second maximum-scale declaration will take precedence.
// * Will respect original maximum-scale, if set.
// * Works with int or float scale values.
@csswizardry
csswizardry / BEM-inuit.css.md
Created October 2, 2012 20:09
Thoughts on BEM for inuit.css

Bringing BEM to inuit.css

BEM is a methodology for naming and classifying CSS selectors in a way to make them a lot more strict, transparent and informative.

The naming convention follows this pattern:

.block{}
.block__element{}
.block--modifier{}
@brettz9
brettz9 / navigator.language.js
Last active January 3, 2019 17:19
navigator.language
// Defined: http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#navigatorlanguage
// with allowable values at http://www.ietf.org/rfc/bcp/bcp47.txt
// Note that the HTML spec suggests that anonymizing services return "en-US" by default for
// user privacy (so your app may wish to provide a means of changing the locale)
navigator.language = navigator.language ||
// IE 10 in IE8 mode on Windows 7 uses upper-case in
// navigator.userLanguage country codes but per
// http://msdn.microsoft.com/en-us/library/ie/ms533052.aspx (via
// http://msdn.microsoft.com/en-us/library/ie/ms534713.aspx), they
// appear to be in lower case, so we bring them into harmony with navigator.language.
@serkanyersen
serkanyersen / examples.js
Created September 29, 2013 21:57
Allows you to correctly extend existing models and views while utilizing the properties on the base object, also adds super class support
var Car = Backbone.Model.extend({
defaults:{
engine: 'gasoline',
hp: 0,
doors: 4,
color: 'generic'
},
engine: function(){
return 'Wroomm';
}