Skip to content

Instantly share code, notes, and snippets.

View IronistM's full-sized avatar
🏗️
Under construction

Manos Parzakonis IronistM

🏗️
Under construction
View GitHub Profile
@IronistM
IronistM / github.gs
Created October 3, 2016 07:45 — forked from chipoglesby/github.gs
A Google Apps Script that automatically opens a pull request on a Github Repo.
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)
@IronistM
IronistM / finSim.R
Last active September 22, 2016 09:50 — forked from coppeliaMLA/finSim.R
Uncertainty in a financial model
#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')
@IronistM
IronistM / costdata.gs
Last active September 18, 2015 13:03 — forked from chipoglesby/costdata.gs
Cost Data Upload via Google Analytic's Management API with Google Sheets
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());
@IronistM
IronistM / facebookads.gs
Last active April 10, 2018 17:28 — forked from chipoglesby/facebookads.gs
Pull Facebook Advertising Metrics into Google Sheets
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);
#
# PREDICTING LONG TERM CUSTOMER VALUE WITH BTYD PACKAGE
# Pareto/NBD (negative binomial distribution) modeling of
# repeat-buying behavior in a noncontractual setting
#
# Matthew Baggott, matt@baggott.net
#
# Accompanying slides at:
# http://www.slideshare.net/mattbagg/baggott-predict-customerinrpart1#
#
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;
require(RMySQL)
require(ggplot2)
require(scales)
myusername = "peter"
mypassword = "sekret"
system('ssh -f pe@192.168.0.10 -L 3306:localhost:3306 -N -o ExitOnForwardFailure=yes')
con <- dbConnect(MySQL(),
user=myusername, password=mypassword,
@IronistM
IronistM / pullJSON.js
Last active August 29, 2015 14:18 — forked from varun-raj/pullJSON.js
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()); //
# 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)
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