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
# 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
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
## R | |
# install possible missing dependencies for R packages | |
apt-get -y install libcurl4-gnutls-dev | |
apt-get -y install libcairo2-dev | |
apt-get -y install libgdal1-dev libproj-dev | |
apt-get -y install libxt-dev | |
apt-get -y install libiodbc2 libiodbc2-dev | |
apt-get -y install libgdal-dev libproj-dev | |
# then install these packages | |
shiny # devtools::install_github('shiny', 'rstudio') |
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
options(shiny.reactlog=TRUE, warn=2, show.error.locations=TRUE, error=recover) | |
# interactive session | |
browser() | |
# print message | |
message('message') | |
# error handling | |
err.hanlder <- function(e) message(e) |
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 <- navbarPage('TEST', id='page', collapsable=TRUE, inverse=FALSE, | |
# define a message handler that will receive the variables on the client side | |
# from the server and update the page accordingly. | |
tags$head(tags$script(" | |
Shiny.addCustomMessageHandler('updateSelections', | |
function(data) { | |
var nav_ref = '#page a:contains(\"' + data.nav + '\")'; | |
var tabpanel_id = data.nav == 'Alpha' ? '#alpha_tabs' : '#beta_tabs'; | |
var tab_ref = tabpanel_id + ' a:contains(\"' + data.tab + '\")'; | |
$(nav_ref).tab('show'); |
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
options(RCurlOptions=list(proxy='web.proxy.com:8080')) | |
py <- plotly("me", "mec3g0e1z7") | |
p <- ggplot(mtcars, aes(x=mpg, y=cyl)) + geom_point() | |
res <- py$ggplotly(k, kwargs=list(auto_open=FALSE)) |
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
num.cols <- 10 | |
# allocate space for your ten columns | |
cols <- vector('list', num.cols) | |
# add key column, such as timestamp | |
cols[[1]] <- 1:5 | |
for (i in 2:num.cols) { | |
cols[[i]] <- rnorm(5) # add the next column, 5 random numbers |
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
library(ggplot2) | |
library(reshape2) # gives you the melt function | |
d1 <- data.frame(time=1:10, x1=1:10) | |
d2 <- data.frame(time=1:10, x2=1:10/2) | |
d <- merge(d1, d2, by='time') | |
d.molten <- melt(d, id.var='time') |
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
layout.mat <- matrix(c(1,1,1,1,1,1,2,3,3), nrow=3) | |
layout.mat | |
layout(layout.mat) | |
plot(1:10) | |
plot(1:10) |