Skip to content

Instantly share code, notes, and snippets.

@logicalguess
logicalguess / Dockerfile
Last active December 29, 2017 16:17
akka http wrapper for the YOLO algorithm
FROM innoq/docker-alpine-java8
RUN apk add --update --no-cache \
bash \
build-base curl \
make \
gcc \
git
RUN git clone https://github.com/pjreddie/darknet.git && echo "#include <sys/select.h>\n"|cat - ./darknet/examples/go.c > /tmp/out && mv /tmp/out ./darknet/examples/go.c
@logicalguess
logicalguess / led_toggle_command.go
Created November 9, 2017 02:36
Gobot program to toggle LEDs through an API
package main
import (
"fmt"
"gobot.io/x/gobot"
"gobot.io/x/gobot/api"
"gobot.io/x/gobot/platforms/firmata"
"gobot.io/x/gobot/drivers/gpio"
"time"
"os"
@logicalguess
logicalguess / combo.go
Last active November 5, 2017 19:19
Gobot that blinks an LED and reads the voltage of a pin on an Arduino microcontroller connected to a Raspberry Pi. The code is built for the Raspberry Pi and transferred to it.
package main
import (
"fmt"
"gobot.io/x/gobot"
"gobot.io/x/gobot/api"
"gobot.io/x/gobot/platforms/firmata"
"gobot.io/x/gobot/drivers/gpio"
"time"
"os"
@logicalguess
logicalguess / component.go
Created October 24, 2017 04:15
Event-driven components in Go.
package main
import (
"fmt"
"time"
)
type G interface{}
func producer(ch chan []G, d time.Duration) {
var i int
@logicalguess
logicalguess / state.go
Last active January 16, 2020 03:46
State Monad in Go.
package main
import (
"fmt"
"reflect"
)
type G interface{}
type S G
@logicalguess
logicalguess / curry.go
Last active January 2, 2020 12:35
Function currying in Go.
package main
import (
"fmt"
"reflect"
)
type G interface{}
type F func(...G) G
@logicalguess
logicalguess / partial_function.go
Created October 18, 2017 03:13
Input processing logic as a partial function in Go.
package main
import (
"fmt"
"errors"
)
type G interface{}
type X struct {
@logicalguess
logicalguess / HListMContainer.scala
Created September 23, 2017 05:00
Shapeless HList containers
package logicalguess.union
import shapeless.ops.hlist.Selector
import shapeless.{::, HList, HNil, Typeable}
import scala.reflect.runtime.universe._
trait HListMContainer {
type L <: HList
val hv: L
@logicalguess
logicalguess / DepTyped.scala
Last active September 23, 2017 04:41
unions and heterogeneous lists without shapeless
package logicalguess.union
import scala.reflect.runtime.universe._
trait DepTyped {
type U <: Union
val tu: Typed[U]
def add[In : TypeTag](in: In)= new DepTyped {
override type U = DepTyped.this.U | In
@logicalguess
logicalguess / Call.scala
Last active September 21, 2017 01:57
type safe partial function union/merge with compile time verification
package logicalguess.receiver
import scala.reflect.ClassTag
case class Call[U <: Union](pf: PartialFunction[Any, Any]) {
import Call._
def union[In](f: Function[In, Any])(implicit ct: ClassTag[In]) = Call[U | In](pf.orElse(downcast(f)))