Skip to content

Instantly share code, notes, and snippets.

View mikeholler's full-sized avatar

Michael Holler mikeholler

View GitHub Profile
@mikeholler
mikeholler / DatabaseHelper.java
Created March 17, 2014 15:20
Maintain only one static database connection in Android. From http://touchlabblog.tumblr.com/post/24474750219/single-sqlite-connection
public class DatabaseHelper extends OrmLiteSqliteOpenHelper
{
private static DatabaseHelper instance;
public static synchronized DatabaseHelper getHelper(Context context)
{
if (instance == null)
instance = new DatabaseHelper(context);
return instance;
Cheat sheet for UML diagramming: From http://broken.build/assets/images/posts/cheat_sheet4.png
@mikeholler
mikeholler / Scratch.java
Created November 21, 2014 17:15
Profiling String Comparison vs. Class.isAssignableFrom(...) Comparison.
import java.util.Collection;
import java.util.List;
import java.util.Scanner;
public final class Scratch {
public static final String CORRECT_CLASS_NAME = List.class.getCanonicalName();
public static final String INCORRECT_CLASS_NAME = Scanner.class.getCanonicalName();
@mikeholler
mikeholler / MatlabTimeHelper.java
Created February 7, 2014 15:37
Convert from MATLAB serial date time to Unix UTC milliseconds.
public class MatlabTimeHelper {
public static final int UNIX_EPOCH_START_MATLAB_DAYS = 719529;
public static long matlabToMillis(double matlab) {
return (long) (matlab - UNIX_EPOCH_START_MATLAB_DAYS) * 24 * 3600 * 1000;
}
public static double millisToMatlab(long millis) {
return millis / (24.0 * 3600 * 1000) + UNIX_EPOCH_START_MATLAB_DAYS;
@mikeholler
mikeholler / antora-generate-wrapper.js
Created September 12, 2019 20:24
Wrapper that allows for --author-mode argument.
#!/usr/bin/env node
/**
* This is a wrapper to the `antora generate` command line tool that adds some
* functionality not otherwise present in antora.
*
* Before getting into that, one restriction is that the playbook.yml file MUST
* be the first argument to this command, otherwise this script will not work
* correctly. Other than that small restriction, all other uses of
* `antora generate` are supported here.
*
@mikeholler
mikeholler / dataclass_utils.py
Created January 8, 2020 21:25
Require keyword or positional arguments for Python dataclasses
from dataclasses import is_dataclass
from typing import TypeVar, Type, Callable, List, Dict, Any
_T = TypeVar("_T")
_Self = TypeVar("_Self")
_VarArgs = List[Any]
_KWArgs = Dict[str, Any]
def _kwarg_only_init_wrapper(
import asyncio
import datetime as dt
import logging
import os
import pyracing
import sys
from pyracing.client import Client
from pyracing.response_objects.chart_data import IRating
from pyracing.constants import ChartType
from pyracing.constants import Category
@mikeholler
mikeholler / build.gradle
Created February 3, 2014 22:31
Task to print project version. Run using `./gradlew -q version`.
// Task to get current version of the project.
task version(type: VersionTask)
class VersionTask extends DefaultTask {
@TaskAction
def version() {
println project.version
}
}