Skip to content

Instantly share code, notes, and snippets.

@justjoheinz
justjoheinz / gist:7613775
Created November 23, 2013 11:55
Chaining Validations
class ChainedValidation[E,A](val x : A, val validationResult: ValidationNel[E,A]) {
def andThen(f: A => ValidationNel[E, A])(implicit s1: Semigroup[E]) : ChainedValidation[E,A] = {
// calculate new validation
val newResult = f(x)
validationResult match {
// (success & newResult) =>
case Success(_) =>
newResult match {
@justjoheinz
justjoheinz / Application.scala
Created November 15, 2013 08:32
Gist to describe problems testing actors which are instantiated in a Play2 controller.
package controllers
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits._
import play.api.Play.current
import play.api.libs.concurrent.Akka
import play.api.mvc._
import akka.actor._
package scalaio
import shapeless._, poly._
object list extends (Id ~> List) {
def apply[T](t : T) = List(t)
}
object headOption extends (List ~> Option) {
def apply[T](l : List[T]) = l.headOption
@justjoheinz
justjoheinz / Makefile
Created March 17, 2012 13:41
Super simple beagleboneio project
INCLUDE_PATH=/opt/local/include
LIBRARY_PATH=/opt/local/lib
CC_OPTS=-O2
all:
gcc test.c -o test $(CC_OPTS) -I$(INCLUDE_PATH) -L$(LIBRARY_PATH) -lbeagleboneio
@justjoheinz
justjoheinz / excerpt.cpp
Created November 27, 2011 11:55
switch statement for ISR in Marlin firmware
switch(temp_state) {
case 0: // Prepare TEMP_0
#ifdef NORMAL_OP
#if (TEMP_0_PIN > -1)
#if TEMP_0_PIN > 7
ADCSRB = 1<<MUX5;
#endif
ADMUX = ((1 << REFS0) | (TEMP_0_PIN & 0x07));
ADCSRA |= 1<<ADSC; // Start conversion
#endif
@justjoheinz
justjoheinz / Configuration.h
Created November 26, 2011 13:45
Marlin Config
#ifndef __CONFIGURATION_H
#define __CONFIGURATION_H
// This determines the communication speed of the printer
//#define BAUDRATE 250000
#define BAUDRATE 115200
//#define BAUDRATE 230400