Instantly share code, notes, and snippets.

View README.md

jquery.scrollLock.js

Useful for when a blocking user experience is needed (in my case, didn't want people unwittingly loosing their place by scrolling while a modal required their attention): $.scrollLock() locks the body in place, preventing scroll until it is unlocked.

// Locks the page if it's currently unlocked
$.scrollLock();

// ...or vice versa
View fileInput.css
.fileContainer {
overflow: hidden;
position: relative;
}
.fileContainer [type=file] {
cursor: inherit;
display: block;
font-size: 999px;
filter: alpha(opacity=0);
View jquery.notextSelector.js
/*
jQuery's ':empty' selector only returns true if the element contains no text node, or whose text node consists exclusively of zero or more spaces and tabs. This ':notext' selector will return true for elements whose text nodes can also contain line breaks (any whitespace character) and HTML comments.
*/
$.expr[':'].notext = function detectNoText(x){
return x.innerHTML && x.innerHTML.replace(/(<!--.*(?!-->))|\s+/g, '').length === 0
}
View Drizzle.md

Drizzle

Autumn is here again with its dismal days, and the sun is hiding himself in the darkest corner of the heavens so that no one shall see how pale and aged and worn he has grown in this latter time. But while the wind whistles in the window-chinks and the rain purls in the rainspouts and a wet dog howls in front of a closed gate down below on the street and before the fire has burned down in our tile stove, I will tell you a story about the drizzle. Listen now!

For some time back the good God had become so angered over the wickedness of men that he resolved to punish them by making them still wickeder. He should, in his great goodness, have liked above all things to have drowned them all together in a new Deluge: he had not forgotten how agreeable was the sight when all living creatures perished in the flood. But unfortunately in a sentimental moment he had promised Noah never to do so again.

"Harken, my friend I" he therefore said to the Devil one day. "You are assuredly no saint, but occasionall

View tabitha.js
// Source
const tabitha = (context = document) =>
[
...context.querySelectorAll('*')
]
.filter(element => {
const style =
window.getComputedStyle(element)
return (
View OffFocus.jsx
class OffFocus extends React.Component {
constructor(){
super()
const handler = e => {
if(
this.state.focused
&&
e.target.nodeType
&&
View drizzle.txt
THE DRIZZLE
AUTUMN is here again with its dismal days,
and the sun is hiding himself in the darkest
corner of the heavens so that no one shall see how
pale and aged and worn he has grown in this
latter time. But while the wind whistles in the
window-chinks and the rain purls in the rain-
View unfuckReact.js
const mounted = new WeakSet()
export default const unfucker = (component, displayName = component.displayName || component.name || 'React.Component') => {
const host = {
[displayName] : class extends React.Component {
constructor(){
this.state = {}
component.apply(this, arguments)
}
View Location.es6.min.js
export default x=>document.createElement('a').href=x
View html.loading.snippet.html
<script>
// add a class of 'loading' to the HTML, then remove it once the page has finished loading
(function(c){
c('scripted loading')
window.onload = function(){setTimeout(function(){
c(c().replace('loading',''))
},30)}
}(function(c){
var h = document.lastChild
return c ? h.className = c : h.className