Skip to content

Instantly share code, notes, and snippets.

@mcobzarenco
mcobzarenco / Order by time.cpp
Last active August 29, 2015 14:08
Order by time without duplicates
inline int64_t get_monotonous_click() {
static std::atomic<int64_t> last_click{0};
int64_t timestamp{
std::chrono::system_clock::now().time_since_epoch()
/ std::chrono::microseconds(1)};
int64_t old_click{last_click.load()};
int64_t new_click{0};
do {
new_click = std::max(timestamp, old_click + 1);
diff --git a/CMakeLists.txt b/CMakeLists.txt
index decc40c..a3220e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@ option(rpcz_build_static "Build static library." OFF)
option(rpcz_build_examples "Build rpcz's examples." OFF)
find_package(ProtobufPlugin REQUIRED)
-find_package(Boost REQUIRED COMPONENTS thread program_options)
+find_package(Boost REQUIRED COMPONENTS thread program_options system)
unique_ptr<string> f(bool b) {
unique_ptr<string> p(new string("ok!"));
unique_ptr<string> p2(new string("okish!"));
if(b) {
return p;
} else {
return p2;
}
}
➜ riakpp git:(master) build/release/src/riaktool -m 10000 -k 10000
[0] riaktool.cpp:81:main: Creating connection pool...
[0] riaktool.cpp:85:main: Buffering messages...
[0] riaktool.cpp:109:main: Buffered 0 messages.
[0] riaktool.cpp:109:main: Buffered 500 messages.
[0] riaktool.cpp:109:main: Buffered 1000 messages.
[0] riaktool.cpp:109:main: Buffered 1500 messages.
[0] riaktool.cpp:109:main: Buffered 2000 messages.
[0] riaktool.cpp:109:main: Buffered 2500 messages.
[0] riaktool.cpp:109:main: Buffered 3000 messages.
@mcobzarenco
mcobzarenco / Power Law Plotting for Facebook Data.py
Created June 26, 2013 12:02
Power Law Plotting for Facebook Data
SCALE = 0.1
XMIN = 820
GAMMA = 3.63719
fb_ccdf = ccdf(degs)
xs = array(fb_ccdf[0][500:])
power_law = array(xs / XMIN) ** (-GAMMA + 1) * SCALE
{
"metadata": {
"name": "Untitled1"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{