Skip to content

Instantly share code, notes, and snippets.

View genejones's full-sized avatar

Gene Jones genejones

  • Atlanta
View GitHub Profile
@genejones
genejones / detect-private-browsing.js
Created May 29, 2016 18:56 — forked from cou929/detect-private-browsing.js
Detect private browsing mode (InPrivate Browsing or Incognito).
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
@genejones
genejones / gist:7339539
Created November 6, 2013 16:41
Shows how nonce is generated + consumed.
siteCat.authorizeHeader = function(){
var nonce = guid.v1();
var time = moment.utc().format().replace('+00:00', 'Z');
var pass = this.generatePass(nonce, time, this.secret);
var token = {
"Username" : this.user,
"PasswordDigest": pass,
"Nonce": new Buffer(nonce).toString('base64'),
"Created": time,
}
@genejones
genejones / bookmarklet.js
Created October 23, 2013 17:26
Bookmarklet for DTM (Satellite) Rover. Updated for DTM transition.
javascript:(function(){if(window.__satellite_tool_loading){return;}window.__satellite_tool_loading=true;var head=document.getElementsByTagName('head')[0],path='https://dtm.adobe.com/assets/';window.__sdsat_path='https://dtm.adobe.com/';window.__sdsat_api_token='YourAPIToken';window.__sdsat_username='yourUserName';var widget={required_assets:[path+'satellite_html.js',path+'satelliteUtils.js'],assets_loaded:0,loadScript:function(src,cb){var script=document.createElement('script');script.type='text/javascript';script.src=src;script.onreadystatechange=function(){if(this.readyState==="loaded" || this.readyState==="complete"){cb();}};script.onload=cb;head.appendChild(script);},loadjQuery:function(){if('$' in window){window.temp$=window.$;}if('jQuery' in window && window.jQuery!==undefined){window.$jQuery=jQuery.noConflict(true);window.$=window.temp$;}widget.loadScript('https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',function(){var jq=jQuery.noConflict(true);window.j$=jq;window.jQuery=window.$jQuer
@genejones
genejones / setPosition.js
Last active December 16, 2015 20:09
Determine current location using HTML5 techniques.
//made with help from https://developer.mozilla.org/en-US/docs/DOM/window.navigator.geolocation.getCurrentPosition
function setPositionFromCurrent(){
//this requires HTML5
if (!!navigator.geolocation){
navigator.geolocation.getCurrentPosition(function (position){
var coords = position.coords;
console.log('Latitude : ' + coords.latitude);
console.log('Longitude: ' + coords.longitude);
window.lat = coords.latitude;
@genejones
genejones / gist:5416598
Created April 18, 2013 22:01
SnowPlow Tracking
<script type="text/javascript">
var _snaq = _snaq || [];
_snaq.push(['setCollectorCf', 'CLOUDFRONT SUBDOMAIN}}']);
_snaq.push(['trackPageView']);
_snaq.push(['enableLinkTracking']);
(function()
var sp = document.createElement('script'); sp.type = 'text/javascript'; sp.async = true; sp.defer = true;
sp.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://d1fc8wv8zag5ca.cloudfront.net/0.11.1/sp.js';
@genejones
genejones / mergeProperties.js
Created November 13, 2012 02:20
Converts object properties to arrays
function mergeProperties(inputArray, placeHolderValue){
//expects an array of objects
//each object has properties
//need to convert properties to arrays
//e.g. [{a:2, b:3, c:7}, {a:4, b:5}] -> [["a", "b", "c"], [2, 3, 7], [4, 5, 0]]
//any empty values should get set to ""
var allProperties = {};