Skip to content

Instantly share code, notes, and snippets.

View dbousamra's full-sized avatar

Dominic Bou-Samra dbousamra

  • Piccolo Health
  • Australia
View GitHub Profile
object Example {
def main(args: Array[String]) {
val client = new AmazonDynamoDBAsyncClient(creds)
val system = ActorSystem()
// THIS GUY. I am passing in an ec to DynamoDb. Is it safe to have a reference here? I have to have one because the map on line 10 complains.
implicit val ec = system.dispatcher
val snapshotDao = new DynamoDbSnapshotDao(client, ec)
val f = snapshotDao.getSnapshot2().map { x =>
export var genRandomObject: testcheck.Generator<any> =
gen.bind(gen.JSON, (o) => {
var n: number = getRandomInt(0, 10);
for (var i=0; i < n; i++) {
var r: number = getRandomInt(1, 12);
var k: string = testcheck.sample(genWithLength(gen.alphaNumChar, 6, 10), {times:1, maxSize:1})[0];
switch (r) {
case 1:
o[k] = testcheck.sample(genDate, {times:1, maxSize:1}).pop();
break;
return this.repository.getEventById(msg.getReferenceIdentifier()).then((eventO: m.Option<domain.core.Event>) => {
if (!eventO.isDefined) {
this.logger.error("%s - Could not find event.", event.id)
return Promise.resolve(new message.ImageIntelligenceRequeueRequest(event, false))
}
var event = eventO.get();
// If it does contain a person, handle person
describe("Event save", () => {
it("Should be able to retrieve an event from the database, mutate the data, and save it", (done) => {
return eventRepo.findOneById('54c305fd1431209617db8221').then((eventO: m.Option<domain.Event>) => {
var event = eventO.get();
event.hash = 'foobar';
return eventRepo.save(event).then((savedEvent) => {
return eventRepo.findOneById('54c305fd1431209617db8221').then((updatedEvent) => {
updatedEvent.isDefined.should.be.true
updatedEvent.foreach((ev) => ev.should.eql(event))
});
var _ = require('lodash')
var mocha = require('mocha')
var should = require('should')
var testcheck = require('testcheck')
var mochaCheck = require('mocha-testcheck').install();
var gen = testcheck.gen
var DomsStringUtils = {
truncateBetter: function(input, length) {
if (length < 0) {
/// <reference path="../../typings/tsd.d.ts" />
import domain = require('../src/dao/domain');
import CameraMapper = require('../src/dao/mapper/camera/index');
import repository = require('../src/dao/repository/index')
import mongo = require('../src/dao/adapter/mongodb');
import generators = require('./generators')
import should = require('should');
import _ = require('lodash')
import mt = require('mocha-testcheck')
import testcheck = require('testcheck')
/// <reference path="../../typings/tsd.d.ts" />
import testcheck = require('testcheck');
import domain = require('./dao/domain');
import CameraMapper = require('./dao/mapper/camera/index');
import should = require('should');
import _ = require('lodash')
import mt = require('mocha-testcheck')
mt.install(global);
var persist = should;

Was thinking a bit about what you said yesterday around using values as exceptions, and think I misunderstood your point.

That post was around Go's handling of errors. They encode an error or exception as a second return value from a function (effectively a tuple). I.e. the function:

func Open(name string) (file *File, err error)

returns an error as it's 2nd return value. You then capture that at the calling site:

// Raw JSON types
interface CameraRaw {
_id: string;
name: string;
}
interface AccountRaw {
_id: string;
email: string;
object Try {
def apply[T](f: => T): Try[T] =
try {
Success(f)
} catch {
case NonFatal(e) => Failure(e)
}
}
sealed trait Try[+T] {