View posit.js
function posit( x, positivity ){
return x * ( positivity * 2 - 1 );
}
View jquery.sel.js
// Selects the text of the scoped element.
// Courtesy of @jcubic: http://stackoverflow.com/a/21829549/356541
$.fn.sel = function selectText() {
var node = this[0];
if ( document.body.createTextRange ) {
var range = document.body.createTextRange();
range.moveToElementText( node);
range.select();
} else if ( window.getSelection ) {
View foobar.json
{
"foo" : "bar"
}
View commented.json
{
"" : "// Start Zepto ",
"zepto" : "../../lib/zepto/zepto",
"zepto-extras" : "../../lib/zepto/zepto-extras",
"zepto-slide-transition" : "../../lib/zepto/zepto-slide-transition",
"zepto-fx-methods" : "../../lib/zepto/zepto-fx-methods",
"" : "// End Zepto ",
"" : "// Start jQuery ",
"jquery" : "../../lib/jquery/jquery-1.10.2",
View target.support.js
// Determine whether or not we need to run fallback code by testing for `:target` support.
var targetSupport = ( function targetSupport(){
var iframe = document.createElement( 'iframe' );
var body = document.getElementsByTagName( 'body' )[ 0 ];
var doc;
var outcome;
iframe.tabindex = -1;
iframe.style.display = 'none';
View jquery.csi.js
jQuery.csi = function csi( context ){
$( '[data-include]', context || document ).each( function fetchPartial(){
var $placeholder = $( this );
var location = $placeholder.attr( 'data-include' );
$.ajax( { url : location, async : false } ).done( function injectPartial( response ){
var $partial = $( response );
csi( $partial );
View increase-specificity.scss
// Increase class-level specificity of a rule without functionaly modifying the selector
@mixin increase-specificity( $depth: 1 ) {
$sel : '';
@while($depth > 0) {
$sel : $sel + ':nth-child(n)';
$depth : $depth - 1;
}
&#{$sel} {
View gist:11288260
function getParentStructure( el ){
var $el = $( el );
var indent = '';
var output = '';
_.chain( $el.parents() ).reverse().map( function convertToString( parent ){
var attributes = parent.attributes;
output += indent + '<' + parent.tagName.toLowerCase();
View returner.js
// returner is a convenience function that allows you to invoke mutator methods on arrays (or anything else)
// and return the mutated array itself rather than some arbitrary property of that array.
//
// Why?
// I have never been convenienced by the returned length of an array after pushing to it.
// I have often wanted to push to an array and return it with the same statement.
//
// Seriously? Like, when?
// Can I use a word in its own definition? At line 27, I want to modify an array and return it.
// Thanks to returner, I'm evaluating that as a function argument expression.
View _.superMerge.js
_.mixin( {
// Like uniq, but tests for equivalence rather than identity.
// Does this by running comparison on stringified representations.
// DOM nodes and other objects with circular references can't be stringified and will break.
looseUniq : function uniqBasedOnStringify( source ){
var output = _( source )
.map( function stringify( x ){ return JSON.stringify( x ); } )
.uniq()
.map( function parse( x ){ return JSON.parse( x ); } )
.valueOf();