Skip to content

Instantly share code, notes, and snippets.

View nfultz's full-sized avatar
🌯

Neal Fultz nfultz

🌯
View GitHub Profile
#From glmnet package
cv.glmnet <-
function (x, y, weights, offset = NULL, lambda = NULL, type.measure = c("mse",
"deviance", "class", "auc", "mae"), nfolds = 10, foldid,
grouped = TRUE, keep = FALSE, parallel = FALSE, ...)
{
if (missing(type.measure))
type.measure = "default"
else type.measure = match.arg(type.measure)
@nfultz
nfultz / debug.log
Created January 19, 2018 23:49
Debugging drat
> debug(add)
> drat::insertPackage("drat_0.1.4.zip", "mydrat", "my commit message")
debugging in: git2r::add(repo, file.path(reldir, pkg))
debug: standardGeneric("add")
Browse[2]> debug(getMethod(git2r::add, signature("git_repository", "character")))
Browse[2]> c
debugging in: git2r::add(repo, file.path(reldir, pkg))
debug: {
.local <- function (repo, path, force = FALSE)
{
@nfultz
nfultz / app.R
Last active November 8, 2017 21:39 — forked from mine-cetinkaya-rundel/app.R
Shiny dynamic UI - observers & for loop
# An example based on http://shiny.rstudio.com/articles/dynamic-ui.html
library(shiny)
ui = basicPage(
fluidRow(
actionButton(inputId = "add_buttons", label = "Add 5 Buttons")
),
uiOutput("more_buttons") # this is where the dynamically added buttons will go
)
If you have a huge repository (in size and in history) and want to add a subfolder
to your project as a submodule you can follow this example to save time and space
using git's shallow clone and shallow checkout feature. It is a bit more complicated
in this example because I assume that you want your submodule to track a non-default
branch, called `mybranch`, instead of the `master` branch. Things could probably get
a lot simpler when using the default branch. After following the commands in these
examples you can use `git submodule update` and `git submodule update --remote` as normal.
@nfultz
nfultz / docker-wildcard.md
Created June 19, 2017 20:38
Comments on working around .git folder in docker.
@nfultz
nfultz / quadprog_ipoptr_translate.R
Created September 19, 2016 15:39 — forked from rwalk/quadprog_ipoptr_translate.R
Quadratic programming: Use matrix inputs to solve a QP with ipoptr
ipoptr_qp <- function(Dmat, dvec, Amat, bvec, ub=100){
# Solve the quadratic program
#
# min -d^T x + 1/2 x^T D x
# s.t. A%*%x>= b
#
# with ipoptr.
n <- length(bvec)
# Jacobian structural components
@nfultz
nfultz / gist:2809aa1d9df4540bfbcc
Created April 29, 2015 23:16
generifying Rcssplot
#Taking a look at Rcssplot, seems nice enough.
#
#Wrappers feel inelegant though, especially building commands as strings then eval(parse())
#
#here is a potential solution:
#
# 1. Build call using substitute()
# 2. get copy of property list
# 3. delete any properties that are specified by user explicitly (in ...)
# 4. append the props to the call