Skip to content

Instantly share code, notes, and snippets.

{
"id": "100",
"email": "bigjasonwebb@gmail.com",
"realName": "Jason J Webb",
"avatar": "/100/C0F6B65E73BE49BAA9F940E40550917E.jpg",
"signupDate": "2014-02-11T23:21:01+00:00",
"featureEnrollments": [
{
"id": 1,
"feature": "publish",
{
"id": "CFF5C6158BFD45C9A53459FBAB9996B2",
"delta": "44",
"isDeleted": false,
"revisions": [
{
"revisionId": 44,
"userId": 100,
"date": {
"time": "2014-07-17T22:58:12+00:00",
{
"id": "FFF5C6158BFD45C9A53459FBAB9996B2",
"delta": "41",
"isDeleted": false,
"revisions": [
{
"revisionId": 41,
"userId": 100,
"date": {
"time": "2014-07-17T04:37:16+00:00",
{
"id": "FFF5C6158BFD45C9A53459FBAB9996B2",
"delta": "41",
"isDeleted": false,
"revisions": [
{
"revisionId": 41,
"userId": 100,
"date": {
"time": "2014-07-17T04:37:16+00:00",
{
"code": 500,
"error": "There was an unexpected server error.",
"fields": null
}
def save[A](key: String)(f: CouchValueHandler[A])(implicit formatter: CouchFormat[A], context: CouchContext): Future[A] =
get[A](key).flatMap {
case Some(row) =>
update[A](key, row)(value => f(value.some))
case None =>
val value = f(None)
add(key, value) flatMap {
case false => // Failure to add means there is now a value, start the process over.
save(key)(f)
case true =>
/**
* Copyright (C) 2006-2009 Dustin Sallings
* Copyright (C) 2009-2013 Couchbase, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
trait EntryMasterSerializer {
def EntryProposedRevisionReader(entryId: UUID)(implicit request: DayOneAuthenticatedRequest[_]): Reads[(ProposedRevision, Entry)] = (
(__ \ "type").read[RevisionOutcome] and
(__ \ "editDate").readOrElse(DateTime.now(DateTimeZone.UTC)) and
(__ \ "entry").read(entryReads(entryId.some))
).tupled.map {
case (outcome, editDate, entry) =>
val revision = ProposedRevision(
outcome = outcome,
user = request.user,
class EntryMerge(em: EntryMaster,
revisionIn: ProposedRevision,
entryIn: Entry,
parentRevision: Option[EntryRevision]) extends Loggable with DayOneInjectable {
// CODE AND THINGS!
}
@bigjason
bigjason / base64.js
Last active August 29, 2015 14:05
Copy of couchbase decodeBase64 for debugging
var decodeBase64 = (function(b64) {
var i, j, l, tmp, scratch, arr = [];
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
if (typeof b64 !== 'string') {
throw 'Input is not a string';
}
if (b64.length % 4 > 0) {
throw 'Invalid base64 source.';
}
scratch = b64.indexOf('=');