Skip to content

Instantly share code, notes, and snippets.

class MySQL(val handle: SlickDatabase) extends DataBaseComponent {
val Driver = MySQLDriver
val dialect = MySqlDatabaseDialect
}
object MySQL {
val driverName = "com.mysql.jdbc.Driver"
}
class H2(val handle: SlickDatabase) extends DataBaseComponent {
val Driver = H2Driver
val dialect = H2DatabaseDialect
override def entityName(name: String): String = name.toUpperCase()
}
object H2 {
val driverName = "org.h2.Driver"
}
trait DataBaseComponent {
// the actual Slick driver (e.g. H2 or MySQL)
val Driver: ExtendedDriver
// dialect specific to this driver for functions that Slick does not support
// Usage will be discussed in future blog post
val dialect: DatabaseDialect[_]
// A database instance for which connections can be created.
// Encapsulates either a DataSource or parameters for DriverManager.getConnection().
val handle: SlickDatabase
// MySQL and H2 have different preferences on casing the table and column names.
*/1 * * * * /usr/bin/flock -n /var/lock/my_time /usr/bin/python /path/to/script/my_time.py
import pycurl
import os
import socket
from urllib import pathname2url
import json
import urllib2
# in this specific case we take an average over two hours of the mean(99) of statsd label named "some.thing.total"
target=pathname2url('summarize(stats.timers.some.thing.total.mean_99,"2hour","avg")')
lazy val currentVersion: ServiceVersion = current.mode match {
case Mode.Test = ServiceVersion("Test mode service")
case _ = ServiceVersion(io.Source.fromURL(Play.resource("app_version.txt").get).mkString)
}
lazy val compilationTime: DateTime = current.mode match {
case Mode.Test = currentDateTime
case _ =
val timeStr = io.Source.fromURL(Play.resource("app_compilation_date.txt").get).mkString
DateTimeFormat.forPattern("E, dd MMM yyyy HH:mm:ss Z")
import org.joda.time.{DateTime, DateTimeZone, LocalDate, LocalTime}
import org.joda.time.format.DateTimeFormat
...
val BUILD_DATETIME_FORMAT = DateTimeFormat.forPattern("yyyyMMdd-HHmm")
.withLocale(Locale.ENGLISH)
.withZone(DateTimeZone.forID("America/Los_Angeles"))
val buildTime = BUILD_DATETIME_FORMAT.print(new DateTime(DateTimeZone.forID("America/Los_Angeles")))
val appVersion = "%s-%s-%s".format(buildTime,
"git rev-parse --abbrev-ref HEAD".!!.trim, "git rev-parse --short HEAD".!!.trim)
val PT = DateTimeZone.forID("America/Los_Angeles")
def matching(str: String): Boolean = str match {
case "another string" => false
case "yet another" => false
case "not this" => false
case "hello world" => true
case other => false
}
def iffing(str: String): Boolean = {
if (str == "another string") false
@eishay
eishay / gist:7344161
Last active December 27, 2015 14:59
Options for Play's build script play/framework/build for faster compilation
java ${DEBUG_PARAM} ${JAVA_OPTS} -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError -server \
-XX:ReservedCodeCacheSize=2g -Xmx4g -Xss4M -XX:MaxPermSize=512M -XX:+DoEscapeAnalysis \
-XX:+UseCompressedOops -XX:+CMSClassUnloadingEnabled -XX:+UseCodeCacheFlushing \
-Dplay.version="${PLAY_VERSION}" -Dplay.version="${PLAY_VERSION}" -Dsbt.ivy.home=`dirname $0`/../repository \
-Dplay.home=`dirname $0` -Dsbt.boot.properties=`dirname $0`/sbt/sbt.boot.properties \
-jar `dirname $0`/sbt/sbt-launch.jar "$@"
import org.joda.time.{DateTime, DateTimeZone, LocalDate, LocalTime}
import org.joda.time.format.DateTimeFormat
...
val BUILD_DATETIME_FORMAT = DateTimeFormat.forPattern("yyyyMMdd-HHmm")
.withLocale(Locale.ENGLISH)
.withZone(DateTimeZone.forID("America/Los_Angeles"))
val buildTime = BUILD_DATETIME_FORMAT.print(new DateTime(DateTimeZone.forID("America/Los_Angeles")))
val appVersion = "%s-%s-%s".format(buildTime,
"git rev-parse --abbrev-ref HEAD".!!.trim, "git rev-parse --short HEAD".!!.trim)
val PT = DateTimeZone.forID("America/Los_Angeles")