Skip to content

Instantly share code, notes, and snippets.

require File.expand_path('../helper', __FILE__)
class TestExample < Test::Unit::TestCase
def setup
threads = []
3.times do |line|
threads << Thread.new do
data = File.readlines(File.join(ROOT_DIR,'test','data'))[line]
data.split(',').each do |value|
DataPointDocument.create(:value => value.to_i)
<!DOCTYPE html>
<html lang="en">
<head>
<title>WebGLiak</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
color: #808080;
font-family:Monospace;

Rolling with Eventual Consistency

Keywords: riak, ripple, statistics, eventually consistent, race condition, CRDT, map/reduce, analytics

In a previous post I wrote about the different mindset that a software engineer should have when building for a key-value database as opposed to a relational database. When working with a relational database, you describe the model first and then query the data later. With a key-value database, you focus first on what you want the result of the query to look like, and then work backward toward a model.

As an example, I described averaging some value:

"In a SQL database, we can just call average() on that column, and it will compute the answer at query time. In a key-value store, we can add logic in the application layer to catch the object before it enters Riak, fetch the average value and number of included elements from Riak, compute the new rolling average, and save that answer back in Riak

@clr
clr / gist:3908781
Created October 17, 2012 22:36
Dmitri's blog post

Rails Rumble with Riak and Ripple - Three Developers and a Lot of Rs

This past weekend, Bryce Kerley, David Andersen, and I had the pleasure and honor of participating in Rails Rumble 2012. This event is a 48-hour competition to design, build and deploy a web application in Ruby and Rails (or one of the other Rack-based web framework). Developing at this pace is grueling, to say the least (especially since it took place immediately after we all flew home from Ricon 2012), but also really exciting. You get the whole product cycle experience, from design to feature releases to testing and QA, all in one intense weekend.

Our application is Brainload. It's a social flashcard/memorization aid tool, which lets users create, share and review flash cards on various topics (useful for memorizing programming language syntax, new APIs, school exam preparations, and building foreign language vocabulary). You can launch

@clr
clr / gist:3944385
Created October 24, 2012 06:29
Application Development on Riak: Getting Started

The CRUD model is a well-known pattern in application development. In the CRUD lingo, you can Create, Read, Update, or Delete your data object. This lines up well with the Resource Access Pattern, with which many are familiar as a component of a RESTful API.

The Resource Access Pattern is very popular because of its simplicity. Writing a Resource Access Pattern on top of Riak is really simple too. Riak uses a RESTful HTTP syntax, and maps the operations to CRUD like so:

CRUD Verb HTTP Verb URL Description
Create PUT /buckets/resource-type/keys/key-name Make a new resource at the given key and store the submitted data.
POST /buckets/resource-type Make a new resource and get the unique key generated for it.
Read GET /buckets/resource-type/keys/key-name Get the resource data back for the given key.
Update PUT /buckets/resource-type/keys/key-name Store the submitted data for the given key.
@clr
clr / access.log
Created October 30, 2012 22:21
Wide Finder ErlangGames
208.115.113.86 - - [29/Oct/2012:17:11:45 -0700] "GET /Case%20History/new_page_1.htm HTTP/1.1" 404 89 "-" "Mozilla/5.0 (compatible; Ezooms/1.0; ezooms.bot@gmail.com)" "dakotalargeanimalclinic.com"
218.30.103.53 - - [29/Oct/2012:17:37:02 -0700] "GET /robots.txt HTTP/1.1" 200 54 "-" "Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)" "www.dakotalargeanimalclinic.com"
208.115.111.70 - - [29/Oct/2012:17:46:47 -0700] "GET /robots.txt HTTP/1.1" 200 54 "-" "Mozilla/5.0 (compatible; Ezooms/1.0; ezooms.bot@gmail.com)" "dakotalargeanimalclinic.com"
74.125.182.28 - - [29/Oct/2012:17:54:04 -0700] "GET /Equine_Nutrition/teeth_check_horse.html HTTP/1.1" 200 4111 "http://www.google.com/search" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko; Google Web Preview) Chrome/22.0.1229 Safari/537.4" "www.dakotalargeanimalclinic.com"
70.238.130.51 - - [29/Oct/2012:17:54:04 -0700] "GET /photo_gallery/black_cat_mouth_open.JPG HTTP/1.1" 200 632815 "http://www.google.com/search?num=10&hl=en&sit
@clr
clr / riak_basic.txt
Created November 6, 2012 05:34
Basic Querying Examples
curl -X PUT http://127.0.0.1:8091/buckets/qcon/keys/nosql4evah \
-H 'content-type: text/plain' \
-d $'Scale out all the things!\n'
curl -X GET http://127.0.0.1:8091/buckets/qcon/keys/nosql4evah
curl -X DELETE http://127.0.0.1:8091/buckets/qcon/keys/nosql4evah
curl -X GET http://127.0.0.1:8091/buckets/qcon/keys/nosql4evah
curl -X PUT http://127.0.0.1:8091/buckets/statefarm_2i/keys/apple \
-H 'x-riak-index-category_bin: fruit' \
-H 'Content-Type: text/plain' \
-d 'malus domestica'
curl -X PUT http://127.0.0.1:8091/buckets/statefarm_2i/keys/banana \
-H 'x-riak-index-category_bin: fruit' \
-H 'Content-Type: text/plain' \
-d 'musa acuminata'
@clr
clr / gist:5605122
Created May 18, 2013 17:00
Install basho_bench from RPM
[basho-proserv]
name=Basho Proserv Packages for Enterprise Linux 6 - $basearch
baseurl=https://s3.amazonaws.com/basho-proserv-benchmarking/yum/el/6/tools/$basearch
failovermethod=priority
enabled=1
gpgcheck=0
Casey Rosenthal
2:40 PM
k
what would be a good platform for ProServ to ask some questions?
like
are Links dead? can we deprecate them?
2i => we end up frequently recommending clients *not* use 2i, and implement a term-based inverted index instead
Epic Redmond
2:42 PM
I'd love to. I didn't even want to put them in the docs