Skip to content

Instantly share code, notes, and snippets.

@kevinwright
kevinwright / Boot.scala
Created November 28, 2011 19:30
Scalate in Akka
...
lazy val engine: TemplateEngine = {
val ctx = CaptureContext.context.get
val srcDirectories = ctx.getRealPath("/") match {
case path: String => List(new File(path))
case null => List()
}
println("Scalate got src directories " + srcDirectories)
new TemplateEngine(srcDirectories)
@kevinwright
kevinwright / scaladays2014.md
Last active March 8, 2018 20:25
Scaladays 2014 slides

As compiled by Kevin Wright a.k.a @thecoda

(executive producer of the movie, and I didn't even know it... clever huh?)

please, please, please - If you know of any slides/code/whatever not on here, then ping me on twitter or comment this Gist!

This gist will be updated as and when I find new information. So it's probably best not to fork it, or you'll miss the updates!

Monday June 16th

@kevinwright
kevinwright / keybase.md
Last active February 13, 2018 14:54
keybase.md

Keybase proof

I hereby claim:

  • I am kevinwright on github.
  • I am thecoda (https://keybase.io/thecoda) on keybase.
  • I have a public key whose fingerprint is 7B0A E482 1479 D389 A452 49B7 EF27 0EC3 7CC6 9FE9

To claim this, I am signing this object:

@kevinwright
kevinwright / Main.scala
Created May 31, 2016 13:05
Improved syntax for scopt
case class Params(
mode: String = "",
input: Option[File] = None,
output: Option[File] = None,
keyRing: Option[File] = None,
key: String = "",
password: String = "",
genDigest: Boolean = false
) {
def withEncrypt() = this.copy(mode = "encrypt")
@kevinwright
kevinwright / AsyncUtils.scala
Last active April 14, 2016 21:19
ThrottledRunner
import scala.collection.generic.CanBuildFrom
import scala.concurrent.{ExecutionContext, Future}
import scala.language.higherKinds
import scala.util.{Failure, Success}
object AsyncUtils {
/**
* A subtle variant on `Future.traverse` that forces the Futures to be executed one at a time
* instead of allowing parallelism
@kevinwright
kevinwright / gist:8505936
Last active January 3, 2016 18:59
ScalaOnIos.scala
implicit class IosInt(i: Int) extends AnyVal {
def s: Int = i + 1
}
val test: String = "I have an iPhone " + 4.s
block"""
| implicit def fnFromProduct${N}[A,..Z]: Aux[(A::..Z) => Res, (A,..Z) => Res] = new FnFromProduct[(A::..Z) => Res] {
| type Out = (A,..Z) => Res
| def apply(hf : (A::..Z) => Res): Out = (a:A,..z:Z) => hf(a::..z)
| }
"""
block"""
| implicit def fnFromProduct«N»[«A..Z»]: Aux[(«A::Z») => Res, («A..Z») => Res] = new FnFromProduct[(«A::Z») => Res] {
| type Out = («A..Z») => Res
| def apply(hf : («A::Z») => Res): Out = («a:A..z:Z») => hf(«a::z»)
| }
"""
@kevinwright
kevinwright / gist:8268045
Created January 5, 2014 13:16
string interpolation with "creatively" named values
// intended for boilerplate.scala in shapeless...
val arity = 3
val N = arity
val typeVars = (0 until arity) map (n => (n+'A').toChar)
// = Vector(A, B, C)
val `A..Z` = typeVars.mkString(", ")
// = "A, B, C"
@kevinwright
kevinwright / arch-install-non-efi.md
Last active December 24, 2015 23:49
Arch install script for a minimal BIOS-based (as opposed to EFI) system. Gets as far as the first boot with network configured, and no users or packages installed beyond those necessary to complete the installation.

Phase 0: Enable ssh service

systemctl start sshd
passwd
ip addr

From this point on, SSH into the (dhcp-assigned) IP - it makes it easier to copy/paste

Phase 1: Prepare System