Skip to content

Instantly share code, notes, and snippets.

{
"metadata": {
"name": "Untitled1"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@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
➜ 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.
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;
}
}
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)
@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);
template<typename Scalar>
struct ImmutableParams {
std::vector<Eigen::Map<const DynamicMatrix<Scalar>>> W;
std::vector<Eigen::Map<const DynamicVector<Scalar>>> b;
};
template<typename Scalar>
struct MutableParams {
std::vector<Eigen::Map<DynamicMatrix<Scalar>>> W;
std::vector<Eigen::Map<DynamicVector<Scalar>>> b;
#include <chrono>
#include <iostream>
#include <vector>
using namespace std;
template<typename T>
uint64_t time_it_us(const T& t) {
auto begin = std::chrono::high_resolution_clock::now();
Verifying that +anih is my openname (Bitcoin username). https://onename.com/anih
@mcobzarenco
mcobzarenco / wikidata.py
Created July 7, 2015 17:29
Parse wikidata dump in Python
#!/usr/bin/env python
from __future__ import print_function, division
import argparse
import json
import sys
from gzip import GzipFile
def concat_claims(claims):
for rel_id, rel_claims in claims.iteritems():