Skip to content

Instantly share code, notes, and snippets.

View andyczerwonka's full-sized avatar

Andy Czerwonka andyczerwonka

View GitHub Profile
val entries = readings collect {
case r if sensorNames.contains(r.sensor) => (str2date(r.date), sensorNames(r.sensor), r.metric)
}
@Test
public void test_singleProductRequested() {
production(10, "Gas", "mcf/d", "2013-01-01", "2014-01-01", 1000.0);
txn.dataBuilder().shrinkage(_project).assetProduct(_asset, "Gas").shrinkage(2013, 3, 1.0)
.shrinkage(2013, 6, 0.0).end();
_test //
.raw("mcf", "Gas") //
.sales("mcf", "Gas") //
private def send(invitation: Invitation, to: User, emailer: Emailer) = {
val url = s"${Application.configuration.baseUrl}/${invitation.id}"
val htmlBody = template.replace("{{url}}", url)
emailer.send(user.email, invitation.subject, htmlBody)
}
object Application {
lazy val configuration: ApplicationConfiguration = expensiveLoadOperation()
}
class InvitationApi() extends Controller {
def invite() = Action(parse.json) { request =>
val payload = request.body.as[UserId]
val baseUrl = ApplicationConfiguration.get(this).baseUrl
sendInvitation(payload.userId, baseUrl) match {
case Success(invitation) => Ok
case Failure(e) => BadRequest(e.getMessage)
}
}
object ApplicationConfiguration {
private[this] lazy val configuration = expensiveLoadOperation()
def get(excuse: Controller): ApplicationConfiguration = configuration
def get(excuse: ImportProvider): ApplicationConfiguration = configuration
}
[Fact]
public void DepreciationCalculation_NoDepreciationEntries()
{
_test
.MonthlyWindow("2016-01-01", 12)
.DecliningBalance(depreciationRate: 0.0)
.CapexEntry("2016-01-01", 100)
.Expect(
"2016-01-01 0",
"2016-01-02 0",
@andyczerwonka
andyczerwonka / Tyrion.scala
Last active March 14, 2016 23:14
Example of class that isn't being called
import akka.actor._
import javax.inject._
import database.MongoEnvironment
import play.api.inject.ApplicationLifecycle
import play.api._
import scala.concurrent.ExecutionContext
@Singleton
@andyczerwonka
andyczerwonka / nginx.conf
Created January 9, 2016 00:54 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
2015-11-14 03:21:58 -0500 [ERROR] from play.core.server.netty.PlayDefaultUpstreamHandler in New I/O worker #4 - Exception caught in Netty
java.lang.IllegalArgumentException: invalid version format: ?+??H???9 ?
at org.jboss.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:94) ~[io.netty.netty-3.10.4.Final.jar:na]
at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[io.netty.netty-3.10.4.Final.jar:na]
at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[io.netty.netty-3.10.4.Final.jar:na]
at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:191) ~[io.netty.netty-3.10.4.Final.jar:na]
at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:102) ~[io.netty.netty-3.10.4.Final.jar:na]
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[io.netty.netty-3.10.4.Final.jar:na]
at org.jboss.netty.handler.codec.replay.Re