This file contains hidden or 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
scala> Parser8086.instructions(reader) | |
res1: com.github.assgui.Parser8086.ParseResult[List[com.github.assgui.Parser8086.~[com.github.assgui.Parser8086.~[com.github.assgui.Parser8086.~[String,String],String],String]]] = [1.17] parsed: List((((mov~dx)~,)~1000)) |
This file contains hidden or 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
case class CyclicIterator[T](traversable: Traversable[T]) extends Iterator[T] { | |
var currentIterator = traversable.toIterator | |
def next() = { | |
if (!currentIterator.hasNext) currentIterator = traversable.toIterator | |
currentIterator.next() | |
} | |
def hasNext = !traversable.isEmpty | |
} |
This file contains hidden or 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
trait AStarAlgorithm[T] { | |
def heuristic(currentPath: Vector[T], from: T , to: T, goal: T): Double | |
def getReachable(node: T): Set[T] | |
} | |
object AStar { | |
def find[T](nodes: Set[T], start: T, goal: T)(implicit algorithm: AStarAlgorithm[T]): Option[Vector[T]] = { | |
find(start, goal, Set(start), Vector(start), 0) | |
} | |
def find[T](start: T, goal: T, closed: Set[T], navigated: Vector[T], currentCost: Double)(implicit algorithm: AStarAlgorithm[T]): Option[Vector[T]] = { |
This file contains hidden or 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 scalaz._ | |
import Scalaz._ | |
case class Asset(id: Int, path: String) | |
case class AssetDependencyChain(assetToDeps: Map[Asset, Set[Asset]]) { | |
def getResolvedDependencies(startingAsset: Asset): ValidationNEL[String, Set[Asset]] = { | |
def resolve(workingAsset: Asset, workingPath: Vector[Asset]): ValidationNEL[String, Set[Asset]] = { | |
if (workingPath.contains(workingAsset)) "Circular dependency discovered with %s and along path %s.".format(workingAsset, workingPath).failNel[Set[Asset]] | |
else { | |
val workingSet = Set(workingAsset) |
This file contains hidden or 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 rebuildJavaFX(runtimeRoot: Path, destinationFolder: Path): Unit = { | |
val binRoot = runtimeRoot.resolve("bin") | |
val bundlePath = destinationFolder.resolve("javafxnativebundle.jar") | |
bundlePath.toFile.delete() | |
using(FileSystems.newFileSystem(createNewZipFile(bundlePath), null)){zipFileSystem => | |
toPathStream(binRoot) | |
.filter(isLibrary) | |
.filterNot(shouldBeIgnored) | |
.foreach{libraryItem => | |
val zipPath = zipFileSystem.getPath(libraryItem.getFileName.toString) |
This file contains hidden or 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
val lineSeperator = ", " + System.getProperty("line.separator") | |
Array("First Line", null, "Second Line", "Third Line").filter(_ != null).mkString(lineSeperator) |
This file contains hidden or 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
case class Thing(text: String) | |
implicit def convertToThing(text: String): Thing = new Thing(text) | |
def jazzify(text: String): Unit = println("JAZZ: " + text) | |
def jazzify(thing: Thing): Unit = jazzify(thing.text) | |
// Brings about the end of days by effectively calling jazzify(thing: Thing) recursively. | |
jazzify(new Thing("Sean")) |
This file contains hidden or 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
println(expectedParseResult ≟ actualParseResult) | |
println(expectedParseResult.fail ≟ actualParseResult.fail) | |
// Output is: | |
// false | |
// true |
This file contains hidden or 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 write(toStore: T): IO[Unit] = { | |
val streamIO = io(new ObjectOutputStream(new FileOutputStream(file))) | |
streamIO.bracket(closeCloseable)(stream => io(stream.writeObject(toStore))) | |
} |
This file contains hidden or 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 requestOption(message: String, title: String): IO[Option[String]] = { | |
io(Promise( | |
Dialog.showInput[String]( | |
message = message, | |
title = title, | |
messageType = Dialog.Message.Question, | |
initial = "") | |
).get) | |
} |