Skip to content

Instantly share code, notes, and snippets.

@mnunberg
mnunberg / redismodule.h
Created November 22, 2018 12:06
redismodule.h using extern and proper declaration vs. definition separation
#ifndef REDISMODULE_H
#define REDISMODULE_H
#include <sys/types.h>
#include <stdint.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
@mnunberg
mnunberg / pycbc-winbuild.py
Last active October 25, 2017 09:49
Build script for Python couchbase client.
#!/usr/bin/env python
import os
import os.path
import sys
import argparse
import urllib2
import zipfile
import shutil
import glob
import subprocess
@mnunberg
mnunberg / n1ql-sample.c
Created February 20, 2015 16:53
n1ql/lcb2.4.7
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <libcouchbase/couchbase.h>
#include <libcouchbase/n1ql.h>
#define CONNSTR "couchbase://localhost:12000/beer-sample"
static void rowCallback(lcb_t instance, int cbtype, const lcb_RESPN1QL *resp) {
if (! (resp->rflags & LCB_RESP_F_FINAL)) {
IPTC Notes
This document outlines some of my experiences with IPTC, both for my own
reference, and for anyone else wishing to use this library.
"libiptc" is an internal library to "iptables". It is available as a
package on some distros, and is compiled with the "iptables" tarball as
well. Depending in "libiptc" should be a fairly simple process.
"libiptc" itself only provides the fairly high level functions used to
actually insert/remove/update/append a rule, but does not actually
@mnunberg
mnunberg / gist:d78c50d3e526d36d5393
Created March 2, 2016 00:11
Subdoc multi packet format
# key: mutateIn_REPLACE_Test
# op[0]: SUBDOC_REPLACE(foo, "car")
# op[1]: SUBDOC_REPLACE(foo, "car")
Operation STORE: Success (Not an error)
performing mutations..
Dumping packet..(kh_span: 45. val: 32
[0]: {0x80 (h)} {128 (d)}
[1]: {0xD1 (h)} {209 (d)}
[2]: {0x0 (h)} {0 (d)}

LIBCOUCHBASE BUILD CONFIGURATION

lcbutils

This component contains a collection of utilities for libcouchbase which do not require external or I/O dependencies. This should always be first and be assumed to be the base dependency of other libraries.

It will be built as a static library and linked in with the resultant DSO, so that its symbols are not duplicated twice.

#include <stdio.h>
#include "netbufs.h"
#include "slist-inl.h"
#define MINIMUM(a, b) a < b ? a : b
#define MAXIMUM(a, b) a > b ? a : b
#define BASEALLOC 32768
#define BLOCK_IS_FLUSHED(block) ((block)->flush_start == (block)->cursor)
#define BLOCK_IS_EMPTY(block) ((block)->start == (block)->cursor)
namespace Couchbase
{
internal class SocketPool : ResourcePool {
// .....
public IPooledSocket Acquire()
{
// Log..
IPooledSocket socket = null;
lock(_syncObj)
{
@mnunberg
mnunberg / uvsync.py
Last active December 26, 2015 11:29
pyuv sync
from socket import getaddrinfo
from pyuv import Timer, Loop, TCP
from pyuv.error import UVError
from pyuv import errno as uv_errno
class NetworkError(Exception):
def __init__(self, uverr):
self.code = uverr
#
# Copyright 2013, Couchbase, Inc.
# All Rights Reserved
#
# 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
#