Skip to content

Instantly share code, notes, and snippets.

View tleyden's full-sized avatar

Traun Leyden tleyden

View GitHub Profile
@tleyden
tleyden / gist:5825013
Created June 20, 2013 17:56
Sync Gateway thread dump (ctl-\)
^\SIGQUIT: quit
PC=0x241db
goroutine 1 [IO wait]:
net.runtime_pollWait(0x9f4f00, 0x72, 0x0)
/usr/local/go/src/pkg/runtime/znetpoll_darwin_amd64.c:118 +0x82
net.(*pollDesc).WaitRead(0xc201474350, 0x23, 0xc200147960)
/usr/local/go/src/pkg/net/fd_poll_runtime.go:75 +0x31
net.(*netFD).accept(0xc2014742d0, 0x4d0b18, 0x0, 0xc200147960, 0x23, ...)
@tleyden
tleyden / i33repro
Last active December 21, 2015 23:59
# start sync gateway if not already
# push pull on device1
http POST localhost:8080/_replicate source="cblite-test" target="http://10.0.2.2:4984/db" continuous:=true
http POST localhost:8080/_replicate target="cblite-test" source="http://10.0.2.2:4984/db" continuous:=true
# push pull on device2
http POST localhost:8081/_replicate source="cblite-test" target="http://10.0.2.2:4984/db" continuous:=true
http POST localhost:8081/_replicate target="cblite-test" source="http://10.0.2.2:4984/db" continuous:=true
type RandomThinker struct {
ourTeamId int
}
func (r *RandomThinker) Start(ourTeamId int) {
r.ourTeamId = ourTeamId
}
func (r RandomThinker) Think(gameState GameState) (bestMove ValidMove) {
@tleyden
tleyden / gist:6876753
Last active December 24, 2015 22:59
Kickoff replication
public void startReplicationsWithFacebookToken(String accessToken, String email) {
Log.d(TAG, "startReplicationsWithFacebookToken()");
httpClient = new CBLiteHttpClient(server);
dbInstance = new StdCouchDbInstance(httpClient);
// create a local database
couchDbConnector = dbInstance.createConnector(DATABASE_NAME, true);
@tleyden
tleyden / gist:6877087
Created October 7, 2013 23:52
FB params passed in CBLReplicator ctor
public CBLReplicator(CBLDatabase db, URL remote, boolean continuous, HttpClientFactory clientFacotry, ScheduledExecutorService workExecutor) {
this.db = db;
this.continuous = continuous;
this.workExecutor = workExecutor;
this.remote = remote;
this.remoteRequestExecutor = Executors.newCachedThreadPool();
if (remote.getQuery() != null && !remote.getQuery().isEmpty()) {
votes := &OutgoingVotes{}
votesId := fmt.Sprintf("vote:%s", game.user.Id)
err := game.db.Retrieve(votesId, votes)
if err != nil {
logg.LogTo("MAIN", "Unable to find existing vote doc: %v", votesId)
}
votes.Id = votesId
votes.Turn = game.gameState.Turn
@tleyden
tleyden / gist:7531816
Created November 18, 2013 17:30
Data race when trying to expose data via http handler
package main
import (
"fmt"
"net/http"
"time"
)
/*
@tleyden
tleyden / gist:8031420
Last active December 31, 2015 19:09
Person CouchbaseLite
class Person {
private Document document;
private Map<String, Object> properties;
public Person() {
this(getDatabaseSomehow().createDocument());
}
public Person(Document documentParam) {
@tleyden
tleyden / gist:8031592
Created December 18, 2013 23:19
Query for Person objects
Query query = view.createQuery();
QueryEnumerator queryEnumerator = query.run();
while (queryEnumerator.hasNext()) {
QueryRow row = queryEnumerator.next();
Document document = database.getDocument(row.getDocumentId());
Person person = new Person(document);
person.setName(person.getName() + ".");
person.save();
}
@tleyden
tleyden / gist:8048897
Created December 20, 2013 01:04
build.gradle file
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android-library'
apply plugin: 'maven'