This file contains hidden or 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
git config --global http.proxy http://webproxy.phila.gov:8080 | |
git config --global user.name "Firstname Lastname" | |
git config --global user.email "[email protected]" | |
git config --global github.user mplourde | |
git config --global github.token 2332424your3232442 |
This file contains hidden or 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
# after making a series of changes to a file or files, open git bash and use the following commands to commit and sync | |
# if you've added files to the repository, call 'git add' to add them to the repo | |
git add /path/to/file | |
# to commit all your changes, open git bash and change directory to the project folder. Use "pushd //28-arajohnsmit/myproject" | |
# to change to a directory on someone else's machine. Then enter the following command | |
git commit -a | |
# this will open a vim session for you to enter a message about your changes. | |
# In vim hit the 'i' key to go into insert mode. Type a brief explanation of your changes, then hit esc |
This file contains hidden or 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 | |
import sys | |
def script_dir(): | |
if '__file__' in globals(): | |
return os.path.abspath(os.path.dirname(__file__)) | |
elif sys.argv[0]: | |
return os.path.abspath(os.path.dirname(sys.argv[0])) | |
else: | |
os.path.abspath(os.curdir) |
This file contains hidden or 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
# example1 (using grobs instead of grid.*) | |
vp <- vpTree( | |
parent=viewport(layout=grid.layout(nrow=2, ncol=2), name='parent'), | |
children=vpList( | |
viewport(layout.pos.row=1, layout.pos.col=1, name='vp1'), | |
viewport(layout.pos.row=1, layout.pos.col=2, name='vp2') | |
) | |
) | |
pushViewport(vp) | |
seekViewport('parent') |
This file contains hidden or 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
ui <- fluidPage( | |
selectInput('plot_type', 'Plot type', choices=c('point', 'line')), | |
sliderInput('n', 'N plots', value=1, min=1, max=100), | |
uiOutput('plots') | |
) | |
server <- function(input, output, session) { | |
output$plots <- renderUI({ | |
ptype <- input$plot_type |
This file contains hidden or 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
x <- ggplot(mtcars, aes(x=mpg, y=disp, label=carb)) + | |
geom_point() + | |
geom_text(y=Inf, vjust=-.3) | |
g <- ggplotGrob(x) | |
g$layout$clip[g$layout$name == "panel"] = "off" | |
grid.draw(g) |
This file contains hidden or 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
# create instance, create key, install awscli, do awscli configure, | |
export AWS_ACCESS_KEY_ID=XX | |
export AWS_SECRET_ACCESS_KEY=XX | |
export SPARK_HOME=~/spark-1.4.1-bin-hadoop2.6 | |
$SPARK_HOME/ec2/spark-ec2 --key-pair=XX \ | |
--instance-type=m1.large \ | |
--zone us-east-1a \ | |
--identity-file=XX.pem \ |
This file contains hidden or 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
vsel <- function (y, lag.max = 10, type = c("const", "trend", "both", | |
"none"), season = NULL, exogen = NULL) | |
{ | |
browser() | |
y <- as.matrix(y) | |
if (any(is.na(y))) | |
stop("\nNAs in y.\n") | |
colnames(y) <- make.names(colnames(y)) | |
K <- ncol(y) | |
lag.max <- abs(as.integer(lag.max)) |
This file contains hidden or 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
get_p_id <- function(p_id, connection) { | |
sqlQuery(connection, sprintf( | |
"select p.id 'proposal_id', | |
pd.id 'proposal_detail_id', | |
mm.media_month, | |
b.name 'MVPD', | |
n.code 'network', | |
mpi.post_log_recieved_date 'log_date', | |
pd.start_date 'detail_start', | |
pd.end_date 'detail_end', |
This file contains hidden or 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
#' @export | |
add_time_sig <- function(D) { | |
daypart_cols <- names(D)[grepl('hour_', names(D))] | |
# NOT CURRENTLY USED | |
#D <- D %>% | |
# mutate_( | |
# week_sig = ~ifelse(get_media_month(log_date) != get_media_month(detail_start), | |
# get_media_week(detail_end), |