Skip to content

Instantly share code, notes, and snippets.

View Chippiewill's full-sized avatar
🤠

Will Gardner Chippiewill

🤠
View GitHub Profile
@Chippiewill
Chippiewill / fast_literal_compare.cc
Created October 7, 2016 13:45
Example code for performing fast comparison against string literals in C++
#include <cstring>
#include <iostream>
#include <string>
template <size_t N>
bool compare(const char* s, size_t n, const char(&data)[N]) {
// Subtract 1 from N to remove null-termination
if (n != (N - 1)) {
return false;
}
import os
from subprocess import call
import sys
import time
if len(sys.argv) > 2 and sys.argv[2] == "cbstats":
def get_stats():
out = os.popen("/Applications/Couchbase\ Server.app/Contents/Resources/couchbase-core/bin/cbstats {} all -b {}".format(sys.argv[1], sys.argv[2])).read()
ret = []
for row in out.split("\n"):
class SetHashTable:
def add_key(set, key, value):
# Adds a key to the set, creates if doesn't exist
def get_set(set):
# Gets all the keys/values in the set

Couchbase Binary Protocol

Introduction

Couchbase is a high performance NoSQL document store that has evolved from the combination of Memcached and CouchDB. The Couchbase binary protocol is based off of the Memcached binary protocol.

This document has been adapted from the Memcached 'Binary Protocol Revamped' document and may make reference to parts of the protocol not implemented by Couchbase Server.

@Chippiewill
Chippiewill / bigram.c
Last active January 3, 2016 14:18
n-gram analysis
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 2
static const char ALPHABET[] = "abcdefghijklmnopqrstuvwxyz";
unsigned result[sizeof(ALPHABET) / sizeof(ALPHABET[0]) - 1][sizeof(ALPHABET) / sizeof(ALPHABET[0]) - 1];