This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MySQL(val handle: SlickDatabase) extends DataBaseComponent { | |
val Driver = MySQLDriver | |
val dialect = MySqlDatabaseDialect | |
} | |
object MySQL { | |
val driverName = "com.mysql.jdbc.Driver" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*/1 * * * * /usr/bin/flock -n /var/lock/my_time /usr/bin/python /path/to/script/my_time.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")') | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |