Skip to content

Instantly share code, notes, and snippets.

@hohonuuli
hohonuuli / Firebase.java
Last active September 21, 2020 23:37
For Medium Article
package firebase.jwt;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseAuthException;
import com.google.firebase.auth.FirebaseToken;
import io.micronaut.core.io.ResourceResolver;
import io.micronaut.core.io.scan.ClassPathResourceLoader;
# Material desing #400 series of colors https://www.materialui.co/colors
[aws]
symbol = " "
[battery]
full_symbol = ""
charging_symbol = ""
discharging_symbol = ""
@hohonuuli
hohonuuli / build.sh
Created June 18, 2020 21:28
Example deployment script for Annosaurus at MBARI
#!/usr/bin/env bash
for server in "$USER@server1.mbari.org" "$USER@server2.mbari.org" "$USER@server3.mbari.org"
do
echo "--- Deploying and starting Annosaurus at ${server}"
ssh $server <<'ENDSSH'
docker pull mbari/annosaurus:latest
docker stop annosaurus
@hohonuuli
hohonuuli / canadiangrid.py
Created October 9, 2019 16:46
Python code for performing canadian grid calculation
import math
from dataclasses import dataclass
from typing import List
__author__ = "Brian Schlining"
__copyright__ = "Copyright 2019, Monterey Bay Aquarium Research Institute"
@dataclass
class Camera:
@hohonuuli
hohonuuli / RequestPager.java
Created May 2, 2019 04:43
RequestPager code for Medium article
import io.reactivex.Observable;
import io.reactivex.subjects.PublishSubject;
import io.reactivex.subjects.Subject;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.function.Supplier;
@hohonuuli
hohonuuli / SchedulingPageRequests.java
Last active May 2, 2019 04:45
Scheduling Page Requests example code
// This function takes a page, which defines the limit and offset
// and makes the web service call using that limit/offset
Function<RequestPager.Page, List<MyObject>> function = (page) -> {
try {
return service.someApiCall(page.getLimit(), page.getOffset())
.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
} catch (Exception e) {
throw new RuntimeException("A page request failed", e);
}
};
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 ""