Skip to content

Instantly share code, notes, and snippets.

View cvogt's full-sized avatar

Jan Christopher Vogt cvogt

  • Symbiont.io
View GitHub Profile
@cvogt
cvogt / ProductionConfig.scala
Created October 6, 2016 19:32
Scala configuration with an external service
object ProductionConfig{
def main(args: Array[String]): Unit = {
Application.run(
Config(
ConfigService.getString("db.host"),
ConfigService.getInt("db.port")
)
)
}
}
@cvogt
cvogt / ProductionConfig.scala
Last active October 6, 2016 23:35
serializing scala configuration
object ProductionConfig{
def main(args: Array[String]): Unit = {
val config = Config("db.production-server.com",12345)
if(args(0) == "serialize")
println( toJson( config ) )
else
Application.run( config )
}
}
@cvogt
cvogt / Application.scala
Last active October 9, 2016 19:06
decoupled configuration code structure
object Application{
def run(config: Config): Unit = {
val db = connectToDb( config.dbHost, config.dbPort )
...
}
}
case class Config(
dbHost: String,
port: Int
)
@cvogt
cvogt / Application.scala
Last active October 9, 2016 19:05
configuration managed by the application
object Application{
def main(args: Array[String]): Unit = {
val config = Config.get( args(0) )
val db = connectToDb( config.dbHost, config.dbPort )
...
}
}
object Config{
def get(config: String) = {
@cvogt
cvogt / Application.scala
Last active October 6, 2016 23:34
traditional config file code structure
object Application{
def main(args: Array[String]): Unit = {
val config = Config.get( args(0) )
val db = connectToDb( config.dbHost, config.dbPort )
...
}
}
object Config{
def get(config: String) = {
val reader = config_library.ConfigReader( config + “.conf” )
@cvogt
cvogt / sbt-cli
Created September 6, 2016 17:04
~/bin/sbt-cli better sbt cli interop
#!/bin/sh
sbt --error ";set showSuccess := false; $*"
@cvogt
cvogt / demo.sh
Created September 6, 2016 06:56 — forked from paulp/demo.sh
Enabling sbt plugins from the command line in any sbt project
% sbtx dependencyGraph
... blah blah ...
[info] *** Welcome to the sbt build definition for Scala! ***
[info] Check README.md for more information.
[error] Not a valid command: dependencyGraph
[error] Not a valid project ID: dependencyGraph
% sbtx -Dplugins=graph dependencyGraph
... blah blah ...
@cvogt
cvogt / Build.scala
Created August 17, 2016 19:00
Scalable code-generation
import sbt._
import Keys._
import Tests._
object stagedBuild extends Build {
lazy val mainProject = Project(
id="main",
base=file("."),
settings = sharedSettings ++ Seq(
slick <<= codeGenTask, // register manual sbt command
@cvogt
cvogt / gist:61f13dbf79202fee6568d8dd6aab5bab
Last active July 26, 2016 14:18
SynchronousExecutionContext - for debugging
import scala.concurrent._
import scala.concurrent.duration._
trait SynchronousExecutionContext
object SynchronousExecutionContext extends ExecutionContext with SynchronousExecutionContext {
def execute( runnable: Runnable ): Unit = runnable.run
def reportFailure( cause: Throwable ): Unit = throw new Exception( cause )
}
# name: Agnoster
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for FISH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://gist.github.com/1595572).
## Set this options in your config.fish (if you want to :])