Skip to content

Instantly share code, notes, and snippets.

View joshlemer's full-sized avatar
🏠
Working from home

Josh joshlemer

🏠
Working from home
  • Winnipeg, Canada
View GitHub Profile
package dmap
import scala.reflect.runtime.universe._
import DMap._
class DMap private(underlying: Map[Any, Entry]) {
def get[T](key: Any)(implicit tt: TypeTag[T]): Option[T] = {
underlying.get(key) match {
@joshlemer
joshlemer / main.rs
Created June 30, 2018 17:23
edn_macro
extern crate edn;
extern crate ordered_float;
use edn::Value;
//use std::collections::hash_map::*;
use std::convert::From;
style = IntelliJ
maxColumn = 120
continuationIndent.callSite = 2
continuationIndent.defnSite = 2
align.openParenDefnSite = false
align.openParenCallSite = false
assumeStandardLibraryStripMargin = true
trait HashScheme[Out] {
def seedValue: Out
def combine(left: Out, right: Out): Out
trait Hash[-In] {
self =>
def apply(in: In): Out = apply(seedValue, in)
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build-debug' ]
2 info using npm@3.5.2
3 info using node@v6.11.4
4 verbose run-script [ 'prebuild-debug', 'build-debug', 'postbuild-debug' ]
5 info lifecycle @~prebuild-debug: @
6 silly lifecycle @~prebuild-debug: no script for prebuild-debug, continuing
7 info lifecycle @~build-debug: @
8 verbose lifecycle @~build-debug: unsafe-perm in lifecycle true
9 verbose lifecycle @~build-debug: PATH: /usr/share/npm/bin/node-gyp-bin:/home/josh/workspace/rust/wasm_game_of_life/node_modules/.bin:/home/josh/torch/install/bin:/home/josh/torch/install/bin:/home/josh/torch/install/bin:/home/josh/torch/install/bin:/home/josh/.cargo/bin:/home/josh/bin:/home/josh/.local/bin:/home/josh/torch/install/bin:/home/josh/torch/install/bin:/home/josh/torch/install/bin:/home/josh/torch/install/bin:/home/josh/.cargo/bin:/home/josh/bin:/home/josh/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/sna
import java.util.concurrent.TimeUnit
import akka.actor.{Actor, ActorLogging, ActorRef, ActorSystem, PoisonPill, Props}
import akka.util.Timeout
import cats.Id
import scala.collection.immutable.Queue
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.{ExecutionContext, Future}
import scala.language.higherKinds
package com.github.joshlemer.traitobjects
import java.io._
import com.github.joshlemer.traitobjects.traitobjects.TObj
import scala.collection.mutable.ListBuffer
import scala.language.higherKinds
import scala.language.implicitConversions
@joshlemer
joshlemer / TarArchives.scala
Created September 8, 2017 17:53
An other go at Tar Archives
class TarArchive(tarArchiveInputStream: () => TarArchiveInputStream) extends Iterable[TarArchiveEntry] { self =>
def iterator = new TarArchiveIterator(tarArchiveInputStream())
def /(path: String): Iterable[TarArchiveEntry] = new Iterable[TarArchiveEntry] {
def iterator = self.iterator.filter(_.getName.startsWith(path))
}
def iterableOf[T](implicit getFromTar: GetFromTar[T]): Iterable[T] =
new Iterable[T] { override def iterator = self.iterator.mapTo[T] }
@joshlemer
joshlemer / I18n.scala
Created July 22, 2017 00:30
I18n with Shapeless
trait Lang {
def name: String
}
object Lang {
trait En extends Lang { def name = "en"}
implicit object En extends En
trait Fr extends Lang { def name = "fr"}
@joshlemer
joshlemer / parser.scala
Last active June 18, 2017 15:56
JSON with Sets and any value as object keys. Forked from lihaoyi/fastparse json parser in the library docs (http://www.lihaoyi.com/fastparse/#Json)
object Js {
sealed trait Val extends Any {
def value: Any
def apply(i: Int): Val = this.asInstanceOf[Arr].value(i)
def apply(s: java.lang.String): Val =
this.asInstanceOf[Obj].value.find(_._1 == s).get._2
}
case class Str(value: java.lang.String) extends AnyVal with Val
case class Obj(value: (Val, Val)*) extends AnyVal with Val
case class Arr(value: Val*) extends AnyVal with Val