Skip to content

Instantly share code, notes, and snippets.

View rockymadden's full-sized avatar
:octocat:
Setting status

Rocky Madden rockymadden

:octocat:
Setting status
  • UiPath
  • Pale Blue Dot
View GitHub Profile
trait Functor[T[_]]{
def fmap[A,B](f:A=>B)(ta:T[A]):T[B]
}
trait Applicative[T[_]] extends Functor[T]{
def pure[A](a:A):T[A]
def <*>[A,B](tf:T[A=>B])(ta:T[A]):T[B]
}
trait Monad[M[_]] extends Applicative[M]{
/**
* A functional Conway's game of life.
*/
package object conwaydef {
type Coord[A] = (Int, Int) => A
type Calculator = Coord[Coord[Boolean] => Boolean]
type Size = Int
def nextCell(old: Boolean)(mates: Int) = if (mates > 3) false else if (mates == 3) true else (old && mates == 2)
case class Score(p1: Int, p2: Int)
// Alles ist eine Expression
val score = Score(5, 1)
val winner = if (score.p1 > score.p2) "Player 1" else "Player 2"
val looser = if (score.p1 > score.p2) "Player 2" else "Player 1"
// Tupel
val winnerLooser =
import scala.collection.immutable.ListMap
sealed abstract class Validated[+T]
case class Valid[+T](value:T) extends Validated[T]
case class Error(message:String) extends Validated[Nothing]
class ValidationException(s:String) extends Exception(s)
trait Functor[T[_]]{
def fmap[A,B](f:A=>B)(ta:T[A]):T[B]
}
trait Applicative[T[_]] extends Functor[T]{
def pure[A](a:A):T[A]
def <*>[A,B](tf:T[A=>B])(ta:T[A]):T[B]
}
trait Monad[M[_]] extends Applicative[M]{
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
package pong.functional
sealed trait Event
sealed trait Action
object Action {
case object MoveUp extends Action
case object MoveDown extends Action
case object ShootMissile extends Action
}
@rockymadden
rockymadden / processing-chassis-3u-8node.md
Last active December 17, 2015 05:58
One simple example of a 10u/13node hardware private cloud infrastructure. Built specifically for colocation, based on how datacenters often slice up their racks (e.g. 10u/quarter rack is very common). Saves a few hundred thousand dollars over AWS in three years time. Replace/repeat at that time and then put these into a Hadoop cluster or somethi…

This chassis houses up to 8 processing nodes. Each node is roughly equivilent to 30 elastic compute units. You can scale as needed by building and slotting more nodes into the chassis. Candidates for these nodes includes: app servers of any kind, ssl termination/reverse proxies, cache servers, distributed/concurrent processing, cron jobs, etc.

Barebone:


Per node (up to 8):

package com.rockymadden.collection.mutable
import scala.annotation.tailrec
import scala.collection.generic.CanBuildFrom
import scala.collection.mutable.{Builder, Map, MapBuilder, MapLike}
final class PrefixMap[A] extends Map[String, A] with MapLike[String, A, PrefixMap[A]] {
private val suffixes: Map[Char, PrefixMap[A]] = Map.empty
private var value: Option[A] = None
@rockymadden
rockymadden / build.gradle
Last active June 27, 2018 15:01
Deploy a Gradle Scala project to Maven Central, or any Maven repository for that matter, based upon the presence of variables in your gradle.properties file. Plays nicely with continuous integration tools like Travis-CI.
apply plugin: 'maven'
apply plugin: 'scala'
apply plugin: 'signing'
def isMavenDeployable = hasProperty('mavenRepositoryUrl') &&
hasProperty('mavenRepositoryUsername') &&
hasProperty('mavenRepositoryPassword')
if (isMavenDeployable) {
signing {