Skip to content

Instantly share code, notes, and snippets.

View dpastoor's full-sized avatar

Devin Pastoor dpastoor

  • A2-Ai
  • Rockville, MD
View GitHub Profile
@dpastoor
dpastoor / rscratch.r
Created January 11, 2017 21:19
hacky example of calling rscript from exec
args <- commandArgs(trailingOnly = TRUE)
# just add the two args goether
Input <- as.numeric(args[1]) + as.numeric(args[2])
jsonlite::toJSON(list(res = Input))
@dpastoor
dpastoor / nm.tmLanguage
Created December 7, 2016 23:04
nonmem syntax highlighter
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>mod</string>
<string>ctl</string>
<string>lst</string>
</array>
@dpastoor
dpastoor / changeDirInGoroutine.go
Created December 2, 2016 14:47
changing dirs in a goroutine leads to issues about what dir expected to be in since the dir is set per os thread
package main
import (
"fmt"
"path/filepath"
"sync"
"time"
)
import "os"
@dpastoor
dpastoor / all.R
Created November 21, 2016 21:16
ggplot linking scales
library(ggplot2)
t1<-seq(0,40,0.2)
a1<-seq(from =1, to =0, length.out = length(t1))
a2<-seq(from = 1, to = 0.4, length.out = length(t1))
a3<-seq(from = 1, to = 0.6, length.out = length(t1))
df1<-data.frame(time = t1, surv = a1)
df2<-data.frame(time = t1, surv = a2)
df3<-data.frame(time = t1, surv = a3)
@dpastoor
dpastoor / simulation_client.R
Created August 31, 2016 14:15
logging simulations
```{r}
library(pbdZMQ)
library(future)
sim_logger <- function(rep, message = "") {
context <- zmq.ctx.new()
sink <- zmq.socket(context, .pbd_env$ZMQ.ST$PUSH)
zmq.connect(sink, "tcp://localhost:5558")
zmq.send(sink, paste("completed sim", rep, "from process", Sys.getpid(), "with message: ", message))
library(future)
library(mrgsolve)
library(dplyr)
data(extran3)
ipar <- extran3 %>% dplyr::select(ID,CL,VC,KA) %>% distinct(ID)
mod <- mrgsolve:::house()
plan(multiprocess)
f <- list()
for (ii in 1:2) {
@dpastoor
dpastoor / gist:98ffc68da4dba3198e061bb31633fdae
Created August 10, 2016 15:21
future example for parallel processing very raw
library(microbenchmark)
library(tibble)
library(future)
library(dplyr)
nids <- 16
sleep_times <- data_frame(REP = 1:nids, sleep_time = round(runif(nids, 0, 2), 0))
sleep_times
eager_bm <- function(sleep_times) {
plan(eager)
@dpastoor
dpastoor / vec_to_ltm.R
Created March 12, 2016 15:09
vector to lower triangle matrix
b = matrix(0, 2, 2)
b[lower.tri(b, diag=T)] = as.numeric(c("1.23E-01",
"0.00E+00",
"1.54E-01"))
library(MASS)
library(shiny)
library(mrgsolve)
library(dplyr)
library(magrittr)
library(parallel)
RNGkind("L'Ecuyer-CMRG")
set.seed(101)

We're excited to have you attend one of our workshops! Here's a JavaScript (re)fresher to help you get up-to-speed on some features of the language we'll be using.

Let and Const

JavaScript has always had var:

var name = 'Ryan'