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 getMailChimpData(){ | |
// Here are the things you will change | |
var API_KEY = 'YOUR-KEY-HERE'; | |
var MEMBER_LIST_ID = 'LIST-ID-WITH-SEGMENTS'; | |
var KYCIR_LIST_ID = 'LIST-ID-WITH-NO-SEGMENTS'; | |
function calculateAvgRates(runType, segmentID, rateType){ | |
var ratesList = []; | |
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
# Equation looks to see if there are ties, if ties exist, | |
# then it skips the next ranking number so your last ranking | |
# number corresponds with the actual number of actual things | |
# you're ranking. | |
# This equation allows for up to a 4-way tie. | |
# Column E holds the values you're comparing to create the | |
# rank and Column F is where you're putting this equation |
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
//These two functions create a new menu item titled "Update data" that | |
//when clicked will run the rest of the code we're writing here | |
function onOpen() { | |
var ui = SpreadsheetApp.getUi(); | |
ui.createMenu('Update data') | |
.addItem('Update data', 'updateDataMenu') | |
.addToUi(); | |
} | |
function updateDataMenu() { |
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 gaDateFetch(){ | |
// Here are all the variables you'll need to set | |
var sheetName = 'by-date'; | |
var viewId = 'ga:xxxxxxx'; | |
var metric = 'ga:users'; | |
// select the sheet named by-date | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = ss.getSheetByName(sheetName); | |
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
#https://stackoverflow.com/questions/19914937/applying-function-with-multiple-arguments-to-create-a-new-pandas-column | |
def float_to_datetime(ddate, ttime): | |
return pd.to_datetime('1899-12-30') + pd.to_timedelta(ddate + ttime),'s') | |
response_data['pickup_datetime'] = np.vectorize(float_to_datetime)(response_data['date'], response_data['911_pickup_time']) | |
response_data['dispatch_datetime'] = np.vectorize(float_to_datetime)(response_data['date'], response_data['dipatch_time']) | |
response_data['arrive_datetime'] = np.vectorize(float_to_datetime)(response_data['date'], response_data['arrive_time']) |
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
#https://gist.github.com/oag335/9959241 | |
response_data['real_date'] = pd.to_datetime('1899-12-30') + pd.to_timedelta(response_data['date'],'D') |
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
# https://www.commandlinefu.com/commands/view/9002/extracting-a-range-of-pages-from-a-pdf-using-ghostscript | |
# commandline | |
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=14 -dLastPage=17 -sOutputFile=OUTPUT.pdf ORIGINAL.pdf |
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
import os | |
data_dir = '/Users/akanik/data/csv/' | |
file1 = 'whatever-data-1.csv' | |
file1_path = data_dir + file1 | |
#Make sure your combined file does not live within your data_dir. | |
#This will cause an endless loop of writing | |
combined_file = '/Users/akanik/data/whatever-data-ALL.csv' | |
fout = open(combined_file,'a') |
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
=if(isblank(B2),A1,B2) |
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
#virtual environment | |
>> cd [project-path] | |
>> mkvirtualenv -a ./ [-r requirements_file] ENVNAME | |
#install django in virtualenv | |
>> pip install Django | |
#create django project | |
>> django-admin startproject mysite |