Skip to content

Instantly share code, notes, and snippets.

@GrahamBorland
GrahamBorland / V8Extensions.kt
Created October 29, 2019 10:02
Helper functions for memory management with J2V8
/**
* This executes the supplied lambda in the scope of a J2V8 MemoryManager, ensuring that all
* V8Object instances allocated in the scope are cleaned up on exit.
*/
inline fun <T> V8.scope(body: () -> T) : T {
val scope = MemoryManager(this)
try {
return body()
} finally {
scope.release()
@GrahamBorland
GrahamBorland / filter.ts
Last active June 25, 2018 16:14
Monzo YNAB IFTTT filter code
// spending should be negative
let accountAmount = Monzo.cardPurchase.AmountInAccountCurrency;
let localAmount = Monzo.cardPurchase.AmountInLocalCurrency;
let amount = -Number(accountAmount) * 1000;
let date = Meta.currentUserTime.toISOString().substr(0, 10);
var memo = null;
if (localAmount && localAmount != accountAmount) {
memo = Monzo.cardPurchase.LocalCurrencySymbol + localAmount;
void saySomethingNice(String name, int count) {
// aren't we nice?
mTextView.setText(text + " is handsome");
}