Skip to content

Instantly share code, notes, and snippets.

@GauthamBanasandra
GauthamBanasandra / n1ql_query.cpp
Created February 3, 2017 10:45
Execute N1QL queries using the C SDK.
//
// Created by Gautham Banasandra on 03/02/17.
//
#include <iostream>
#include <libcouchbase/couchbase.h>
#include <libcouchbase/n1ql.h>
static void end(lcb_t, const char *, lcb_error_t);
@GauthamBanasandra
GauthamBanasandra / stop_iter.cpp
Created February 14, 2017 04:22
Trying to stop callback. But doesn't work.
//
// Created by Gautham Banasandra on 13/02/17.
//
#include <iostream>
#include <libcouchbase/couchbase.h>
#include <libcouchbase/n1ql.h>
static void end(lcb_t, const char *, lcb_error_t);
@GauthamBanasandra
GauthamBanasandra / transpilation_performance.js
Created May 4, 2017 14:03
Compares the slow down caused due to transpilation.
/**
* Created by gautham on 04/05/17.
*/
let process = require('process');
function run(size) {
function generate_data(size) {
let data = [];
for (let i = 0; i < size; ++i) {
data.push(i);
@GauthamBanasandra
GauthamBanasandra / nested_iter1.cpp
Last active May 19, 2017 05:59
Inner query: Bus error 10
//
// nested_iter.cpp
// libcb
//
// Created by Gautham Banasandra on 17/05/17.
// Copyright © 2017 Couchbase. All rights reserved.
//
#include <libcouchbase/couchbase.h>
#include <libcouchbase/n1ql.h>
first query: "21st Amendment Brewery Cafe"
second query: "(512) Whiskey Barrel Aged Double Pecan Porter"
second query: "(512) Wit"
second query: "One"
second query: metadata {
"requestID": "04f2af25-ecd3-44d4-9db4-c763d3bd19fa",
"signature": {
"*": "*"
},
@GauthamBanasandra
GauthamBanasandra / input.js
Last active July 6, 2017 06:19
Change in maintaining exit status.
// User code
function query() {
for (var r of res) {
return r;
}
}
@GauthamBanasandra
GauthamBanasandra / Anagram.cpp
Created September 9, 2017 14:57
UVa 195 Anagram
#include <iostream>
#include <ios>
#include <algorithm>
#include <string>
#define MAX_ALPHA 200
char alphabets[MAX_ALPHA];
typedef unsigned long long big_int;
bool Compare(char x, char y)
@GauthamBanasandra
GauthamBanasandra / pos_params.cc
Created October 5, 2017 05:14
Positional parameters in libcouchbase SDK
//
// pos_param.cpp
// libcb
//
// Created by Gautham Banasandra on 04/10/17.
// Copyright © 2017 Couchbase. All rights reserved.
//
#include <iostream>
#include <string>
@GauthamBanasandra
GauthamBanasandra / auth-bucket.cpp
Last active February 8, 2018 08:41
Trying out lcb dynamic auth
//
// main.cpp
// auth-change
//
// Created by Gautham Banasandra on 07/12/17.
// Copyright © 2017 Couchbase. All rights reserved.
//
#include <chrono>
#include <fstream>
@GauthamBanasandra
GauthamBanasandra / abv-track.js
Last active February 20, 2018 16:29
zipping a file in go
function OnUpdate(doc, meta) {
var abv = 2,
count = 0,
lim = 10;
var q = SELECT * FROM `beer-sample`
WHERE abv >: abv LIMIT: lim;
for (var row of q) {
var id = meta.id + (++count);
sample[id] = row;
}