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
tasks.withType(CreateStartScripts).each { task -> | |
task.doLast { | |
String text = task.windowsScript.text | |
text = text.replaceFirst(/(set CLASSPATH=%APP_HOME%\\lib\\).*/, { "${it[1]}*" }) | |
task.windowsScript.write text | |
} | |
} |
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
try (InputStreamReader inputStreamReader = new InputStreamReader( | |
new FileInputStream(path.toString()), StandardCharsets.UTF_8)) { | |
// do stuff with the inputStreamReader rather than a File | |
} | |
} | |
byte[] bytes = string.getBytes(StandardCharsets.UTF_8); | |
String string = new String(bytes, StandardCharsets.UTF_8); |
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
Thread.allStackTraces.keySet().each() { | |
if (it.name.contains("SCM polling")) { | |
println "Interrupting thread ${it.id} ${it.name}" | |
it.interrupt() | |
} | |
} |
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
// Oracle example | |
@GrabResolver(name='nexus', root='http://path/to/some/nexus/server') | |
@GrabConfig(systemClassLoader=true) | |
@Grab(group='oracle', module='ojdbc6', version='11.2.0.4') | |
import groovy.sql.Sql | |
def hostname = "hostname of Oracle DB here" | |
def port = "port of the server here" | |
def db = "service name here" | |
def url = "jdbc:oracle:thin:@//${hostname}:${port}/${db}" |
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
configure { project -> | |
project / builders / 'hudson.plugins.gradle.Gradle' { | |
description 'Builds and runs unit tests.' | |
tasks "clean test javadoc" | |
rootBuildScriptDir '' | |
fromRootBuildScriptDir true | |
useWrapper true | |
makeExecutable true | |
useWorkspaceAsHome false | |
} |
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
# a simple function to create a list of lists: | |
list_of_lists <- function(...) { | |
list(...) | |
} | |
my_lol <- list_of_lists(list(cleesh = "krill"), list(nitfol = "rezrov")) | |
# want to print out "krill" and "rezrov" | |
# various suggestions for iterating over a list: | |
for (name in names(my_lol)) { | |
message(my_lol[[name]][[1]]) |
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
#' Kabsch Algorithm | |
#' | |
#' Aligns two sets of points via rotations and translations. | |
#' | |
#' Given two sets of points, with one specified as the reference set, | |
#' the other set will be rotated so that the RMSD between the two is minimized. | |
#' The format of the matrix is that there should be one row for each of | |
#' n observations, and the number of columns, d, specifies the dimensionality | |
#' of the points. The point sets must be of equal size and with the same | |
#' ordering, i.e. point one of the second matrix is mapped to point one of |
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
```{r setup, include=FALSE} | |
devtools::load_all("..") | |
knitr::opts_chunk$set(echo = TRUE, collapse = TRUE, comment = "#>") | |
``` |
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
# Rough code to run mize with various settings over all the test functions in | |
# the funconstrain package https://github.com/jlmelville/mize and | |
# https://github.com/jlmelville/funconstrain | |
# Example | |
# devtools::install_github("jlmelville/mize") | |
# devtools::install_github("jlmelville/funconstrain") | |
# library("mize") | |
# library("funconstrain") |
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
words_canon <- function(words) { | |
words$canon <- apply(words, 1, | |
function(x) { | |
paste( | |
stringr::str_sort( | |
unlist( | |
strsplit( | |
tolower(as.character(x)), split = "", | |
fixed = TRUE))), | |
collapse = "") |
OlderNewer