This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.body.addEventListener('error', function(event) { | |
if ( event.target.nodeName.toLowerCase() == 'img' ) { | |
// an image on the page failed to load | |
} | |
}, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'init', 'gs_books_label_rename', 999 ); | |
/** | |
* Modify registered post type menu label | |
* | |
*/ | |
function gs_books_label_rename() { | |
global $wp_post_types; | |
$wp_post_types['gs_books']->labels->menu_name = __( 'Books', 'gs_books' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(doc) { | |
// Add touch device support for dropdown menu | |
if (('addEventListener' in doc) && ('querySelectorAll' in doc) && (('ontouchstart' in window) || ('onmsgesturechange' in window))) { | |
var menu_item_selector = '.the-menu > div > ul > li', | |
menu_items = doc.querySelectorAll(menu_item_selector), | |
touchStart; | |
// Set up touch start handler | |
touchStart = function() { | |
if (this.className.indexOf(' tapped') > -1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function run(generator) { | |
var iterator = generator(resume); | |
var data = null, yielded = false; | |
iterator.next(); | |
yielded = true; | |
check(); | |
function check() { | |
while (data && yielded) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
[options] | |
# webpack loaders | |
module.name_mapper='.*\.css$' -> '<PROJECT_ROOT>/flow/stub/css-modules.js' | |
module.name_mapper='.*\.\(svg\|png\|jpg\|gif\)$' -> '<PROJECT_ROOT>/flow/stub/url-loader.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// addEventListener polyfill IE6+ | |
!window.addEventListener && (function (window, document) { | |
function Event(e, element) { | |
var instance = this; | |
for (property in e) { | |
instance[property] = e[property]; | |
} | |
instance.currentTarget = element; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (c) 2014 Nate Cook, licensed under the MIT license | |
// | |
// Fisher-Yates shuffle as top-level functions and array extension methods | |
/// Shuffle the elements of `list`. | |
func shuffle<C: MutableCollectionType where C.Index == Int>(inout list: C) { | |
let c = count(list) | |
for i in 0..<(c - 1) { | |
let j = Int(arc4random_uniform(UInt32(c - i))) + i | |
swap(&list[i], &list[j]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'), | |
gutil = require('gulp-util'), | |
sass = require('gulp-sass'), | |
rubysass = require('gulp-ruby-sass'), | |
fileinclude = require('gulp-file-include'), | |
rename = require('gulp-rename'), | |
notify = require('gulp-notify'), | |
livereload = require('gulp-livereload'), | |
lr = require('tiny-lr'), | |
connect = require('gulp-connect'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var key = localStorage.wpt_key; | |
if (!key) { | |
var prompt = window.__proto__.prompt; | |
key = prompt('Your WebPagetest API key, please?'); | |
if (!key) { | |
return gameOver(); | |
} | |
localStorage.wpt_key = key; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Straightforward + simple. | |
$("button").on("click", function(event) { | |
event.preventDefault(); | |
var button = $(this); | |
var numberElem = button.find(".number"); | |
var number = Number(numberElem.text()) - 1; | |
numberElem.text(number); | |
if (number === 0) { | |
button.prop("disabled", true); | |
button.off("click"); |
OlderNewer