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 java.time.{Duration, Instant} | |
object BudgetPlot extends App with scalax.chart.module.Charting { | |
val budget = CurrentBudget | |
val endDate = Instant.now.plus(Duration.ofDays(365)) | |
def filter(s: Stream[Transaction]): Stream[Transaction] = s.takeWhile(i => i.date.isBefore(endDate)) | |
val timeseries = new BudgetTimeSeries | |
budget.events |
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 java.time.Instant | |
import scala.collection.mutable | |
import scilube.Matlib | |
class BudgetTimeSeries { | |
private[this] val series = new mutable.TreeMap[Instant, Double] | |
def addToSeries(events: Seq[Transaction]): Unit = { |
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 java.time.{Duration, Instant} | |
object BudgetApp extends App { | |
val budget = CurrentBudget | |
val endDate = Instant.now.plus(Duration.ofDays(365)) | |
def filter(s: Stream[Transaction]): Stream[Transaction] = s.takeWhile(i => i.date.isBefore(endDate)) | |
def money(s: Stream[Transaction]): Double = s.last.accumulatedValue | |
val sum = budget.events.map(_.stream) // Convert each transaction into a stream |
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 java.time.{Duration, LocalDate, Instant, ZoneId} | |
object CurrentBudget extends Budget { | |
// Helper function. Creates an Instant from dates like "2017-12-19" | |
implicit def toInstant(s: String): Instant = LocalDate.parse(s) | |
.atStartOfDay(ZoneId.systemDefault()) | |
.toInstant | |
override def events: Seq[Transaction] = Seq( |
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 Budget { | |
def events: Seq[Transaction] | |
} |
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 java.time.temporal.{ChronoField, TemporalAdjusters} | |
import java.time.{Duration, Instant, ZoneId} | |
/** | |
* A OneTime transaction does not reoccur in our model. | |
*/ | |
case class OneTime(label: String, | |
value: Double, | |
date: Instant) extends Transaction { | |
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 java.time.Instant | |
trait Transaction { | |
def label: String | |
/** The amount of money in the transaction */ | |
def value: Double | |
/** When this transaction occurs */ |
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 java.util.LinkedHashSet; | |
import javafx.collections.ObservableList; | |
import javafx.scene.control.TableRow; | |
import javafx.scene.control.TableView; | |
import javafx.util.Callback; | |
/** |
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
[ | |
{"ConceptName": "Pandalus", | |
"Salinity": 35.234, | |
"Associations": [ | |
"eating | Sergestes | nil", | |
"surface-color | self | red", | |
"upon | bedrock | nil" | |
], | |
"ImageURL": "http://www.foo.com/bar.png" | |
}, |
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
export JAVA_HOME=`/usr/libexec/java_home -v 1.8` |