Brainstorming a friendlier find(1).
Goals:
var sprintf = function (text) { | |
var i = 1, args = arguments; | |
return text.replace(/%(0)?(\d*)?\.?(\d*)?(s|f)/g, function (pattern) { | |
var a = arguments, | |
precision = +a[3], | |
value = args[i++], | |
padSize = +a[2] - (~~value).toString().length, | |
padding = padSize > 0 ? (new Array(padSize + 1).join(a[1] || ' ')) : ''; | |
return padding + (a[4] === 'f' && a[3] ? value.toFixed(+precision) : value); | |
}); |
define({ | |
/* | |
* Simplified prototypal inheritance, see http://javascript.crockford.com/prototypal.html | |
*/ | |
create: function (obj){ | |
function F() {} | |
F.prototype = obj; | |
return new F(); | |
}, |
var has = function (obj, property) { | |
var tree = obj, | |
split = property.split('.'), | |
last = split.pop(); | |
while (next = split.shift()) { | |
tree = tree[next]; | |
if (tree === undefined) return false; | |
} |
//BSD Licensed | |
var YourGlobal = { | |
namespace: function(ns){ | |
var parts = ns.split("."), | |
object = this, | |
i, len; | |
for (i=0, len=parts.length; i < len; i++) { | |
if (!object[parts[i]]) { |
.fake_file_input { | |
background: url(../images/fake_file_input.png) no-repeat; | |
cursor: pointer; | |
width: 150px; | |
height: 30px; | |
overflow: hidden; | |
position: relative; | |
display: inline-block; | |
*display: inline; | |
*zoom: 1; |
var when = require('../when'); | |
// A test callback-based function | |
function callbackBased(value, callback, errback) { | |
setTimeout(function() { | |
(value ? callback : errback)(value); | |
}, 100); | |
} | |
function log(val) { |
// add your variants of | |
a ? b : c | |
// in comments :) | |
// a is boolean | |
// b and c - any type | |
// lazy evaluation isnt important |
@mixin cover-background( $path ) { | |
background-image: url( "../../" + $path ); | |
@include background-size( cover ); | |
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + $path + "', sizingMethod='scale')"; | |
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="", sizingMethod="scale"); | |
} |
/***************************************************************************** | |
* __ __ _ _ ___ _ | |
* \ \/ _\ /\/\ (_)_ __ | |_ _ _ / __\ __ ___ ___| |__ | |
* \ \ \ / \| | '_ \| __| | | | / _\| '__/ _ \/ __| '_ \ | |
* /\_/ /\ \ / /\/\ \ | | | | |_| |_| | / / | | | __/\__ \ | | | | |
* \___/\__/ \/ \/_|_| |_|\__|\__, | \/ |_| \___||___/_| |_| | |
* |___/ | |
* | |
* Identifying and Eliminating Code Smells | |
* |