Skip to content

Instantly share code, notes, and snippets.

@coffeemug
coffeemug / concatMap.md
Created July 2, 2013 00:33
An example of poor API documentation

RethinkDB: The concatMap command in Javascript

Declaration

sequence.concatMap(mappingFunction) -> stream
array.concatMap(mappingFunction) -> array

Description

@coffeemug
coffeemug / gist:6168031
Last active February 3, 2022 23:16
The fun of implementing date support
After spending the better part of the month implementing date support
in RethinkDB, Mike Lucy sent the team the following e-mail. It would
have been funny, if it didn't cause thousands of programmers so much
pain. Read it, laugh, and weep!
-----
So, it turns out that we're only going to support dates between the
year 1400 and the year 10000 (inclusive), because that's what boost
supports.
@coffeemug
coffeemug / gist:6417983
Last active December 22, 2015 04:38
Importing `git log` data into RethinkDB
git log --pretty=format:"%H|%ae|%at|%s" | \
python -c " \
import rethinkdb as r; \
import sys; \
r.connect().repl(); \
r.table_create('commits').run(); \
r.table('commits').insert([dict(map(lambda x, y: [x, y], \
['id', 'email', 'date', 'subject'], \
line.split('|', 3))) \
for line in sys.stdin]) \
@coffeemug
coffeemug / gist:6444786
Created September 5, 2013 01:04
RethinkDB vs. Mongo insert test
"""Compares rethinkdb with mongo. Copied from http://pastebin.com/3PqdFTjc. Example output:
mongodb: 0.110867023468
rethink: 2.25043606758
"""
import copy
import pymongo
import rethinkdb as r
import time
David, sorry you ran into these issues. The crash is a known bug, and will be fixed in the 1.12 release (along with the new cache implementation). See https://github.com/rethinkdb/rethinkdb/issues/1389 for more details.
As to the performance you're getting, could you give some additional info so we could track this down?
- Which OS/version are you running?
- Which RethinkDB version are you running? (you can tell by running `rethinkdb --version`)
- Which client driver are you using (and which version)?
- What query do you use to get out 100 documents and how are you measuing latency?
Would really appreciate your feedback so we could fix these issues.
r.table('authors').filter(lambda author:
r.table('users')['last_name'].contains(author['last_name'])).
run(conn)

Migrating to RethinkDB 1.12

There are a number of breaking changes in RethinkDB 1.12 you should be aware of before migrating.

Data migration

First, make sure to go through the regular data migration process, since the 1.12 file format isn't compatible with file formats generated by previous versions of RethinkDB.

Then, replace group_by and grouped_map_reduce commands in your applications with the new group command.

@coffeemug
coffeemug / hn_rethink
Created October 7, 2014 19:08
Grab top stories into RethinkDB via Hacker News API
r.http("https://hacker-news.firebaseio.com/v0/topstories.json").limit(5).map(
r.http(r.add("https://hacker-news.firebaseio.com/v0/item/",
r.row.coerceTo('string'),
".json"))
);

Keybase proof

I hereby claim:

  • I am coffeemug on github.
  • I am coffeemug (https://keybase.io/coffeemug) on keybase.
  • I have a public key whose fingerprint is 5925 55F9 CC4C 2D4E E82E 97AA A33E 7D8E 5279 41E9

To claim this, I am signing this object:

- Inexplicable perversity of human nature.
- The clever machinations of MongoDB's marketing people.
- The AGPL license killed it.
- We spent too long development before monetizing.
- Bad performance.
- Numeric types limited to a 64-bit `float`.
- Great product, but didn't/couldn't translate to revenue.
- Bad business model.
- Failure in timezones/timestamp nuances.