Skip to content

Instantly share code, notes, and snippets.

function s = jdbcquery(conn, sqlstr)
% Connect to database, execute SQL string, and pass back structure array.
%
% Usage:
% s = jdbcquery(conn, sqlstr)
%
% Input
% conn: A java.sql.Connection object. See Also database
% sqlstr: SQL string, i.e. 'SELECT * FROM Observation WHERE ConceptName LIKE ''Pandalus%'''
%
function c = database(url, user, password, driverName)
% DATABASE - connect to a SQL database
%
% Usage:
% c = database(url, user, password, driverName)
%
% Inputs:
% url = The database URL. e.g. jdbc:jtds:sqlserver://solstice.shore.mbari.org:1433/EXPD
% user = The user name to connect to the database
% password = THe password for user
@hohonuuli
hohonuuli / ifdo-to-fathomnet.sc
Last active May 26, 2022 01:26
Proof-of-concept to convert https://marine-imaging.com/fair/ifdos/iFDO-overview/ to FathomNet-friendly CSV
#!/usr/bin/env -S scala-cli shebang --scala-version 3.1.2
/*
Proof of concept to convert iFDO YAML to FathomNet CSV
Requirements:
- Install scala-cli https://scala-cli.virtuslab.org
Usage:
ifdo-to-fathomnet.sc <ifdo-yaml-file> > <fathomnet-csv-file>
@hohonuuli
hohonuuli / Logging.scala
Created May 2, 2022 16:33
Gist for Medium article
import java.lang.System.Logger
import java.lang.System.Logger.Level
import java.util.function.Supplier
/**
* * @author Brian Schlining
*/
object Logging:
case class LoggerBuilder(
@hohonuuli
hohonuuli / build_m1.sh
Last active March 16, 2022 19:35
Example build script for docker containers on M1/Arm
#!/usr/bin/env bash
echo "--- Building vars-kb-server (reminder: run docker login first!!)"
VCS_REF=`git tag | sort -V | tail -1`
docker buildx build --platform linux/amd64,linux/arm64 \
-t mbari/vars-kb-server:${VCS_REF} \
-t mbari/vars-kb-server:latest \
--push . \
@hohonuuli
hohonuuli / Logging.scala
Last active February 3, 2022 20:30
Simple pass through logger
import java.lang.System.Logger
import java.lang.System.Logger.Level
object Logging:
private def logAndReturn[T](obj: T, logger: Logger, level: Level, fn: T => String): T =
if logger.isLoggable(level) then
logger.log(level, fn(obj))
obj
@hohonuuli
hohonuuli / fish_prompt.fish
Last active January 5, 2022 12:23
Fish prompt that displays Java, Python versions when appropriate
set -g __fish_prompt_grey A3A3A3
set -g __fish_git_prompt_char_cleanstate "✔"
set -g __fish_git_prompt_char_conflictedstate "✖"
set -g __fish_git_prompt_char_dirtystate "✚"
set -g __fish_git_prompt_char_stagedstate "●"
set -g __fish_git_prompt_char_stateseparator \U0020 #\Ue725
set -g __fish_git_prompt_char_untrackedfiles "…"
set -g __fish_git_prompt_char_upstream_ahead "↑"
set -g __fish_git_prompt_char_upstream_behind "↓"
set -g __fish_git_prompt_char_upstream_prefix ""
@hohonuuli
hohonuuli / Transformer.scala
Last active November 2, 2021 20:30
Method to convert case classes to CSV
import java.net.URL
import scala.deriving.*
import scala.compiletime.{summonAll}
import java.nio.file.Path
/**
* Base function we use to convert case classes to CSV
* @param a The object to convert
*/
def transform[A : Transformer](a: A) = summon[Transformer[A]].f(a)
@hohonuuli
hohonuuli / fetch_async.scala
Last active October 25, 2021 19:39
Scala version of python download code in Medium article
#!/usr/bin/env scala
/*
@author Brian Schlining
@since 2021-10-25
Scala version of example code at
https://python.plainenglish.io/send-http-requests-as-fast-as-possible-in-python-304134d46604
*/
@hohonuuli
hohonuuli / scala3_microservices_wrk2_results.csv
Last active September 26, 2021 18:40
Statistics for Medium Article on Scala 3 microservice benchmarks - wrk2
Framework latency_ms latency_ms_std requests_sec mb_sec pct_max
Cask 61.76 7.16 4022.49 33.89 58.1
Helidon 57.33 7.45 4333.65 36.39 62.4
http4s 65.57 75.05 3928.46 32.98 56.6
Javalin 82.35 21.99 2959.23 24.48 42.0
Scalatra 58.34 3.88 4253.52 35.67 61.2
SparkJava 59.90 27.87 3347.74 28.30 48.6
Vert.xWeb 35.61 1.25 6980.19 58.29 100
ZIOHttp 57.03 6.46 4346.36 35.47 60.9