Skip to content

Instantly share code, notes, and snippets.

🤑
Looking for work

Barney Carroll barneycarroll

🤑
Looking for work
Block or report user

Report or block barneycarroll

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@barneycarroll
barneycarroll / jquery.selectable.js
Last active Oct 11, 2015
Turn selectability on or off via jQuery
View jquery.selectable.js
// Selectability: pass true or false
// http://stackoverflow.com/questions/2700000/how-to-disable-text-selection-using-jquery
$.fn.selectable = (function _selectable(){
var values = [
// Off
['on', 'none', false],
// On
['off','text', $.noop]
];
View Preferences.sublime-settings
{
"ensure_newline_at_eof_on_save": true,
"font_size" : 10,
"tab_size" : 2
}
@barneycarroll
barneycarroll / dabblet.css
Created Nov 27, 2012
Fixing shitty WebKit text rendering for thin and quirky fonts
View dabblet.css
/**
* Fixing shitty WebKit text rendering for thin and quirky fonts
*/
html {
font-family: 'Quicksand';
font-size: 24px;
padding: 1em 5em;
-webkit-text-stroke-width: .25px;}
@barneycarroll
barneycarroll / utilities.js
Last active Dec 14, 2015
Quick and dirty methods for object cloning and comparison using the JSON parser
View utilities.js
// Create a copy of x without reference back to x
function clone(x){
return JSON.parse(JSON.stringify(x));
}
// Pass any number of arguments of non-function type. Returns true if they are all identical.
function areEqual(){
for(var i = 1, l = arguments.length, x = JSON.stringify(arguments[0]); i < arguments.length; ++i){
if(x !== JSON.stringify(arguments[i])){
return false;
@barneycarroll
barneycarroll / ieVersion.js
Last active Dec 14, 2015
Get your /h5bp/-like HTML classnames for IE versions dynamically. Useful if you don't have control of the raw markup as spat out by the server.
View ieVersion.js
// Optain classnames representing the IE rendering engine:
// Makes version-targetted CSS much cleaner
var sIEclass = (function determineIEversion(){
// A DOM element to run the test on
var oTest = document.createElement('test');
// A table matching tested versions to representative class string
var hVersions = {
"6" : "ie ltie10 ltie9 ltie8 ltie7 ie6",
"7" : "ie ltie10 ltie9 ltie8 ie7",
"8" : "ie ltie10 ltie9 ie8",
@barneycarroll
barneycarroll / fileInput.css
Last active Sep 1, 2019
Total input[type=file] style control with pure CSS. File type inputs are notoriously hard to style, due to different semi-serious style restrictions in the name of security (the argument being that a file input presents access to the user's private file system, and should as such always look unambiguously like what it is — redundant if you ask m…
View fileInput.css
.fileContainer {
overflow: hidden;
position: relative;
}
.fileContainer [type=file] {
cursor: inherit;
display: block;
font-size: 999px;
filter: alpha(opacity=0);
@barneycarroll
barneycarroll / mediaJQuery.css
Created Mar 26, 2013
Javascript to emulate media queries with event firing and HTML class toggling to avoid duplication, conflict & waste in native CSS implementation + JS feature dependency. Public version of a private gist created 2012-09-13T11:34:06Z
View mediaJQuery.css
/* Javascript to emulate media queries with events and HTML class toggling
* to avoid duplication, conflict & waste when implemented via
* native CSS implementation + JS feature dependency.
*
* Depends on jQuery and Cowboy's throttle / debounce plugin:
* https://github.com/cowboy/jquery-throttle-debounce
*/
(function(){
var options = {
@barneycarroll
barneycarroll / jquery.getLines.js
Last active Dec 29, 2015
Count the number of lines of text in a given element.
View jquery.getLines.js
void function $getLines($){
function countLines($element){
var lines = 0;
var greatestOffset = void 0;
$element.find('character').each(function(){
if(!greatestOffset || this.offsetTop > greatestOffset){
greatestOffset = this.offsetTop;
++lines;
}
@barneycarroll
barneycarroll / Location.es6.min.js
Last active Aug 24, 2018
An ultra-small URI parsing function that accepts a URI-like string & returns an object with all the string properties of the native Location object for that string. Works using native property detection, without received wisdom (ie dictionaries, inference, etc).
View Location.es6.min.js
export default x=>document.createElement('a').href=x
@barneycarroll
barneycarroll / later.js
Last active Dec 16, 2015
`setTimeout(fn, 0)` is a hack to defer calling `fn` til the synchronous stack has executed, and has many very useful applications — but there's a bit of cognitive overhead in ascertaining that `setTimeout` isn't being used as per its intended use case: this flummoxes novices especially, who may interpret this as a mistake. Is it worth abstractin…
View later.js
// functions passed to later will only execute once the stack has resolved.
function later(fn){
return setTimeout(fn,0);
}
void function executionScope(){
var x = 0;
console.log('Log 1: ' + x);
You can’t perform that action at this time.