Skip to content

Instantly share code, notes, and snippets.

@cwmyers
cwmyers / figureRun.ino
Created October 19, 2019 06:02
A little game that can be run on arduino with an LCD sheild
#include <LiquidCrystal.h>
//LCD pin to Arduino
const int pin_RS = 8;
const int pin_EN = 9;
const int pin_d4 = 4;
const int pin_d5 = 5;

Keybase proof

I hereby claim:

  • I am cwmyers on github.
  • I am cwmyers (https://keybase.io/cwmyers) on keybase.
  • I have a public key whose fingerprint is 755A 0E9F C495 813B 72B3 B39B 3E8D A8EB 443F A790

To claim this, I am signing this object:

@cwmyers
cwmyers / scalaz-stream-flatmap-stack.md
Last active May 12, 2016 08:02
FlatMap is blowing the stack

I've been playing with Scalaz-Streams (0.7.3 and 0.8) and noticed this curious behaviour which I don't understand. As an experiment I am creating multiple processes and using the output of one process as the input for the next process. In doing so, I seem to blow the stack. Initially I thought it was because I'm appending the stream with a recursive call to the function that creates the stream. But I discovered that replacing the flatMap in the first example below with map/mergeN and it stopped blowing the stack. Curiously though using map/mergeN was waaaaaaaay slower than using flatMap. So, why is flatMap blowing the stack and why is mergeN so slow?

import scalaz.concurrent.Task
import scalaz.stream._


object Main extends App {

  def infiniteInts(streamOfInts: Process[Task, Int]): Process[Task, Int] = {
sealed trait Interact[A]
case class Ask(prompt: String)
extends Interact[String]
case class Tell(msg: String)
extends Interact[Unit]
trait Monad[M[_]] {
def pure[A](a: A): M[A]
@cwmyers
cwmyers / ValidaitonExample.scala
Created June 13, 2014 04:32
Validation Example
package com.rea-group.validation
import scalaz._, Scalaz._
import java.lang.NumberFormatException
import scala.collection.mutable.ListBuffer
object ValidationExample {
val suburbs = Map(3000 -> "Melbourne", 3121 -> "Richmond", 4000 -> "Brisbane", 2001 -> "Sydney")