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
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,
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;
#
# 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#
#
@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);
@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 / 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 / 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 / setup-elementary.sh
Last active November 1, 2024 15:08 — forked from floriancgit/setup-elementary.sh
Things to do after installing elementary OS Loki 0.4
#Start with a dist upgrade
sudo apt dist-upgrade
# Get chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i ./google-chrome*.deb
sudo apt-get install -f
# dev (php, docker, git, node, bower, electron, composer)
sudo apt install -y \
@IronistM
IronistM / install-rstudio-daily.sh
Last active June 23, 2017 20:11 — forked from aronatkins/install-rstudio-daily.sh
Install RStudio daily build on OSX/macOS or Elementary OS
#!/bin/bash
#
# Installs the latest RStudio daily desktop build for OSX/macOS and Ubuntu(amd64)
#
# https://support.rstudio.com/hc/en-us/articles/203842428-Getting-the-newest-RStudio-builds
set -e
install_macos_daily() {
REDIRECT_URL="https://www.rstudio.org/download/latest/daily/desktop/mac/RStudio-latest.dmg"
@IronistM
IronistM / s3.sh
Created April 11, 2017 13:00 — forked from chrismdp/s3.sh
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1