View replace-accent.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
var accentMap = { | |
'à': 'a', 'á': 'a', 'â': 'a', 'ã': 'a', 'ä': 'a', 'å': 'a', // a | |
'ç': 'c', // c | |
'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e', // e | |
'ì': 'i', 'í': 'i', 'î': 'i', 'ï': 'i', // i | |
'ñ': 'n', // n | |
'ò': 'o', 'ó': 'o', 'ô': 'o', 'õ': 'o', 'ö': 'o', 'ø': 'o', // o | |
'ß': 's', // s | |
'ù': 'u', 'ú': 'u', 'û': 'u', 'ü': 'u', // u | |
'ÿ': 'y' // y |
View replayYouTubeVideo.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
(function replayYouTubeVideo() { | |
var video = document.querySelector('.html5-main-video'); | |
setInterval(function() { | |
if(video.currentTime === video.duration) { | |
video.currentTime = 0; | |
} | |
}, 5000); | |
}()); |
View webshot.phantom.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
// Handle customCSS option | |
if (typeof options.customCSS === 'string') { | |
page.evaluate(function(customCSS) { | |
var style = document.createElement('style'); | |
var text = document.createTextNode(customCSS); | |
style.setAttribute('type', 'text/css'); | |
style.appendChild(text); | |
document.head.insertBefore(style, document.head.firstChild); | |
}, options.customCSS); | |
} |
View each.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
function each (collection, callback) { | |
var x, len; | |
if(Utils.isArray(collection)) { | |
x = -1; | |
len = collection.length; | |
while(++x < len) { | |
if (callback(x, collection[x]) === false) { | |
break; | |
} | |
} |
View debounce.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
function debounce(func, wait) { | |
// we need to save these in the closure | |
var timeout, args, context, timestamp; | |
return function () { | |
// save details of latest call | |
context = this; | |
args = [].slice.call(arguments, 0); | |
timestamp = new Date(); | |
// this is where the magic happens | |
var later = function () { |
View index.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
// Node.js Environment | |
var code = 'function jqcon() {}', | |
esprima = require('esprima'), | |
ast = esprima.parse(code), | |
estraverse = require('estraverse'); | |
estraverse.traverse(ast, { | |
enter: function (node, parent) { | |
if(node.type === 'Identifier') { | |
node.name = node.name + '_is_awesome'; |
View index.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
// Node.js Environment | |
var code = 'function jqcon() {}', | |
esprima = require('esprima'), | |
ast = esprima.parse(code), | |
estraverse = require('estraverse'); | |
estraverse.replace(ast, { | |
enter: function (node, parent) { | |
if(node.type === 'Identifier' && node.name === 'jqcon') { | |
// Changes the 'jqcon' function name to 'jqcon_is_awesome' |
View index.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
// Node.js Environment | |
var code = 'function jqcon() {}', | |
esprima = require('esprima'), | |
ast = esprima.parse(code), | |
estraverse = require('estraverse'); | |
estraverse.traverse(ast, { | |
enter: function (node, parent) {}, | |
leave: function(node, parent) {} | |
}); |
View index.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
// Node.js Environment | |
var code = 'function jqcon() {}', | |
esprima = require('esprima'), | |
ast = esprima.parse(code); | |
console.log('ast', ast); |
View index.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
var esprima = require('esprima'), | |
estraverse = require('estraverse'), | |
escodegen = require('escodegen'); | |
console.log('esprima', esprima); | |
console.log('estraverse', estraverse); | |
console.log('escodegen', escodegen); |
NewerOlder