Skip to content

Instantly share code, notes, and snippets.

@mrbald
mrbald / remarked.html
Created September 19, 2018 08:31
Remarkjs-based presentation bootstrap boilerplate
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body { font-family: 'Droid Serif'; }
@mrbald
mrbald / retail.sh
Last active May 22, 2020 14:23
A script to incrementally poll a log file of timestamp-prefixed text records
#!/bin/bash
#
# A script to incrementally poll a log file.
# Subsequent invocations print lines added since the previous invocation.
# An assumption is that log lines begin with a timestamp 23 characters long (see/tweak the TS_LEN variable below).
#
# The state is stored in the file <original_filename>.seen as a last_line_no + last_timestamp pair last seen.
# If the state file is not there, or the line_no in the target file has the last_timestamp
# different from the one in the state file, then the file is printed from the line 1.
@mrbald
mrbald / timeit.scala
Last active October 2, 2018 13:14 — forked from atmb4u/timeit.scala
timeit for scala
def timeit (warmups: Int, trials: Int) (block: => Unit): Unit = {
import Math.{min,max}
for (i <- 1 to warmups) block
var total = 0.0
var best = Long.MaxValue
var worst = Long.MinValue
for (i <- 1 to trials) {
val beg = System.nanoTime()
@mrbald
mrbald / ts2dt.java
Created September 10, 2018 15:38
Epoch millis to UTC datetime converter in Java
import static java.time.Instant.ofEpochMilli;
import static System.out;
class ts2dt {
public static void main(String... args) {
out.println(ofEpochMilli(Long.valueOf(args[0])));
}
}
@mrbald
mrbald / pom.xml
Created August 22, 2018 10:57
Strict Dependencies Check with Maven
<project ...>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>...</version>
<executions>
<execution>
<id>analyze</id>
@mrbald
mrbald / pom.xml
Last active August 22, 2018 10:55
Strict Warnings Policy with Maven
<project ...>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>...</version>
<configuration>
<compilerArgs>
<arg>-Xlint:all,-options,-path,-sunapi</arg>
@mrbald
mrbald / TimeIt.java
Last active October 8, 2018 08:33
Java 8 TimeIt combo
import static java.lang.System.nanoTime;
/*
* Usage:
* final long then = TimeIt.start();
* ...
* final long elapsed = TimeIt.elapsedSince(then);
* recorder.record(elapsed);
*/
public class TimeIt {