Skip to content

Instantly share code, notes, and snippets.

Christian Dahlqvist cdahlqvist

Block or report user

Report or block cdahlqvist

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Riak CRDT HTTP Examples
Start a Riak 2.0 cluster. This has been tested against Riak 2.0.0pre11.
First set up bucket types (note you can name these as you like for your domain (and add other properties)
$ rel/riak/bin/riak-admin bucket-type create maps '{"props":{"datatype":"map"}}'
maps created
$ rel/riak/bin/riak-admin bucket-type create sets '{"props":{"datatype":"set"}}'
sets created
$ rel/riak/bin/riak-admin bucket-type create counters '{"props":{"datatype":"counter"}}'
counters created
@cdahlqvist
cdahlqvist / statslogger.py
Last active Aug 29, 2015
Simple script that logs a set of Riak statistics to a daily CSV file once a minute
View statslogger.py
#!/usr/bin/env python
import httplib
import json
from datetime import datetime, date, time
from time import sleep
import os.path
from multiprocessing import Process
View gist:ec3a26bb64e979e8af69
Christians-MacBook-Air:nyc_traffic_accidents acd$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'puppetlabs/ubuntu-14.04-64-puppet' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'puppetlabs/ubuntu-14.04-64-puppet'
default: URL: https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-puppet
==> default: Adding box 'puppetlabs/ubuntu-14.04-64-puppet' (v0.3.0) for provider: virtualbox
default: Downloading: https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-puppet/version/3/provider/virtualbox.box
==> default: Successfully added box 'puppetlabs/ubuntu-14.04-64-puppet' (v0.3.0) for 'virtualbox'!
View gist:96d0d132c5586229345e
# Add mapping
curl -XPUT localhost:9200/restaurants -d '{
"mappings": {
"areas": {
"properties": {
"name": {
"type": "string"
},
"area": {
"type": "string"
View LoggingWebServer.js
var http = require('http');
var fs = require('fs');
var optimist = require('optimist')
.usage('Simple web server to log incoming requests.\n\nUsage: $0 [options]')
.options({
file: {
alias: 'f',
describe: 'Path of file to log to. Server will log to stdout if no file specified.'
},
View sum_aggregation_example
curl -XPOST http://localhost:9200/test/test -d'{
"title": "one",
"total": 10
}'
curl -XPOST http://localhost:9200/test/test -d'{
"title": "one",
"total": 10
}'
@cdahlqvist
cdahlqvist / keylister.erl
Last active Dec 15, 2015
Script to list all keys in a Riak bucket and spool to a file. To be run while attached to riak console.
View keylister.erl
%% -------------------------------------------------------------------
%%
%% keylister: Utility for listing all keys in a bucket
%%
%% Copyright (c) 2013 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you 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
@cdahlqvist
cdahlqvist / riak_graphite.erl
Last active Dec 16, 2015
Server process for sending statistics to Graphite from Riak
View riak_graphite.erl
%% -------------------------------------------------------------------
%%
%% riak_graphite: Server process to emit statistics to Graphite
%%
%% Copyright (c) 2013 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you 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
View pb_status_anon.txt
PBStatusFun = fun() ->
VnodePids = [Pid || {_, Pid} <- riak_core_vnode_manager:all_index_pid(riak_kv_vnode)],
Links = [process_info(Pid, [links]) || Pid <- VnodePids],
WorkerPoolPids = [WPPid || [{links,[_, WPPid]}] <- Links],
WorkerPoolLinks = [process_info(Pid, [links]) || Pid <- WorkerPoolPids],
PoolboyPids = [PoolboyPid || [{links,[_, PoolboyPid]}] <- WorkerPoolLinks],
[poolboy:status(Pid) || Pid <- PoolboyPids]
end.
PBStatusCountFun = fun() ->
@cdahlqvist
cdahlqvist / pb_status_monitor.erl
Created May 24, 2013
Process that monitors the status of the poolboy worker pool used for coverage queries.
View pb_status_monitor.erl
%% -------------------------------------------------------------------
%%
%% pb_status_monitor: PoolBoy pool monitor
%%
%% Copyright (c) 2013 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you 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
You can’t perform that action at this time.