This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function github() { | |
username = "xxx" | |
repo = "xxx" | |
url = "https://api.github.com/repos/"+username+"/"+repo+"/issues" | |
payload = { | |
"title": "xxx", | |
"body": "xxx", | |
"assignee": "xxx" | |
} | |
sendToGithub(url, payload) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#First we are going to set up probability distributions for our beliefs about the inputs | |
#We've been told ARPU is about £7 and it's very unlikely to be higher than £10 or lower than £4 | |
#So we'll go for a normal distribution centred at 7 with 5% and 95% quantiles at 4 and 10 | |
#Show how we get the variance | |
arpu.sd<-3/1.96 | |
x<-seq(0, 15,by=0.5) | |
d<-dnorm(x, 7, arpu.sd) | |
plot(x, d, type='l') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function uploadData() { | |
var accountId = "xxxxxxxx"; | |
var webPropertyId = "UA-xxxxxxxx-x"; | |
var customDataSourceId = "xxxxxxxx"; | |
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); | |
var maxRows = ss.getLastRow(); | |
var maxColumns = ss.getLastColumn(); | |
var data = []; | |
for (var i = 1; i < maxRows;i++) { | |
data.push(ss.getRange([i], 1,1, maxColumns).getValues()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SPREADSHEET_URL = ""; | |
function facebookSpend() { | |
var ss = SpreadsheetApp.openByUrl(SPREADSHEET_URL); | |
var sheet = ss.getSheetByName('facebook'); | |
var values = []; | |
Utilities.sleep(1000); | |
var fullUrl = 'https://graph.facebook.com/v2.3/act_xxx/stats?access_token=xxx'; | |
var fetchRequest = UrlFetchApp.fetch(fullUrl); | |
var results = JSON.parse(fetchRequest.getContentText()); | |
Logger.log(results.spent/100); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# PREDICTING LONG TERM CUSTOMER VALUE WITH BTYD PACKAGE | |
# Pareto/NBD (negative binomial distribution) modeling of | |
# repeat-buying behavior in a noncontractual setting | |
# | |
# Matthew Baggott, [email protected] | |
# | |
# Accompanying slides at: | |
# http://www.slideshare.net/mattbagg/baggott-predict-customerinrpart1# | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT orders.customerid, | |
orders.transactiondate, | |
orders.transactionamount, | |
cohorts.cohortdate | |
FROM orders | |
JOIN (SELECT customerid, | |
Min(transactiondate) AS cohortDate | |
FROM orders | |
GROUP BY customerid) AS cohorts | |
ON orders.customerid = cohorts.customerid; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(RMySQL) | |
require(ggplot2) | |
require(scales) | |
myusername = "peter" | |
mypassword = "sekret" | |
system('ssh -f [email protected] -L 3306:localhost:3306 -N -o ExitOnForwardFailure=yes') | |
con <- dbConnect(MySQL(), | |
user=myusername, password=mypassword, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pullJSON() { | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheets = ss.getSheets(); | |
var sheet = ss.getActiveSheet(); | |
var url="http://example.com/feeds?type=json"; // Paste your JSON URL here | |
var response = UrlFetchApp.fetch(url); // get feed | |
var dataAll = JSON.parse(response.getContentText()); // |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://learnr.wordpress.com/2009/05/18/ggplot2-three-variable-time-series-panel-chart/ | |
# http://www.talkstats.com/showthread.php/21228-time-series-in-ggplot2 | |
# http://had.co.nz/ggplot2/ | |
# http://stats.stackexchange.com/questions/14513/align-multiple-ggplot2-plots-with-grid | |
# http://wiki.stdout.org/rcookbook/Graphs/Facets%20(ggplot2) | |
# colors: red: "730202", lightyellow: D5D95B, lightgreen: 4F7302 midgreed=274001 darkgreen=092601 | |
setwd('~/repositories/uni/thesis-repos/Opad4lsssExperiments/r_scripts/') | |
library(ggplot2) | |
library(gridExtra) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(ggmap) | |
library(plyr) | |
library(grid) | |
library(gridExtra) | |
# read in cleaned up data | |
dat <- read.table("quakes.dat", header=TRUE, stringsAsFactors=FALSE) | |
# map decimal magnitudes into an integer range |