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
@gfranko
gfranko / example.js
Created Feb 7, 2014
Make Entire Tocify TOC Visible
View example.js
$('#toc').tocify({
'showAndHideOnScroll': false
});
@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);
@gfranko
gfranko / index.js
Created Feb 10, 2014
requirebin sketch
View index.js
// Checks to see if any CSS rule using inline-block also includes the IE6 and IE7 inline-block hack
// If the IE hacks are not there, they are added
var css = require('css'),
_ = require('lodash'),
exampleCSS = '.example-selector { display: inline-block; }',
ast = css.parse(exampleCSS);
_.each(ast.stylesheet.rules, function(rule) {
fixIEBugs(rule);
});
@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),
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);
console.log('ast', ast);
@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 / 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 / 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 / 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);
}());
You can’t perform that action at this time.