Skip to content

Instantly share code, notes, and snippets.

View danbills's full-sized avatar
🎩
-

Dan Billings danbills

🎩
-
  • Foundation Medicine
  • Marblehead, MA
View GitHub Profile
@danbills
danbills / foldoption.java
Created November 14, 2019 19:22
fold option in Java
private <T, U> Optional<U> foldOption(Optional<T> option, Function<T,U> f, Supplier<U> ifNone) {
return Optional.<U>of(option.map(f).orElse(ifNone.get()));
}
41,226.449
41,226.449
@danbills
danbills / cloud_sql_connection_string.txt
Created September 20, 2019 18:30
google cloud sql connection string
jdbc:mysql://google/cromwell?cloudSqlInstance=anichols-clone&socketFactory=com.google.cloud.sql.mysql.Socke
tFactory&user=asdf&password=asdf&useUnicode=true&characterEncoding=UTF-8
@danbills
danbills / cromwell_service_account.sh
Created August 29, 2019 19:23
minimal way to create a service account suitable for running cromwell on Google GCP Pipelines API
EMAIL=$(gcloud beta iam service-accounts create $1 --description "foo" --display-name "danb-perf-display-name" --format json | jq '.email' | sed -e 's/\"//g')
for i in storage.objectCreator storage.objectViewer genomics.pipelinesRunner genomics.admin iam.serviceAccountUser storage.objects.create
do
gcloud projects add-iam-policy-binding $2 --member serviceAccount:$EMAIL --role roles/$i
done
gcloud iam service-accounts keys create sa.json --iam-account $EMAIL
@danbills
danbills / swt_example.scala
Created May 28, 2019 00:22
uses swt and SIGAR java system libs to produce a GUI
//IMPORTANT
//to run on mac use JAVA_OPTS="-XstartOnFirstThread" amm -w swt.sc
interp.repositories() ++= Seq(coursier.maven.MavenRepository(
"http://maven-eclipse.github.io/maven/"))
import $ivy.`org.clapper::grizzled-scala:4.4.1`
import $ivy.`org.fusesource:sigar:1.6.4`
import grizzled.sys._
@danbills
danbills / truncate_log.json
Last active April 26, 2019 01:21
truncate a cloud sql database's general log
{
"truncateLogContext": {
"kind": "sql#truncateLogContext",
"logType": "MYSQL_GENERAL_TABLE"
}
}
@danbills
danbills / compare_cromwell_perf.sh
Created October 20, 2018 21:03
compare 2 cromwell runs
#!/bin/bash
REPORT_BUCKET="cromwell-perf-test-reporting"
CROMWELL_OLD_VERSION=34-cfbe67f
CROMWELL_NEW_VERSION=34-bda9485
TEST_CASES=$(gsutil ls -d gs://$REPORT_BUCKET | grep -e "/$")
TEST_CASES_URLS_LIST=(${TEST_CASES// / })
docker \
import $ivy.`org.http4s::http4s-dsl:0.18.17`
import $ivy.`org.http4s::http4s-blaze-server:0.18.17`
import $ivy.`org.http4s::http4s-blaze-client:0.18.17`
import $ivy.`io.circe::circe-core:0.9.3`
import $ivy.`io.circe::circe-parser:0.9.3`
import $ivy.`io.circe::circe-generic:0.9.3`
import io.circe._, io.circe.parser._
import io.circe.generic.auto._
@danbills
danbills / fs2_scan_state.scala
Created July 21, 2018 21:08
scanState in fs2
def scanState[F[_], S, A, B](init: S)(f: A => State[S, B]): Pipe[F, A, B] =
_.pull.scanSegments(init){
case (previousState, segment: Segment[A, Unit]) =>
segment.mapAccumulate(previousState)({
case (state, o1) =>
val stateFunc = f(o1)
(stateFunc run state).value
}).mapResult(_._2)
}.stream
@danbills
danbills / index.js
Created June 27, 2018 18:46
fake martha
exports.helloWorld = (req, res) => {
// Example input: {"message": "Hello!"}
if (req.body.dosUrl === undefined) {
// This is an error case, as "message" is required.
res.status(400).send('No message defined!');
} else {
// Everything is okay.
console.log(req.body.dosUrl);
var response = {};
response["dos"] = req.body.dosUrl.replace("dos","gs");