This file contains 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
# 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"))) { |
This file contains 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(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), |
This file contains 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
#!/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" |
This file contains 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
<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 | |
// |
This file contains 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
# 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 |
This file contains 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
# 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 |
This file contains 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
# 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")) |
This file contains 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 = "[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()); |
This file contains 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 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("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) |