Skip to content

Instantly share code, notes, and snippets.

View qwertypants's full-sized avatar
🧶

Wilkins Fernandez qwertypants

🧶
View GitHub Profile
@qwertypants
qwertypants / is-it-loaded-yet.js
Created August 25, 2015 13:55
Fire an event when an window property is ready to be used. This assumes that an external script will add the new property on the window object.
// This uses Google tracking as an example
var interval = setInterval(function () {
console.log('searching..')
if (window._gaq) {
_gaq.push(['_trackPageview', 'Something']);
clearInterval(interval);
console.log('stop');
}
}, 10);
@qwertypants
qwertypants / popup.js
Created October 25, 2016 23:21
Popup window
/**
* Opens a new browser window
* @param {String} url The url of the window to open
* @param {String} name The name of this window
* @param {Number} width Window width
* @param {Number} height Window height */
const PopUpWindow = (url, name, width, height)=> {
// Center the window
let _width = width || 450,
_height = height || 300,
const glob = require('glob');
const jsFiles = glob.sync('src/**/*.js');
const tsFiles = glob.sync('src/**/*.ts');
const tsxFiles = glob.sync('src/**/*.tsx');
const allTsFiles = tsFiles.concat(tsxFiles);
console.log(`There are ${jsFiles.length} .js files in the 'src' directory.`);
console.log(`There are ${allTsFiles.length} .ts/x files in the 'src' directory.`);
console.log(`${Math.round((allTsFiles.length / jsFiles.length) * 100)}% of the files are TypeScript files.`);