Skip to content

Instantly share code, notes, and snippets.

Greg Franko gfranko

Block or report user

Report or block gfranko

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
View replace-accent.js
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
@gfranko
gfranko / replayYouTubeVideo.js
Last active Aug 29, 2015
Replay YouTube Video
View replayYouTubeVideo.js
(function replayYouTubeVideo() {
var video = document.querySelector('.html5-main-video');
setInterval(function() {
if(video.currentTime === video.duration) {
video.currentTime = 0;
}
}, 5000);
}());
@gfranko
gfranko / webshot.phantom.js
Created May 30, 2014
node-webshot enhancement
View webshot.phantom.js
// 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);
}
@gfranko
gfranko / each.js
Created May 16, 2014
.each() JavaScript implementation
View each.js
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;
}
}
@gfranko
gfranko / debounce.js
Last active Aug 29, 2015
Debounce Implementation
View debounce.js
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 () {
@gfranko
gfranko / index.js
Created Feb 11, 2014
requirebin sketch
View index.js
// 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';
@gfranko
gfranko / index.js
Created Feb 11, 2014
requirebin sketch
View index.js
// 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'
@gfranko
gfranko / index.js
Created Feb 11, 2014
requirebin sketch
View index.js
// 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) {}
});
@gfranko
gfranko / index.js
Created Feb 11, 2014
requirebin sketch
View index.js
// Node.js Environment
var code = 'function jqcon() {}',
esprima = require('esprima'),
ast = esprima.parse(code);
console.log('ast', ast);
@gfranko
gfranko / index.js
Created Feb 10, 2014
requirebin sketch
View index.js
var esprima = require('esprima'),
estraverse = require('estraverse'),
escodegen = require('escodegen');
console.log('esprima', esprima);
console.log('estraverse', estraverse);
console.log('escodegen', escodegen);
You can’t perform that action at this time.