Skip to content

Instantly share code, notes, and snippets.

@stuwilli
stuwilli / gist:307b40d3e9605525e165
Last active August 29, 2015 14:10
Load external JS script
/**
* Import/include an additional script in the document head
* @param {string} src the source file
* @param {function} callback the callback function
*/
function importScript(src, callback) {
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', src);
@stuwilli
stuwilli / gist:0cc81d24f128d26fc3a8
Created December 9, 2014 15:21
js-beautify BBEdit Text Filter
#!/usr/local/bin/node
var beautify;
try {
beautify = require("/usr/local/lib/node_modules/js-beautify").js_beautify;
} catch(e) {
console.error("js-beautify is not found");
process.exit(e.code);
}
@stuwilli
stuwilli / brightcove-test.js
Created February 6, 2015 15:20
Test for existence of a Brightcove player
(function () {
if (typeof brightcove !== "undefined") {
if (Object.keys(brightcove.experiences).length !== 0) {
return true;
}
}
return false;
})();
@stuwilli
stuwilli / kickstart-fw-linktag.js
Last active August 29, 2015 14:20
Kickstart FW LinkTag From Head
(function() {
function kickStartLinkTag() {
if (typeof brightcove !== 'undefined') {
if (Object.keys(brightcove.experiences).length === 0) {
if (typeof AdOps !== 'undefined' && typeof AdOps.fw !== 'undefined') {
AdOps.fw.initLinkTag();
}
}
}
}
@stuwilli
stuwilli / ie-detect.js
Created May 6, 2015 12:48
IE Detection
function isIE () {
if (document.documentMode) {
return document.documentMode;
} else {
for (var i = 7; i > 0; i--) {
var div = document.createElement("div");
div.innerHTML = "<!--[if IE " + i + "]><span></span><![endif]-->";
if (div.getElementsByTagName("span").length) {
@stuwilli
stuwilli / has-ad-enabled-player.js
Last active August 29, 2015 14:21
Has Brightcove Ad Enabled Player
function hasAdEnabledPlayer() {
if (typeof brightcove !== 'undefined') {
try {
for (var k in brightcove.experiences) {
console.log('checking player ' + k);
if (brightcove.api.getExperience(k).modules.hasOwnProperty('advertising')) {
return true;
} else if (brightcove.getExperience(k).modules.hasOwnProperty('advertising')) {
return true;
}
@stuwilli
stuwilli / gist:b2359d8d2efc97160166
Last active August 29, 2015 14:21
Install PPAPI Debug in Chrome
Download and Install
#http://fpdownload.macromedia.com/pub/flashplayer/updaters/17/flashplayer_17_ppapi_debug.dmg
ln -s /Library/Internet\ Plug-Ins/PepperFlashPlayer/PepperFlashPlayer.plugin /Applications/Google\ Chrome.app/Contents/Versions/43.0.2357.81/Google\ Chrome\ Framework.framework/PepperFlashPlayer.plugin
ln -s /Library/Internet\ Plug-Ins/PepperFlashPlayer/PepperFlashPlayer.plugin /Applications/Google\ Chrome.app/Contents/Versions/44.0.2403.130/Google\ Chrome\ Framework.framework/Internet\ Plug-Ins/PepperFlash/PepperFlashPlayer.plugin
Path to Log
~/Library/Application\ Support/Google/Chrome/Default/Pepper\ Data/Shockwave\ Flash/WritableRoot/Logs/flashlog.txt
@stuwilli
stuwilli / gist:16c9a6aa8bdfcc12e0b5
Last active August 29, 2015 14:22
JS-XLSX Create Workook
var ws_name = 'SheetJS';
/* set up workbook objects -- some of these will not be required in the future */
var wb = {};
wb.Sheets = {};
wb.Props = {};
wb.SSF = {};
wb.SheetNames = [];
/* create worksheet: */
var ws = {}
@stuwilli
stuwilli / gist:483e94de00b762ab1ba4
Last active September 18, 2015 10:40
GPT Resize Freewheel Frame
<!--nosandbox-->
<div id='div-gpt-ad-1234567891234-728x90'></div><!-- change this elements id so it's unique -->
<script type="text/javascript">
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement("script");
gads.async = true;
gads.type = "text/javascript";
var useSSL = "https:" == document.location.protocol;
@stuwilli
stuwilli / mraid-template.html
Created July 31, 2015 14:58
MRAID Template
<script src="mraid.js"></script>
<script>
function redirect(){
mraid.open("");
}
function close() {
mraid.close();
}