Skip to content

Instantly share code, notes, and snippets.

import io.reactivex.Observable;
import java.util.function.Supplier;
/**
* Wrapper around a Supplier (intended to be making remote service request),
* that will attempt to retry a request if an exception occurs.
*
* @author Brian Schlining
* @since 2019-04-24T13:54:00
@hohonuuli
hohonuuli / CompressedGene.scala
Created March 19, 2019 05:26
Trivial compression of DNA in Scala
import scala.collection.BitSet
import scala.collection.mutable
case class CompressedGene(nucleotideCount: Int, bits: BitSet) {
override def toString(): String = CompressedGene.decompress(this)
}
object CompressedGene {
@hohonuuli
hohonuuli / CompressedGene.py
Created March 19, 2019 05:20
Trivial compression of DNA in python
class CompressedGene:
def __init__(self, gene: str) -> None:
self._compress(gene)
def _compress(self, gene: str) -> None:
self.bit_string = 1 # start with sentinal
for nucleotide in gene.upper():
self.bit_string <<= 2 # shift left 2 mits
if nucleotide == "A":
self.bit_string |= 0b00
@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 ""
# I keep all my config settings in .bashrc.
# .bash_profile redirects there
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
import datetime
import json
import sys
import requests
# This example uses mock data. But it outlines the general steps needed.
# If you have a lot of images, they can all be registered in a single
# POST request, but you will need to build a JSON array of data first.
# The details of this bulk load are NOT covered in this example
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.net.http.HttpResponse.BodySubscriber;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.concurrent.CompletableFuture;
@hohonuuli
hohonuuli / vars_extract.py
Last active April 20, 2020 21:45
Script to automate extraction of annotated video frames from VARS/M3
from datetime import datetime, timedelta
from typing import List, Dict
import iso8601
import requests
import subprocess
import sys
__author__ = "Brian Schlining"
__copyright__ = "Copyright 2018, Monterey Bay Aquarium Research Institute"
@hohonuuli
hohonuuli / register_video.py
Last active August 29, 2018 20:39
MBARI Media Management - Demonstrate how to register a video in the `vampire-squid` video asset manager
import datetime
import json
import sys
import requests
host = "http://localhost:8084"
client_secret = "foo"
@hohonuuli
hohonuuli / Dockerfile
Created May 11, 2018 20:05
Dockerfile for a scipy setup using jupyter
FROM ubuntu
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
curl \
cmake \
&& rm -rf /var/lib/apt/lists/*
RUN curl -qsSLkO \