This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This should work with Scala 2.10.4 & scalaz 7.1, core, effect and concurrent packages | |
import scalaz.{ concurrent, Free, Functor, Monad, syntax } | |
import concurrent.Task | |
import Free.{freeMonad => _, _} | |
import syntax.monad._ | |
// Describe the set of actions - which are functors | |
sealed trait RedisF[+A] { | |
def map[B](fn: A => B): RedisF[B] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argonaut._, Argonaut._ | |
import org.scalacheck._, Prop._ | |
import scalaz._, Scalaz._ | |
object EncodingTestExample extends Properties("Encoding Json Test Example") { | |
case class Vehicle( | |
wheelsCount: Option[Int], | |
engineParts: List[String] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
region = "us-west-2"; | |
accessKeyId = "CORRECTAWSKEY"; | |
defaults = | |
{ config, pkgs, resources, ... }: | |
{ deployment.targetEnv = "ec2"; | |
deployment.ec2.accessKeyId = accessKeyId; | |
deployment.ec2.region = region; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ numZookeeperNodes ? 1 }: | |
with import <nixpkgs/lib>; | |
let | |
makeMachine = n: nameValuePair "zk-${toString n}" | |
({ config, pkgs, nodes, ... }: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
defaults = | |
{ config, pkgs, ... }: | |
{ deployment.targetEnv = "virtualbox"; | |
deployment.virtualbox.memorySize = 2048; # Mb | |
deployment.virtualbox.headless = true; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TrentTree where | |
import Control.Monad.Trans.Class -- from the `transformers` package | |
import Control.Monad.Trans.Except -- from the `errors` package | |
import Data.Monoid ((<>)) | |
import Data.Tree | |
import System.Directory (doesDirectoryExist, | |
getDirectoryContents) | |
import System.FilePath (combine, takeFileName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def leg(mode:Int, angle:Double) : IndexedSeq[Double] = { | |
val cosAngle = math.cos(angle) | |
lazy val stream: Stream[Double] = { | |
def loop(last:Double, curr:Double, k:Double = 0.0) : Stream[Double] = curr #:: loop(curr, ((2 * k + 1) * cosAngle * curr - k * last) / (k + 1), k + 1) | |
loop(0.0, 1.0) | |
} | |
stream.take(mode + 1).toIndexedSeq | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Spots | |
import collection.mutable.ArrayBuffer | |
/** | |
* Track class | |
* Author: James R. Thompson, D.Phil | |
* Date: 7/16/12 | |
* Time: 9:31 AM | |
* USC Mork Family Dept. of Chem. Eng. & Mat. Sci. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.math._ | |
case class Complex(re: Double, im: Double = 0.0) { | |
def +(x: Complex): Complex = Complex((this.re+x.re), (this.im+x.im)) | |
def -(x: Complex): Complex = Complex((this.re-x.re), (this.im-x.im)) | |
def *(x: Complex): Complex = Complex(this.re*x.re-this.im*x.im, this.re*x.im+this.im*x.re) | |
} | |
def transformReal(input:IndexedSeq[Double]) = { | |
val data = padder(input.map(i => Complex(i)).toList) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.scene.image.Image | |
import javax.imageio.ImageIO | |
import java.awt.image._ | |
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, IOException} | |
import java.util.logging.{Level, Logger} | |
object JFXImageUtil { | |
def getJavaFXImage(rawPixels:Array[Byte], width:Int, height:Int) = { | |
val out = new ByteArrayOutputStream |
OlderNewer