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
trait Budget { | |
def events: Seq[Transaction] | |
} |
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 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 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 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 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 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 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 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
public class Sample1 { | |
// --- Native methods | |
public native int intMethod(int n); | |
public native boolean booleanMethod(boolean bool); | |
public native String stringMethod(String text); | |
public native int intArrayMethod(int[] intArray); | |
// --- Main method to test our native library |
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
>> ffprobe -loglevel quiet -show_streams -show_format -show_error -print_format json C01_2017_S027_S003_T002.MOV | |
# NOTES: File looks good. Has creation-time atom | |
{ | |
"streams": [ | |
{ | |
"index": 0, | |
"codec_name": "pcm_s24le", | |
"codec_long_name": "PCM signed 24-bit little-endian", | |
"codec_type": "audio", | |
"codec_time_base": "1/48000", |
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
FROM ubuntu | |
RUN apt-get update \ | |
&& apt-get install -y --no-install-recommends \ | |
build-essential \ | |
curl \ | |
cmake \ | |
&& rm -rf /var/lib/apt/lists/* | |
RUN curl -qsSLkO \ |