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 / upgrade_packages.R
Created September 26, 2017 06:57 — forked from bearloga/upgrade_packages.R
The script can be used to re-install packages after upgrading R (on Linux or Mac), since libraries cannot be reused between different minor versions (e.g. when upgrading 3.2.3 to 3.3.2). It detects when a package was installed from CRAN vs GitHub/Git and re-installs it using the appropriate func. Usage: `Rscript upgrade_packages.R`
# WMF only:
if (file.exists("/etc/wikimedia-cluster")) {
message('Detected that this script is being run on a WMF machine ("', Sys.info()["nodename"], '"). Setting proxies...')
Sys.setenv("http_proxy" = "http://webproxy.eqiad.wmnet:8080")
Sys.setenv("https_proxy" = "http://webproxy.eqiad.wmnet:8080")
}
# General use:
message("Checking for a personal library...")
if (!dir.exists(Sys.getenv("R_LIBS_USER"))) {
library(tidyverse)
library(magrittr)
library(stringr)
library(readxl)
directory <- "bunch/of/excel/files"
# Get an overview of all the Excel files and their sheets
sheets <-
data_frame(file = list.files(directory, full.names = TRUE),
@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"
<script>
function matchIP(ipaddress) {
// Comment following three lines if you want to use the IP range method
if (ipaddress == "111.222.333.444") {
dataLayer.push({"internal": "true"});
}
// To use the following IP range check, comment the previous three lines
// of code and uncomment the following lines
//
@IronistM
IronistM / sql.export.randomForest.R
Created May 24, 2017 12:56 — forked from shanebutler/sql.export.randomForest.R
Deploy your RandomForest models in SQL! This tool enables in-database scoring of Random Forest models built using R. To use it, you simply call the function with the Random Forest model, output filename, SQL input data table and the name of the unique key on that table. For example:sql.export.rf(rf.mdl, file="model_output.SQL", input.table="sour…
# sql.export.rf(): save a randomForest model as SQL
# v0.04
# Copyright (c) 2013-2014 Shane Butler <shane dot butler at gmail dot com>
#
# sql.export.rf is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# sql.export.rf is distributed in the hope that it will be useful, but
@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
# Requirements -----------------------------------
require(googleAnalyticsR)
require(lubridate)
require(dataframes2xls)
## Authentication with GA -------------------------
options(googleAuthR.scopes.selected =
c("https://www.googleapis.com/auth/webmasters",
"https://www.googleapis.com/auth/analytics",
"https://www.googleapis.com/auth/analytics.readonly"))
@IronistM
IronistM / Account Anomaly Detector.js
Last active December 19, 2016 15:08
Just commented out the two lines that falsly set todays click and impression stats to 0. "Account Anomaly Detector alerts the advertiser whenever an AdWords account is suddenly behaving too differently from what's historically observed. When an issue is encountered, the script will send the user an alerting email. Only a single email for an aler…
var SPREADSHEET_URL = "[YOUR_URL]";
var DAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
function main() {
var spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
spreadsheet.getRangeByName("date").setValue(new Date());
spreadsheet.getRangeByName("account_id").setValue(AdWordsApp.currentAccount().getCustomerId());
var impressionsThreshold = parseField(spreadsheet.getRangeByName("impressions").getValue());
var clicksThreshold = parseField(spreadsheet.getRangeByName("clicks").getValue());
@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 / r_script_to_read_basic_info_from_all_available_views.r
Created September 28, 2016 07:45
R Script to read basic info from all available views
library("RGoogleAnalytics")
library("ggplot2")
library("dplyr")
#Google Auth Codes
clientid = "USE YOUR CLIENT ID HERE"
clientsecret = "CLIENT SECRET GOES HERE"
#Fire off an AUTH request to Google. This will actually kick off a browser opening to do the OAuth2 transaction.
oauth_token <- Auth(clientid,clientsecret)