Skip to content

Instantly share code, notes, and snippets.

@msure
msure / testing_mysql_queries.py
Created October 16, 2015 21:08
Alternative MySQL Querying
import json
import mysql.connector
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
# p as path, c as connection
with open('/Users/path/to/database/keys/prod_db.json') as p:
c = json.load(p)
p.close()
@msure
msure / test_jquery.js
Created August 19, 2015 21:37
Test to confirm Google Tag Manager no longer has access to JQuery
<script>
console.log("outside test function");
+function ($) {
console.log("inside test function");
if (typeof $ == 'undefined') {
console.log("no jquery!");
} else {
console.log("test function made it past check!");
}
}(window.jQuery);
import pandas as pd
import numpy as np
from sqlalchemy import create_engine
# what is the database equivalent of 'hello world' anyways?
test_query = """
SELECT COUNT(*)
FROM core.users a
WHERE a.date BETWEEN '2015-01-01' AND '2015-05-31'
GROUP BY 1
@msure
msure / gist:385c023e7a8050a97044
Last active August 29, 2015 14:22
Accessing Google Analytic's Real-Time API
from apiclient import errors
from apiclient.discovery import build
from oauth2client.client import OAuth2WebServerFlow
import httplib2
import json
# easy access to account/view/property when using multiple accounts (e.g., ios app, android app, website)
with open('/Users/adrianp/py/json/ga_cred.json') as p:
gc = json.load(p)
p.close()
@msure
msure / yum_cookies.js
Last active December 4, 2015 17:27
Examine cookie names/values for a website
function getCookies(cooksName) {
var cooks = document.cookie.split(';')
var cooksInTheKitchen = {}
cooks.forEach(function(i) {
var name = unescape(i.match(/^\s*([^=]+)/m)[1])
var value = unescape(i.match(/=(.*$)/m)[1])
if (cooksInTheKitchen[name] !== undefined) {
console.log("Trying to retrieve cookie named(" + name + "). There appears to be another property with this name though.");
}
cooksInTheKitchen[name] = value
@msure
msure / the_times_they_are_a_changin
Last active August 29, 2015 14:11
Console.log changes to Google Tag Manager's dataLayer (works in Chrome)
/*
*
* Pop this puppy into your Chrome console on a page where you need to observe changes to the dataLayer
* http://updates.html5rocks.com/2012/11/Respond-to-change-with-Object-observe
*
*/
function chaChaChaChaChanges(changes) {
n = dataLayer.length-1;
console.dir(dataLayer[n]);