Skip to content

Instantly share code, notes, and snippets.

View hussainm's full-sized avatar

Hussain hussainm

View GitHub Profile
@hussainm
hussainm / test
Created September 18, 2018 12:07
test
function getAccounts() {
var accountList = TagManager.Accounts.list();
for (var i = 0;i < accountList.account.length;i++) {
//if (accountList.account[i].accountId > 123456) { //if you reach a timeout, resume by manually updating this and re-running
getContainers(accountList.account[i].accountId,accountList.account[i].name);
Utilities.sleep(5000); //GTM only allows 25 queries per 100 seconds, so we have to slow it down
//}
}
}
@hussainm
hussainm / segment_mixpanel_first__last_utm
Created May 27, 2016 13:12
track first and last utms in mixpanel using segment
<script type="text/javascript">
analytics.ready(function(){
function getQueryParam(url, param) {
// Expects a raw URL
param = param.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + param + "=([^&#]*)",
regex = new RegExp( regexS ),
results = regex.exec(url);
if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
return '';
@hussainm
hussainm / timezone.js
Created August 23, 2014 14:16
timezone by country javascript object. This contains list of countries and their timezone offsets in the form of a js object countries with multiple timezones the average offset is used. csv from: www.theguardian.com/news/datablog/2009/sep/14/time-zones-countries-world-gmt
var timezoneByCountry = {
"Afghanistan": 4.5,
"Albania": 1,
"Algeria": 1,
"Andorra": 1,
"Angola": 1,
"Antigua and Barbuda": -4,
"Argentina": -3,
"Armenia": 4,
"Australia": 8,
@hussainm
hussainm / userscript_unblock_youtube_pakistan.js
Created June 8, 2014 15:11
Unblock youtube in pakistan by redirecting youtube links through playit.pk This userscript can be used on all browsers using monkeyscript / tampermonkey extensions
// ==UserScript==
// @name Unblock youtube in Pakistan
// @namespace YoutubePakistan
// @version 0.1
// @description This script rewrites all youtube links
// @match *://*/*
// @copyright 2012+, You
// ==/UserScript==
@hussainm
hussainm / split_sheet_by_column_excel_macro.vbs
Last active August 29, 2015 14:01
Excel VBA macro to Split Sheet into Multiple sheets based on column value Adapted from http://en.kioskea.net/faq/7053-excel-macro-to-create-new-workbook-and-copy-data By @mashhoodr @hu_me from MarketLytics
' Split Sheet into Multiple sheets based on column value
' Adapted from http://en.kioskea.net/faq/7053-excel-macro-to-create-new-workbook-and-copy-data
Sub details()
Dim thisWB As String
Dim newWB As String
thisWB = ActiveWorkbook.Name
@hussainm
hussainm / kissmetrics_segment_by_hostname.js
Last active January 3, 2016 10:59
Have KISSmetrics installed on multiple domains? want to see visits and conversion rate for each domain? Now you can this script fires an event whenever a user visits one of your domains. Will showup in KM as an event: Visited yourdomain1.com
// Segment Visitors by hostname
jQuery(document).ready(function(){
var refKm = document.referrer;
var hostKm = document.location.hostname;
// checks if visitor is from a different referrer
if((hostKm.length > refKm.length && hostKm.indexOf(refKm) === -1) ||
refKm.indexOf(hostKm) === -1)
{
_kmq.push(['record', 'Visited '+ hostKm]);
@hussainm
hussainm / Merge Excel Two Sheet based on common column
Created November 8, 2013 11:46
VBA script to combine two excel sheets based on a column. Quick and very dirty script to join two sheets in a one to one mapping based on a common column.
Public Const sheet1 As String = "magento1" 'primary sheet
Public Const sheet2 As String = "ga" 'secondary sheet
Public Const keyCol As String = "A" 'column to use as key
Public Const sheet1ColEnd As String = "H" 'column to start appending data
Sub MergeSheet()
Dim id1, id2 As String
Dim sheet1Loop, sheet2Loop As Integer
sheet1Loop = 2