Skip to content

Instantly share code, notes, and snippets.

View daverigby's full-sized avatar

Dave Rigby daverigby

View GitHub Profile
{ 'by_id': { 'id1': {many, fields, of, data, ...},
'id2': {otther fields, of, data, ...},
...
},
'ordering': [id1, id2, ...]
}
cat master_events.log |jq -c '.|select(.bucket=="default" and (.type=="vbucketMoveDone" or .type=="vbucketMoveStart"))' | jq -c -s 'group_by(.vbucket) | .[] | select(length % 2 == 1) | sort_by(.ts)'
for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less
ExternalProject_Add(rocksdb
GIT_REPOSITORY https://github.com/couchbasedeps/rocksdb.git
GIT_TAG ${_git_rev}
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ""
LIST_SEPARATOR " "
BUILD_COMMAND CFLAGS=-Ifoo/include;-Ibar/include $(MAKE)
)
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <iostream>
#include <vector>
#include "date.h" // From https://github.com/HowardHinnant/date/blob/master/include/date/date.h
static constexpr const size_t magnitude_bits = 4;
grep table_file_creation cbcollect_info_ns_1\@172.23.96.117_20180103-232325/kv_rocks.log|cut -d ' ' -f 4- | jq -c '[.cf_name, (.table_properties.raw_key_size + .table_properties.raw_value_size) / .table_properties.data_size]'
@daverigby
daverigby / mac_os_core_id.cc
Last active January 24, 2018 22:39
get current core number on macOS
#include <atomic>
#if defined(__i386__) || defined(__x86_64__)
#include <cpuid.h>
#endif
#include <cstdio>
#include <chrono>
#include <cinttypes>
static inline uint64_t rdtscp( uint32_t & aux )
{
@daverigby
daverigby / c++_pretty_printing.md
Created March 13, 2018 16:52
Enable C++ pretty printing on CentOS 7

$ cat ~/.gdbinit python import sys sys.path.insert(0, '/usr/share/gcc-4.8.2/python') from libstdcxx.v6.printers import register_libstdcxx_printers register_libstdcxx_printers (None) end

@daverigby
daverigby / undefined-enum
Last active March 15, 2018 14:18
Example of UBSan enum error
$ cat undefined.cc
#include <stdexcept>
enum Enum {
A,
B,
C,
Invalid
};
@daverigby
daverigby / ubsan_break_on_runtime_errors
Last active June 19, 2018 12:40
UBSan: break on runtime errors in debugger
b __asan_backtrace_alloc
# GCC 7 on Ubuntu 16.06 requires a different symbol:
break __sanitizer::Die()