Skip to content

Instantly share code, notes, and snippets.

View ShaneDelmore's full-sized avatar

Shane Delmore ShaneDelmore

View GitHub Profile
1
Cargo.lock
Cargo.toml
src
target
1
Cargo.lock
Cargo.toml
src
target
@ShaneDelmore
ShaneDelmore / typeclass.scala
Created June 20, 2018 00:05
Typeclass example
trait Longable{ def toLong(): Long }
implicit class IntCanLong(int: Int) extends Longable {
def toLong(): Long = int.toLong
}
implicit class StringCanLong(str: String) extends Longable {
def toLong(): Long = str.toInt.toLong
}
@ShaneDelmore
ShaneDelmore / foo.scala
Created June 19, 2018 22:58
Disable good code red in intellij (keywords: squigglies, squiggley, squiggle, disable, suppress)
/*_*/
val 1 = "Hello"
/*_*/
@ShaneDelmore
ShaneDelmore / &&.scala
Created January 29, 2018 16:28 — forked from olafurpg/&&.scala
Having fun with Scala extractor objects. The && combinator can be used to merge multiple extractors into one MEGA extractor.
object && {
def unapply[A](e: A) = Some(e -> e)
def test() {
val greaterThan10 = Find[Int](_ > 10)
List(1, 2, 11, 3) match {
// All must succeed
case greaterThan10(ten) && Last(last) && Head(head) =>
println(ten) // 11
println(last) // 3
#!/bin/bash
#echo "Start Export Process"
#echo "Log into Keybase..."
keybase login
#echo "Exporting your PGP keys..."
keybase pgp export -o keybase.public.key
keybase pgp export -s -o keybase.private.key
@ShaneDelmore
ShaneDelmore / tut.md
Created May 1, 2017 17:14
Single threaded executor for Tut docs
import scala.concurrent.Future
import java.util.concurrent.Executor
import scala.concurrent.ExecutionContext
//Please don't do this in production code!  It is used to execute
//the documentation code synchronously to generate more readable output
implicit val synchronousExecutionContext = ExecutionContext.fromExecutor(new Executor {
  def execute(task: Runnable) = task.run()
})
@ShaneDelmore
ShaneDelmore / clippy.json
Created April 27, 2017 21:08
Imclipitly Matryoshka
{
"version":"0.1",
"advices":[{
"error":{
"type":"notAMember",
"what":"value step",
"notAMemberOf":".*Partial.*"
},
"text":"You may need to import matryoshka.instances._",
"library":{

Keybase proof

I hereby claim:

  • I am shanedelmore on github.
  • I am shanedelmore (https://keybase.io/shanedelmore) on keybase.
  • I have a public key ASCjD-4yeo9keUkltfhWRotlwERtREAP0_piYbBacvX0cAo

To claim this, I am signing this object:

@ShaneDelmore
ShaneDelmore / Import.scala
Created January 17, 2017 06:12
More fun with scalatest
package scalafix.util
import scala.collection.immutable.Seq
import scala.meta._
import syntax._
object Import {
def remove(prefix: String, term: String): PartialFunction[Tree, Tree] = {
case b @ q"{ ..$stats }" /* verify targeted term exists */ =>
val newStats: Seq[Stat] = stats.collect {