Skip to content

Instantly share code, notes, and snippets.

View tindzk's full-sized avatar

Tim Nieradzik tindzk

View GitHub Profile
@tindzk
tindzk / PrefixClasses.scala
Created July 7, 2018 11:35
Prefix all referenced CSS tags in HTML files
import pine._
import better.files._
// Place file in src/
object PrefixClasses extends App {
File.currentWorkingDirectory.glob("*.html").foreach { file =>
val newContent = HtmlParser.fromString(file.contentAsString).map {
case t: Tag[_] => t.`class`.update(_.map(cls =>
if (cls.startsWith("sk-")) cls else "sk-" + cls))
case n => n
@tindzk
tindzk / pine-bloop.txt
Created May 6, 2018 17:47
Compiling Pine with Bloop
$ bloop test pineJVM --verbose
[D] Scheduled compilation of 'pineJVM' starting at 19:44:29.349.
[D] No changes
[D] Scheduled compilation of 'pineJVM-test' starting at 19:44:29.356.
[D] Full compilation, no sources in previous analysis.
[D] All sources are invalidated.
[D] Recompiling all 11 sources: invalidated sources (11) exceeded 50.0% of all sources
Compiling 11 Scala sources to /home/tim/dev/pine/.bloop/pineJVM/scala-2.12/test-classes ...
[D] Getting ch.epfl.scala:compiler-bridge_2.12:1.1.1+49-1c290cbb:compile for Scala 2.12.4-bin-typelevel-4
[D] Getting ch.epfl.scala:compiler-bridge_2.12:1.1.1+49-1c290cbb:compile for Scala 2.12.4-bin-typelevel-4
import scala.collection.mutable
import scala.collection.JavaConverters._
import org.eclipse.jgit.diff.{HistogramDiff, Sequence, SequenceComparator}
val histogramDiff = new HistogramDiff()
histogramDiff.setFallbackAlgorithm(null)
val deltas = histogramDiff.diff(
new DataListComparator[Char],
object CodeGenFunctions extends js.Object {
def fn() = println("hello")
}
// JavaScript output
function $s_Lminicol_CodeGenFunctions$__fn__Lminicol_CodeGenFunctions$__V($this) {
$m_Lminicol_package$();
console.log("hello")
}
import org.scalajs.dom.document
object Session {
val CookieName = "SessionId"
val key: String = CookieName
var username: Option[String] = Option(JsGlobals.username)
def get: Option[String] =
document.cookie.split(";").toList.flatMap { part =>
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
/**
* A Service is an abstraction for a small processing unit that takes a request
* and responds asynchronously. The communication is therefore entirely
* message-driven. The messages are epxected to be immutable. A service can
* have an internal state that will not be exposed. Services can be composed
* and requests may be forwarded to other services. The concept is inspired by
* Akka's actors.
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.graphics.g2d.Batch;
@tindzk
tindzk / gist:e2966773aa3e72897204
Last active January 15, 2016 16:35
ScalaRelational benchmarks
> run -i 2 -wi 2 -f 0
SR v1.1.0, Slick v3.0.0
[info] Benchmark Mode Cnt Score Error Units
[info] Test.slickDelete thrpt 2 0,008 ops/ms
[info] Test.slickInsertBatch thrpt 2 0,086 ops/ms
[info] Test.slickInsertSeparate thrpt 2 0,056 ops/ms
[info] Test.slickQuery thrpt 2 0,009 ops/ms
[info] Test.slickUpdate thrpt 2 0,010 ops/ms
[info] Test.srDelete thrpt 2 2,460 ops/ms
@tindzk
tindzk / Monokai.colorscheme
Last active November 23, 2015 23:22 — forked from wdullaer/Monokai.colorscheme
Monokai Konsole Colourscheme
[Background]
Color=40,40,40
[BackgroundIntense]
Color=40,40,40
[Color0]
Color=73,72,62
[Color0Intense]
> publishSigned
[info] Packaging /Users/tim/dev/widok/target/scala-2.10/root_2.10-0.1-SNAPSHOT-sources.jar ...
[info] Updating {file:/Users/tim/dev/widok/}root...
[info] Done packaging.
[info] Wrote /Users/tim/dev/widok/js/target/scala-2.11/widok_sjs0.6_2.11-0.2.0-SNAPSHOT.pom
[info] Wrote /Users/tim/dev/widok/jvm/target/scala-2.11/widok_2.11-0.2.0-SNAPSHOT.pom
[info] Wrote /Users/tim/dev/widok/target/scala-2.10/root_2.10-0.1-SNAPSHOT.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation