Skip to content

Instantly share code, notes, and snippets.

View lonekorean's full-sized avatar

Will Boyd lonekorean

View GitHub Profile
@lonekorean
lonekorean / gist:8049462
Last active December 31, 2015 21:49
Suppress assets pop up on CodePen
document.querySelector('html').ondragenter = function(e) {
e.stopPropagation();
return false;
};
document.querySelector('html').ondragover = function(e) {
e.stopPropagation();
return false;
};
@lonekorean
lonekorean / gist:8049470
Last active December 31, 2015 21:49
Suppress assets pop up on CodePen (jQuery edition)
$('html').on('dragenter dragover', function(e) {
e.stopPropagation();
});
@lonekorean
lonekorean / gist:8278639
Last active January 2, 2016 08:49
Concise string checking
// assuming str is used to hold a string
if (str !== undefined && str !== null && str.length > 0) {
console.log('str is a non-empty string');
}
if (str) {
console.log('str is a non-empty string');
}
@lonekorean
lonekorean / gist:8278642
Last active January 2, 2016 08:49
Feature detection
if (window.File) {
console.log('your browser supports the File API');
}
@lonekorean
lonekorean / gist:8278646
Last active January 2, 2016 08:49
Or with falsey and truthy values
if (41 === 'potato' || window.File) {
console.log('reality is melting and the number 41 is now a potato, or your browser supports the File API');
}
@lonekorean
lonekorean / gist:8278651
Last active April 21, 2023 07:36
Null coalescing
var obj = incomingObj || {};
@lonekorean
lonekorean / gist:8278654
Last active October 3, 2016 00:49
Chained null coalescing
var obj = firstChoiceObj || secondChoiceObj || thirdChoiceObj || {};
@lonekorean
lonekorean / gist:8754808
Last active August 29, 2015 13:55
Git stash save
git stash save "I'll come back to this later"
@lonekorean
lonekorean / gist:8754813
Last active August 29, 2015 13:55
Git stash list
git stash list
@lonekorean
lonekorean / gist:8754822
Last active August 29, 2015 13:55
Git stash list output
stash@{0}: On branch1: Adding more ponies to site footer
stash@{1}: On branch1: Tightening up the graphics on level 3
stash@{2}: On branch2: I'll come back to this later