Skip to content

Instantly share code, notes, and snippets.

View tinoadams's full-sized avatar

Tino tinoadams

View GitHub Profile
@tinoadams
tinoadams / speedtest-influx.sh
Last active July 31, 2021 02:02
Write results of Ookla Speedtest to InfluxDB
#!/bin/bash
set -xeo pipefail
# Get epoch
DATE="$(date +%s)"
# Set this hostname
HOSTNAME=`hostname --short`

Keybase proof

I hereby claim:

  • I am tinoadams on github.
  • I am tinoadams (https://keybase.io/tinoadams) on keybase.
  • I have a public key whose fingerprint is CE3D E075 7DED D8E2 BE1A F03B C926 DB25 40B4 C0EB

To claim this, I am signing this object:

@tinoadams
tinoadams / start_artifactory.sh
Created February 16, 2016 01:16
Run the latest JFrog Artifactory registry inside a Docker container with recommended volumes mounted to the hosts current directory and an initial copy of the default Artifactory configs extracted form the Artifactory image
#!/bin/bash -e
export ARTIFACTORY_IMAGE='jfrog-docker-reg2.bintray.io/jfrog/artifactory-registry:latest'
export ARTIFACTORY_CONTAINER_NAME='art'
export ARTIFACTORY_HOST_HOME="$PWD"
export ARTIFACTORY_HOME=/var/opt/jfrog/artifactory
echo "Artifactory home directory on the host: $ARTIFACTORY_HOST_HOME"
docker rm -f $ARTIFACTORY_CONTAINER_NAME &> /dev/null || echo "no previous Artifactory container not running... moving along"
@tinoadams
tinoadams / using.scala
Created May 31, 2012 16:15
Using the using package
import java.io.BufferedReader
import java.io.ByteArrayInputStream
import java.io.InputStreamReader
import utils.using._
object Main extends App {
// the "used" instance is passed to the body i.e. "in" is of type BufferedReader
using(new BufferedReader(new InputStreamReader(new ByteArrayInputStream("Testing using".getBytes)))) { in =>
println(in.readLine)
@tinoadams
tinoadams / package.scala
Created May 31, 2012 16:01
"Emulating" C# using keyword in Scala
package utils.using
import java.sql.Connection
import javax.persistence.EntityManager
/**
* Declares an object that can be used.
*/
trait Usable[+T] {
@tinoadams
tinoadams / AustralianPostcodeVO.scala
Created May 27, 2012 23:38
Value object sample with parsing and validation
package samples
case class AustralianPostcode private (value: String) {
require(value.matches("""\d{4}"""))
}
object AustralianPostcode {
def parse(value: String) = new AustralianPostcode(value.trim)
}
@tinoadams
tinoadams / SetReceiveTimeoutTest.scala
Created May 27, 2012 03:17
Shows the behaviour of setReceiveTimeout
import java.util.Date
import akka.actor.Actor
import akka.actor.ActorSystem
import akka.actor.Props
import akka.actor.ReceiveTimeout
import akka.util.duration._
class MyActor extends Actor {
context.setReceiveTimeout(5 seconds)
@tinoadams
tinoadams / Main.scala
Created October 17, 2011 02:41
Sample case class with companion object that sanitizes parameters before instantiating new case class instance
package test
abstract case class AustralianPostcode private (value: String) {
require(value.matches("""\d{4}"""))
}
object AustralianPostcode {
def apply(value: String) = new AustralianPostcode(value.trim){}
}
object Main extends App {