Skip to content

Instantly share code, notes, and snippets.

Avatar

Tino tinoadams

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

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 Feb 16, 2016
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
View start_artifactory.sh
#!/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
Using the using package
View using.scala
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
"Emulating" C# using keyword in Scala
View package.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
Value object sample with parsing and validation
View AustralianPostcodeVO.scala
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
Shows the behaviour of setReceiveTimeout
View SetReceiveTimeoutTest.scala
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 Oct 17, 2011
Sample case class with companion object that sanitizes parameters before instantiating new case class instance
View Main.scala
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 {