Skip to content

Instantly share code, notes, and snippets.

.clearfix {
height: 1%; /* trigger hasLayout for IE < 8 */
}
.clearfix:before, .clearfix:after {
content: " ";
display: block;
height: 0;
visibility: hidden;
}
@kflorence
kflorence / exec.js
Created May 15, 2012 18:00
Call a function only if it is defined
var exec = (function(global) {
return function(name, args, context) {
var func = (context = context || global)[name];
return (typeof func != 'undefined') && func.apply(context, args);
};
})(this);
// Use like:
var timesTwo = function(x) {
return x * 2;
@kflorence
kflorence / scrollbarWidth.js
Created July 10, 2012 22:13
Calculate scroll bar width cross-browser
function getScrollBarWidth() {
var inner = document.createElement('p');
inner.style.width = "100%";
inner.style.height = "200px";
var outer = document.createElement('div');
outer.style.position = "absolute";
outer.style.top = "0px";
outer.style.left = "0px";
outer.style.visibility = "hidden";
@kflorence
kflorence / getType.js
Created August 29, 2012 05:06
Enhanced version of jQuery.type that will return class names for user generated Objects
var getType = (function() {
var rFunctionName = /function ([^(]+)/;
return function( object ) {
var matches,
type = $.type( object );
if ( type == "object" ) {
matches = rFunctionName.exec( object.constructor.toString() );
@kflorence
kflorence / namespacer.js
Last active December 10, 2015 10:58
A simple function for namespacing things like events and class names
// namespacer( "kf", [ "one", "two" ] );
// => { one: "one.kf", two: "two.kf" }
function namespacer( namespace, items, separator, before ) {
var i, item,
l = items.length,
namespaced = {};
if ( l && namespace ) {
if ( !separator ) {
separator = ".";
@kflorence
kflorence / join.js
Created January 1, 2013 01:08
Simple function for joining non-Array object properties
// join( { one: "one", two: "two" } );
// => "one,two"
function join( obj, separator ) {
var k,
items = [];
if ( typeof obj.join === "function" ) {
items = obj;
} else {
# Put this in ~/.bash_profile on your devbox
# Run it like: $ update-config
function update-config {
echo "Updating config..."
cd /usr/wikia/docroot
git pull --rebase
mkdir -p wiki.factory
ln -sf /usr/wikia/source/wiki/extensions/wikia/Development/Configs_DevBox/LocalSettings.php wiki.factory/LocalSettings.php
perl /usr/wikia/docroot/clinks.pl --source=/usr/wikia/source/wiki --docroot=/usr/wikia/docroot/wiki.factory
@kflorence
kflorence / .gitconfig
Last active April 26, 2018 20:42
Useful config settings
[alias]
br = branch
ci = commit
cl = clone
co = checkout
cp = cherry-pick
df = diff
lg = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
mg = merge --no-ff
pl = pull --rebase
@kflorence
kflorence / empx.js
Last active December 16, 2015 22:20
Convert from em to px and vice versa.
function unit( scope ) {
return parseInt( window.getComputedStyle( scope || document.body ).fontSize, 10 );
}
function pxToEm( px, scope ) {
return ( parseInt( px, 10 ) / unit( scope ) ).toFixed( 8 ) + 'em';
}
function emToPx( em, scope ) {
return Math.round( parseFloat( em ) * unit( scope ) ) + 'px';
@kflorence
kflorence / .jshintrc
Created August 22, 2013 21:37
Wikia .jshintrc
{
// Wikia .jshintrc
// Enforcing
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,