Skip to content

Instantly share code, notes, and snippets.

View ingenthr's full-sized avatar

Matt Ingenthron ingenthr

View GitHub Profile
@ingenthr
ingenthr / tap-protocol.xml
Created August 16, 2018 17:47
TAP snapshot
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE section PUBLIC '-//OASIS//DTD DocBook XML V4.5//EN'
'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd' [
<!ENTITY % every.entities SYSTEM "entities.ent">
%every.entities;
]>
<section id="membase-tap-protocol">
<title>TAP Protocol</title>
@ingenthr
ingenthr / renexus-index.sh
Created March 7, 2018 23:43
building nexus index from CLI
#!/bin/bash
java -jar /home/ingenthr/bin/nexus-indexer-3.0.4-cli.jar \
-t full \
-i /var/www/domains/couchbase.com/files/htdocs/maven2/.index \
-r /var/www/domains/couchbase.com/files/htdocs/maven2 \
-d /var/www/domains/couchbase.com/files/htdocs/maven2/.index \
-n couchbasemaven
chmod 775 /var/www/domains/couchbase.com/files/htdocs/maven2/.index
chmod 664 /var/www/domains/couchbase.com/files/htdocs/maven2/.index/*
@ingenthr
ingenthr / ExponentialBackoffExample.java
Created July 14, 2017 20:57
Couchbase Exponential Backoff on BackpressureException example.
/*
* Copyright (c) 2017 Couchbase, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ingenthr
ingenthr / Example.java
Last active June 27, 2017 21:21
Example of Couchbase Client and logback for seeing stuff with connections.
package com.couchbase.client.demo;
import com.couchbase.client.core.metrics.DefaultLatencyMetricsCollectorConfig;
import com.couchbase.client.core.metrics.DefaultMetricsCollectorConfig;
import com.couchbase.client.java.*;
import com.couchbase.client.java.document.*;
import com.couchbase.client.java.document.json.*;
import com.couchbase.client.java.env.CouchbaseEnvironment;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
import com.couchbase.client.java.query.*;
@ingenthr
ingenthr / Main.java
Created September 28, 2016 22:13
N1QL Query two ways
package com.couchbase.client.example;
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.CouchbaseCluster;
import com.couchbase.client.java.document.json.JsonObject;
import com.couchbase.client.java.query.*;
import static com.couchbase.client.java.query.Select.select;
import static com.couchbase.client.java.query.dsl.Expression.*;
import static com.couchbase.client.java.query.Select.select;
@ingenthr
ingenthr / create_first_node.sh
Created June 28, 2016 01:11
Creating the first node
#!/usr/bin/env bash
set -xe
# Setup Services
curl -i -u Administrator:password -X POST \
http://127.0.0.1:8091/node/controller/setupServices \
-d 'services=kv%2Cn1ql%2Cindex'
# Initialize Node with /couchbase for index and data path
curl -i -u Administrator:password -X POST \
@ingenthr
ingenthr / first_node.sh
Created May 19, 2016 22:52
Quick hack to set up the first node and complete provisioning. Was done to work around a bug in memory optimized indexes.
#!/usr/bin/env bash
set -xe
# Setup Services
curl -i -u Administrator:password -X POST \
http://127.0.0.1:8091/node/controller/setupServices \
-d 'services=kv%2Cn1ql%2Cindex'
# Initialize Node with /couchbase for index and data path
curl -i -u Administrator:password -X POST \
@ingenthr
ingenthr / Main.java
Created December 17, 2015 00:17
Couchbase quick example of Prepared Parameterized Statements from Java SDK
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.CouchbaseCluster;
import java.util.concurrent.TimeUnit;
/**
* Created by ingenthr on 12/16/15.
*/
public class Main {
@ingenthr
ingenthr / ConvertToRdds.scala
Last active November 24, 2015 23:44
Blog: Bulk Transformations of Couchbase Data Using Apache Spark with an External Source
/** Returns an RDD based on email address extracted from the document */
def CreateMappableRdd(s: (String, String)): (String, JsonDocument) = {
val return_doc = JsonDocument.create(s._1, JsonObject.fromJson(s._2))
(return_doc.content().getString("email"), return_doc)
}
// Read
Observable loadedFromId = bucket.get("id"); // async using RxJava
JsonDocument found = bucket.get("notexisting").toBlocking().singleOrDefault(null); // sync
// Write
JsonDocument found = bucket.get("notexisting").toBlocking().singleOrDefault(null); //
// Query