Skip to content

Instantly share code, notes, and snippets.

import java.net.InetSocketAddress
import java.util.concurrent.TimeUnit
import com.codahale.metrics.graphite.{GraphiteReporter, Graphite}
import com.codahale.metrics.{JmxReporter, MetricRegistry, Slf4jReporter}
import org.slf4j.LoggerFactory
import play.api.libs.concurrent.Akka
import services.LogIt
import scala.concurrent.duration._
@scalway
scalway / play.scala
Last active April 18, 2017 08:18 — forked from lihaoyi/play.scala
play.scala
/**
* Single-file play framework application! Make sure everything
* works, as this is the test case that un-earthed #371
*/
import $ivy.`com.typesafe.play::play:2.5.14`
import $ivy.`com.typesafe.play::play-netty-server:2.5.14`
import $ivy.`org.scalaj::scalaj-http:2.2.1`
import play.core.server._, play.api.routing.sird._, play.api.mvc._
import scalaj.http._
@scalway
scalway / Bootstrap3.scala
Last active May 19, 2018 19:06
bootstrap3 scalatags pug'like heler.
/**
* Copyright 2017 Scalway Krzysztof Pecyna
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
trait DefaultModule extends mill.scalalib.ScalaModule {
//def scalaVersion = "2.12.4"
//def scalaJSVersion: T[String] = "0.6.22"
}
def main() = ()
@scalway
scalway / MagnoliaDefault.scala
Created April 27, 2018 11:02
Magnolia - more complicated Default example
package example
/* Magnolia, version 0.7.1. Copyright 2018 Jon Pretty, Propensive Ltd.
*
* The primary distribution site is: http://co.ntextu.al/
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@scalway
scalway / UPickleMagnoliaDerive.scala
Last active June 28, 2018 10:32
UPickle Magnolia Derive
package rabbi
import magnolia._
import ujson.{ObjVisitor, Visitor}
import upickle.{Api, AttributeTagged}
import scala.language.experimental.macros
import scala.reflect.ClassTag
trait UpickleSupportCommon {
java.lang.StackOverflowError
at scala.reflect.internal.Types$Type.isStable(Types.scala:271)
at scala.tools.nsc.typechecker.Typers$Typer.expectsStable$1(Typers.scala:507)
at scala.tools.nsc.typechecker.Typers$Typer.isStableContext(Typers.scala:514)
at scala.tools.nsc.typechecker.Typers$Typer.typedThis$1(Typers.scala:4702)
at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5374)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5387)
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:712)
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5423)
at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5450)
@scalway
scalway / gist:07cc13a4c6b20025c001d3d71ac137b5
Last active October 2, 2018 13:20
scalajs-compilation-error-dashboard.txt
[info] Full optimizing /app-server/app-dashboard/target/scala-2.11/app-dashboard-opt.js
[debug] Linker: Compute reachability: 827080 us
java.lang.StackOverflowError
at org.scalajs.core.ir.Serializers$Deserializer.readTree(Serializers.scala:686)
at org.scalajs.core.ir.Serializers$Deserializer.readTreeFromTag(Serializers.scala:750)
at org.scalajs.core.ir.Serializers$Deserializer.readTree(Serializers.scala:687)
at org.scalajs.core.ir.Serializers$Deserializer.readTreeFromTag(Serializers.scala:752)
at org.scalajs.core.ir.Serializers$Deserializer.readTree(Serializers.scala:687)
at org.scalajs.core.ir.Serializers$Deserializer$$anonfun$readTrees$1.apply(Serializers.scala:928)
at org.scalajs.core.ir.Serializers$Deserializer$$anonfun$readTrees$1.apply(Serializers.scala:928)
@scalway
scalway / web-audio-fetch-stream.js
Last active January 31, 2019 11:13 — forked from revolunet/web-audio-fetch-stream.js
Web Audio streaming with fetch API
//
// loads remote file using fetch() streams and "pipe" it to webaudio API
// remote file must have CORS enabled if on another domain
//
// mostly from http://stackoverflow.com/questions/20475982/choppy-inaudible-playback-with-chunked-audio-through-web-audio-api
//
function play(url) {
var context = new (window.AudioContext || window.webkitAudioContext)();
@scalway
scalway / watchDiff.scala
Last active August 4, 2023 09:49
scala ammonite script that implement `watch -d ""` that shows only diffs. I was using it to see changes in `lsof -p SOMEPROCID` to watch if there are any leaks in my app.
//> using toolkit latest
//> using dep io.github.java-diff-utils:java-diff-utils:4.12
//> using dep com.lihaoyi::fansi::0.4.0
// use like this: scala-cli run . -- 200 lsof -p 28482
import com.github.difflib.*
import com.github.difflib.patch.*
import fansi.*
import os.*