Skip to content

Instantly share code, notes, and snippets.

View timperrett's full-sized avatar
🚧

Timothy Perrett timperrett

🚧
View GitHub Profile
@timperrett
timperrett / coproduct.scala
Created September 15, 2016 11:55
Example of using CoProducts of Free algebras
package example
/*
* REQUIRES KIND PROJECTOR 0.9.0 (untested with any other version, but should be easily adaptable)
*/
import scalaz._, Scalaz._
sealed abstract class FooOp[A]
extends Product with Serializable
/* discovered njoin on this thread: https://github.com/functional-streams-for-scala/fs2/issues/251 - which also cites (adjusted to match example below):
If we increase maxQueued up to 100, and `handle` emits multiple `A` values, up to 100 will be prefetched
before we block on the consumer of results. (Not actually blocking by occupying a thread, but semantically blocking.)
If we increase maxOpen to 50, then we can have 50 `item` streams processing concurrently.
*/
import scalaz.stream.{Sink,Process,sink,channel}
import scalaz.stream.nondeterminism.njoin
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* elrepo: repos.lax-noc.com
* epel: mirror.sfo12.us.leaseweb.net
Resolving Dependencies
--> Running transaction check
---> Package docker-engine.x86_64 0:1.9.1-1.el7.centos will be installed
--> Processing Dependency: docker-engine-selinux >= 1.9.1-1.el7.centos for package: docker-engine-1.9.1-1.el7.centos.x86_64
--> Processing Dependency: selinux-policy >= 3.13.1-23 for package: docker-engine-1.9.1-1.el7.centos.x86_64
--> Running transaction check
SetCookies(Cookie("thing.state", r.value,
path = Some("/"),
domain = Some("localhost"),
secure = Some(true),
maxAge = Some(604800) // 1 week
)) ~> Ok
package com.rr.experiment
import org.specs2.ScalaCheck
import org.specs2.mutable._
import org.scalacheck._
import scalaz._
import scodec._
@timperrett
timperrett / unfiltered-webjars.md
Created April 29, 2015 20:01
Using WebJars with Scala Unfiltered

Add the relevant webjars to your build file:

  libraryDependencies += "org.webjars.bower" % "angular" % "1.3.15"

Add the resources to your server definition:

unfiltered.netty.Server
import scalaz._, Scalaz._
import scalaz.concurrent.Task
val a: String \/ Int = 1.right
def f(in: Int): Task[Doulbe] = Task.now(in.toDouble)
// scalaz.Unapply[scalaz.Traverse,scalaz.\/[String,Int]]{type M[X] = scalaz.\/[String,X]; type A = Int}#M[Double]
a.traverseU(f).run
@timperrett
timperrett / gist:aaaf6f224ea2cd0c8197
Created October 17, 2014 18:46
boot2docker supported CAs
subject= /O=Root CA/OU=http://www.cacert.org/CN=CA Cert Signing Authority/[email protected]
subject= /O=CAcert Inc./OU=http://www.CAcert.org/CN=CAcert Class 3 Root
subject= /C=DE/ST=Hessen/L=Fulda/O=Debconf/CN=Debconf CA/[email protected]
subject= /C=AT/O=A-Trust Ges. f. Sicherheitssysteme im elektr. Datenverkehr GmbH/OU=A-Trust-nQual-03/CN=A-Trust-nQual-03
subject= /CN=ACEDICOM Root/OU=PKI/O=EDICOM/C=ES
subject= /C=CO/O=Sociedad Cameral de Certificaci\xC3\xB3n Digital - Certic\xC3\xA1mara S.A./CN=AC Ra\xC3\xADz Certic\xC3\xA1mara S.A.
subject= /C=IT/L=Milan/O=Actalis S.p.A./03358520967/CN=Actalis Authentication Root CA
subject= /C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
subject= /C=SE/O=AddTrust AB/OU=AddTrust TTP Network/CN=AddTrust Class 1 CA Root
subject= /C=SE/O=AddTrust AB/OU=AddTrust TTP Network/CN=AddTrust Public CA Root
λ vagrant status
Current machine states:
deis-1 running (virtualbox)
deis-2 running (virtualbox)
deis-3 running (virtualbox)
This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.
@timperrett
timperrett / gist:8cf6c77440eba18a47d0
Created September 15, 2014 18:45
Install Oracle JDK from the command line
wget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie;" http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-macosx-x64.dmg