Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

var variation = getABTestVariation( 'silverPlan' );
POPULATION_SIZE = 50
NUM_BITS = 64
GENERATIONS = 1000
SAMPLE_SIZE = 100
CROSSOVER_PROBABILITY = 0.7
MUTATION_RATE = 0.001
class Chromosome
@mattm
mattm / gist:1633149
Created January 18, 2012 14:07
Calling Big Huge Thesaurus's API with jQuery
$.ajax({
url : "http://words.bighugelabs.com/api/2/youapikey/" + word + "/json?callback=?",
dataType : 'json',
complete : function(jqXHR, textStatus) {
if (textStatus == 'parsererror') {
// Did not find any synonyms
alert("404 error because no synonyms exist for this word");
}
},
success : function(data) {
mixpanel.track( 'Visited Homepage', { abtest_name: 'homepage test 3', abtest_variation: 'white' } );
mixpanel.track( 'Visited Homepage', { abtest_variation: 'white' } );
analytics.tracks.recordEvent( 'calypso_abtest_start', { abtest_name: this.experimentId, abtest_variation: variation } );
mixpanel.track( 'Assigned Variation', { abtest_name: 'homepage test 3', abtest_variation: 'white' } );
ORIGINAL_CONVERSION_RATE = 0.1
VARIATION_OUTCOMES = [-0.2, 0.2]
return "pass" if total_participants >= 10000
if gaussian?(participants_a, conversions_a) && gaussian?(participants_b, conversions_b)
if p_value(participants_a, conversions_a, participants_b, conversions_b) >= 0.99
return "yes"
end
end
@mattm
mattm / homepage-scroll-tracking.js
Last active September 5, 2016 18:15
Track how far down your site's homepage visitors scroll
// This code assumes that each section of your homepage uses a "section" tag
// and each one has an id corresponding to its purpose: "testimonials", "pricing", etc
( function() {
var viewedSections = [];
$( window ).on( 'scroll', function() {
$( 'section' ).each( function() {
var sectionName = $( this ).attr( 'id' );
var distanceToTopOfViewport = this.getBoundingClientRect().top;
if ( sectionName && distanceToTopOfViewport < 600 ) {