Skip to content

Instantly share code, notes, and snippets.

@mnguyenngo
mnguyenngo / min_sample_size.py
Last active January 27, 2024 14:40
Determine Minimum Sample Size for A/B test
import scipy.stats as scs
def min_sample_size(bcr, mde, power=0.8, sig_level=0.05):
"""Returns the minimum sample size to set up a split test
Arguments:
bcr (float): probability of success for control, sometimes
referred to as baseline conversion rate
mde (float): minimum change in measurement between control
@simondahla
simondahla / track-downloads-with-universal-google-analytics.js
Created January 16, 2014 17:42
Track, downloads, email, external link clicks with Universal Google Analytics. Include this at the bottom of the desired page. Note: Requiers jQuery to work, include jQuery above this script.
if (typeof jQuery != 'undefined') {
jQuery(document).ready(function($) {
var filetypes = /\.(zip|exe|pdf|doc*|xls*|ppt*|mp3)$/i;
var baseHref = '';
if (jQuery('base').attr('href') != undefined)
baseHref = jQuery('base').attr('href');
jQuery('a').each(function() {
var href = jQuery(this).attr('href');
if (href && (href.match(/^https?\:/i)) && (!href.match(document.domain))) {
jQuery(this).click(function() {
@simondahla
simondahla / advertising.js
Last active January 3, 2016 11:58
Google Analytics Retargeting and Demographics and Interests reports for AdWords and AdBlock software with regular (Google Analytics Classic) fallback.
/* Add this in the top of your advertising script */
_adblock = false;
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter