Skip to content

Instantly share code, notes, and snippets.

@vmysla
vmysla / gist:0eb5c248cfb7f7b017ef
Created July 16, 2015 13:32
Snippet Load method randomization
console.clear();
// localStorage.setItem('rr', 'alert(1)' )
localStorage.setItem('rr', '' );
(function rr(cb, now, obj,attr,val, ls, ver){
//obj[ ver = (now & 1) ] [ ( attr[ ver<<1 || eval( ls && ls.getItem( val[0] ) || (now>>1 & 1) ) ] ) ]= val[ver];
console.log( obj[ ver = (now & 1) ] +'["' + ( attr[ ver<<1 || eval( ls && ls.getItem( val[0] ) || (now>>1 & 1) ) ] ) + '"]="' + val[ver]+'"');
})( 0, Date.now(), ['window', 'document.scripts[0]'], ['onload' , 'onscroll', 'src'], ['rr', '//rastabacher.com/'], this.localStorage
);
(function(signal){
signal({
colors : 9,
ttl : 1000,
latency : 250
});
})(function(conf){
@vmysla
vmysla / gist:8da3c5d0e849247885c4
Created June 8, 2015 09:40
Tracking GA clientID as custom Dimension
ga(function(tracker){
var cid = tracker.get('clientId');
tracker.set('dimension31', cid);
})
@vmysla
vmysla / gist:5ee9f0e8cecbd12c7234
Last active October 19, 2018 07:26
Monitoring AJAX calls to API with GA reporting for Timing and Errors
// ...
function ajaxRequest(url, done, error){ ... }
//...
realAjaxRequest = ajaxRequest;
ajaxRequest = monitoredAjaxRequest;
function monitoredAjaxRequest(url, done, error){
@vmysla
vmysla / gist:2052f3846a6b6fbec1cd
Created May 16, 2015 01:42
jquery selector performance reports
var jqspm={
searchedObjects: {},
currentSelector: '',
finalSelector: '',
_utils: {
makeNewSelector: function(id, selector, finSelector) {
jqspm.currentSelector=selector;
jqspm.finalSelector=finSelector;
jqspm.searchedObjects[id]={
// stats.js - http://github.com/mrdoob/stats.js
var Stats = function() {
var l = Date.now(),
m = l,
g = 0,
n = Infinity,
o = 0,
h = 0,
p = Infinity,
q = 0,
@vmysla
vmysla / gist:8f040c6aa19a2635a2d5
Created April 3, 2015 23:17
jQuery Lookup element by text
function isTextNode(node){ return node.nodeType == 3 };
function hasTextContent(node, text){ return node.textContent.indexOf(text) >= 0 };
function hasTextNode(element, text){
return $(element).contents().filter(function(i,node){
return isTextNode(node) && hasTextContent(node, text);
}).length > 0;
}
function hasTextAttribute(node, text){
@vmysla
vmysla / gist:7edb1145e34417976a47
Last active August 29, 2015 14:11
SQL before / after
/*
/ __ )/ ____/ ____/ __ \/ __ \/ ____/
/ __ / __/ / /_ / / / / /_/ / __/
/ /_/ / /___/ __/ / /_/ / _, _/ /___
/_____/_____/_/ \____/_/ |_/_____/
*/
IF @ParentUserID = @ChildUserID
@vmysla
vmysla / gist:ffccf789044d2dda18b2
Created December 11, 2014 15:57
JavaScript for cookie-based Transaction Reporting (GA, Marine)
(function(){
var pixels = [];
pixels.push(function googleAnalytics(transaction){
ga('ec:setTransactionId', transaction.id);
...
ga('send', ... );
});
@vmysla
vmysla / designer.html
Last active August 29, 2015 14:08
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">