Skip to content

Instantly share code, notes, and snippets.

# current:
SELECT
experienceId as experiment_id,
variationMasterId as variation_master_id,
iterationId as iteration_id,
context_id as visitor_id,
INTEGER(0) as count_visitor_ids,
INTEGER(1) as count_converting_visitor_ids,
INTEGER(count(*)) as conversions,
INTEGER(0) as times_test_seen
# current:
SELECT
experienceId as experiment_id,
variationMasterId as variation_master_id,
iterationId as iteration_id,
context_id as visitor_id,
INTEGER(0) as count_visitor_ids,
INTEGER(1) as count_converting_visitor_ids,
INTEGER(count(*)) as conversions,
INTEGER(0) as times_test_seen
@alanclarke
alanclarke / bot-detection.md
Created November 9, 2016 17:44
Bot detection
  • entrance_referrer_type = 'DIRECT' AND
  • page_number_in_session = 1 AND
  • user_agent_categorisation is one of the following
    • "browser_version":"googlebot
    • "browser_type":"robot"
    • "browser_version":"other"
    • "browser_version":"phantomjs
    • "browser_version":"safari"
    • "browser_version":"firefox 4.0" AND "system_version":"linux"
  • "browser_version":"gomeza
@alanclarke
alanclarke / disable-timeout.js
Last active June 21, 2016 14:04
script to disable google hangout timeout
;(function () {
setInterval(clickYes, 6000)
function clickYes () {
console.log('checking for timeout modal')
var button = [].find.call(document.querySelectorAll('div[role="button"]'), (el) => el.innerHTML.indexOf('Yes') > -1)
if (button) simulateClick(button)
}
function simulate (target, type) {
@alanclarke
alanclarke / now-plus.js
Last active June 14, 2016 17:23
tiny date util
var ms = { minutes: 1000 * 60 }
ms.hours = ms.minutes * 60
ms.days = ms.hours * 24
ms.weeks = ms.days * 7
ms.years = ms.days * 365
module.exports = function create (date) {
date = date || new Date()
function now () {
return new Date()
@alanclarke
alanclarke / datatable.js
Last active June 8, 2016 11:41
schema proposal
{
name: 'datatable 1',
tableType: 'segments',
columns: [{
name: 'England'
value: 'segment_id_123'
}, {
name: 'France'
value: 'segment_id_456'
}],
@alanclarke
alanclarke / each.js
Created April 28, 2016 09:59
alternative technique
var isNative = require('./util/isNative')
module.exports = isNative(Array.prototype.forEach) ? function forEach (array, callback, context) {
return Array.prototype.forEach.call(array, callback, context)
} : function forEach (arr, callback, context) {
var length = this.length
for (var i = 0; i < length; i++) {
callback.call(context, arr[i], i, arr)
}
}
var cm = require('../lib/cookieman')
const msInADay = 1000 * 60 * 60 * 24
describe('addDays', function () {
var date,
beforeEach(function () {
date = new Date()
})
it('should add a multiple of days to the date', function () {
@alanclarke
alanclarke / node.js vs vertx
Created May 10, 2012 01:52
vert.x vs node.js benchmark
/**********
instead of:
***********/
//taken from https://github.com/purplefox/vert.x/blob/master/src/examples/java/httpperf/nodejs-server.js
http.createServer(function (req, res) {
//asynchronous callback and file read on every request
fs.readFile("foo.html", function(err, file) {
if (err) {
console.error(err);
app.post('/signup', function(req, res, next) {
//async callback to function returning whether email exists
exists(function(email_exists) {
req.body.email_exists = email_exists;
next();
})
},
form(field("email").trim().required().isEmail().custom(function(value, data) {