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
/* DO NOT EDIT THIS FILE - it is machine generated */ | |
#include <jni.h> | |
/* Header for class Sample1 */ | |
#ifndef _Included_Sample1 | |
#define _Included_Sample1 | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
/* |
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
#include "Sample1.h" | |
#include <ctype.h> | |
#include <string.h> | |
// Mutate array to uppercase | |
void uppercase(char* str) { | |
size_t n = strlen(str); | |
for (size_t i = 0; i < n; i++) { | |
str[i] = toupper(str[i]); | |
} |
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` |
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
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
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.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
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.{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
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 |