Skip to content

Instantly share code, notes, and snippets.

View flimzy's full-sized avatar

Jonathan Hall flimzy

View GitHub Profile
# This is expected: The document exists with _rev 1-d005ccb8dd54b45ab90d06a3b32513ca
$ curl -X GET http://admin:xxx@localhost:5984/lana-knowledge-items/_design/items_sync_v1\?deleted_conflicts=true
{"_id":"_design/items_sync_v1","_rev":"1-d005ccb8dd54b45ab90d06a3b32513ca","language":"javascript","views":{"by_owner_id":{"map":"\n\t\t\tfunction(d) {\n\t\t\t\tif (d['created_at']) {\n\t\t\t\t\temit(d.created_at, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t"}}}
# Now simulate replicating the deleted document, which appears to work just fine:
$ curl -X PUT http://admin:xxx@localhost:5984/lana-knowledge-items/_design/items_sync_v1\?new_edits=false -H 'Content-Type: application/json' -d'{"_id":"_design/items_sync_v1","_rev":"2-xx","_deleted":true}'
{"ok":true,"id":"_design/items_sync_v1","rev":"2-xx"}
# But fetch the document again, and it's not deleted, and `2-xx` is listed as a deleted conflict
$ curl -X GET http://admin:xxx@localhost:5984/lana-knowledge-items/_design/items_sync_v1\?deleted_conflicts=true
function getErrorMessage(response) {
if (!response.originalError.response)
return 'network error';
return response.originalError.response.data.errorMessage;
}
var C interface{}
if true {
C = new(A)
} else {
C = new(B)
}
func (h *handler) GetData(ctx context.Context, request Payload) (*Data, error) {
go func(ctx context.Context) {
<-ctx.Done()
if ctx.Err() == context.Canceled {
log.Info(ctx.Err())
}
}(ctx)
data := fetchData(request)
keyHoldLoop = function() {
var _entry, _entry$1, _i, _key, _keys, _r, _ref, delta, k, next, now, x, x$1, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _entry = $f._entry; _entry$1 = $f._entry$1; _i = $f._i; _key = $f._key; _keys = $f._keys; _r = $f._r; _ref = $f._ref; delta = $f.delta; k = $f.k; next = $f.next; now = $f.now; x = $f.x; x$1 = $f.x$1; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
next = new time.Time.ptr(new $Uint64(0, 0), new $Int64(0, 0), ptrType.nil);
delta = new time.Duration(0, 0);
now = $clone(time.Now(), time.Time);
/* while (true) { */ case 1:
_r = fmt.Println(new sliceType([new $String("Keyhold loop")])); /* */ $s = 3; case 3: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
_r;
time.Time.
@flimzy
flimzy / gist:714c7c8a3f5541c1b4595421929b3020
Created July 8, 2017 11:38
GopherJS transpilation of func (l *Logger) Output in the standard library 'log' package
Logger.ptr.prototype.Output = function(calldepth, s) {
var $ptr, _r, _tuple, _tuple$1, calldepth, err, file, l, line, now, ok, s, $s, $deferred, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $ptr = $f.$ptr; _r = $f._r; _tuple = $f._tuple; _tuple$1 = $f._tuple$1; calldepth = $f.calldepth; err = $f.err; file = $f.file; l = $f.l; line = $f.line; now = $f.now; ok = $f.ok; s = $f.s; $s = $f.$s; $deferred = $f.$deferred; $r = $f.$r; } var $err = null; try { s: while (true) { switch ($s) { case 0: $deferred = []; $deferred.index = $curGoroutine.deferStack.length; $curGoroutine.deferStack.push($deferred);
l = this;
now = $clone(time.Now(), time.Time);
file = "";
line = 0;
l.mu.Lock();
$deferred.push([$methodVal(l.mu, "Unlock"), []]);
if (!(((l.flag & 24) === 0))) {
@flimzy
flimzy / main.go
Last active April 12, 2017 18:49
package main
import (
"bytes"
"fmt"
"net/http"
"strings"
"sync"
"sync/atomic"
)
diff --git a/conn.go b/conn.go
index 1af4474..ba9f6fc 100644
--- a/conn.go
+++ b/conn.go
@@ -8,7 +8,6 @@ import (
"bytes"
"fmt"
"io"
- "net"
"net/url"
package main
import (
"encoding/json"
"fmt"
)
type Customer struct {
ID int `json:"id"`
FirstName string `json:"firstName"`
1.
Request{
Name: "Tickets for Admin",
Method: "GET",
URL: Server.URL + "/v1/inboxes/9991/tickets/Active.json",
StatusCode: http.StatusOK,
TestContentType: "application/json",
TestCharset: "utf-8",
TestBodyJSON: func(i interface{}) error {