Skip to content

Instantly share code, notes, and snippets.

Avatar

Channing Walton channingwalton

View GitHub Profile
@channingwalton
channingwalton / build.sbt
Last active Jan 13, 2020
Scala 2.13 compiler flags
View build.sbt
val scalacOptions ++= Seq(
"-encoding",
"utf-8", // Specify character encoding used by source files.
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-language:existentials", // Existential types (besides wildcard types) can be written and inferred
"-language:experimental.macros", // Allow macro definition (besides implementation and application)
"-language:higherKinds", // Allow higher-kinded types
"-language:implicitConversions", // Allow definition of implicit functions called views
@channingwalton
channingwalton / NonEmptySet.scala
Last active Mar 24, 2018
NonEmptySet Implementation
View NonEmptySet.scala
import cats.data.NonEmptyList
import cats.Eq
import scala.collection.GenTraversableOnce
sealed trait NonEmptySet[T] extends (T => Boolean) {
def head: T
def set: Set[T]
def +(t: T): NonEmptySet[T]
def ++(ts: NonEmptySet[T]): NonEmptySet[T]
View keybase.md

Keybase proof

I hereby claim:

  • I am channingwalton on github.
  • I am channingwalton (https://keybase.io/channingwalton) on keybase.
  • I have a public key ASAzN6zGSraBz_wTqUhbQLqzT4wmAjuy3zGojAOeYGo2Uwo

To claim this, I am signing this object:

@channingwalton
channingwalton / SetPerformance.scala
Created Apr 29, 2017
Benchmark for performance of .toSet
View SetPerformance.scala
package set.performance
import java.util.concurrent.TimeUnit
import scala.concurrent.duration.FiniteDuration
/**
* On my machine the fast method takes < 2 ms, the slow one 2.2s
*/
object SetPerformance {
@channingwalton
channingwalton / keybase.md
Last active Jul 31, 2016
Verification for keybase
View keybase.md

Keybase proof

I hereby claim:

  • I am channingwalton on github.
  • I am channingwalton (https://keybase.io/channingwalton) on keybase.
  • I have a public key ASD_xyZHdprhe-YpLLpvwqvgVW-wFGmVXHZ8fwXP_1soLwo

To claim this, I am signing this object:

@channingwalton
channingwalton / test.html
Created Apr 29, 2016
positive numbers only
View test.html
<SCRIPT language=Javascript>
<!--
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
return charCode > 47 && charCode < 58;
}
//-->
</SCRIPT>
</HEAD>
@channingwalton
channingwalton / RxConcurrency.scala
Created Apr 28, 2016
Some concurrency testing for Rx
View RxConcurrency.scala
package reactive
import java.util.concurrent.TimeUnit
import rx.lang.scala.{Observable, Subject}
import scala.concurrent.duration.Duration
/**
* The problem: can two threads banging away from two sources be merged and have predictable results?
View gist:58ed83cb76ae2b8d699d
21:15:22.745 ERROR akka://ENSIME/user/$b o.e.s.SocketHandler - Error in socket reader:
java.lang.NumberFormatException: For input string: "new Wo"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.8.0_31]
at java.lang.Integer.parseInt(Integer.java:580) ~[na:1.8.0_31]
at java.lang.Integer.valueOf(Integer.java:740) ~[na:1.8.0_31]
at org.ensime.server.FramedStringProtocol$class.readString(FramedStringProtocol.scala:39) ~[server_2.11-0.9.10-SNAPSHOT.jar:0.9.10-SNAPSHOT]
at org.ensime.server.SwankProtocol.readString(SwankProtocol.scala:10) ~[server_2.11-0.9.10-SNAPSHOT.jar:0.9.10-SNAPSHOT]
at org.ensime.server.S≈wankProtocol.read(SwankProtocol.scala:15) ~[server_2.11-0.9.10-SNAPSHOT.jar:0.9.10-SNAPSHOT]
at org.ensime.server.SocketHandler$$anon$1.run(SocketHandler.scala:43) ~[server_2.11-0.9.10-SNAPSHOT.jar:0.9.10-SNAPSHOT]
@channingwalton
channingwalton / Reverse.idr
Created Sep 29, 2014
Reverse an Idris Vect
View Reverse.idr
module Main
rev : Vect n a -> Vect n a
rev Nil = Nil
rev (x :: xs) = (rev xs) ++ (x :: Nil)
main : IO ()
main = putStrLn $ show $ rev [1,2,3]
fails to compile with
You can’t perform that action at this time.