Skip to content

Instantly share code, notes, and snippets.

@tilgovi
tilgovi / gist:824248
Created February 12, 2011 23:47
[CouchDB] Finding out what was replicated
You can do something like this:
@target host
GET /target => {... "update_seq": X, ...}
POST /_replicate {"source": "<source host>/source", "target": "target"} => {...}
GET /target/_changes?since=X => { //here are your replicated changes }
This last request to /target/_changes will also include any writes to the target database that occurred between the initial GET and /_replicate as well as any writes that occurred after the replication but before the /target/_changes request. If you can only make direct requests against the target database then it is impossible to guarantee an exact answer in the presence of concurrent updates to the target.
On the other hand, if you are performing a push replication from a local database or can otherwise afford to request changes from the source after the replication finishes, you can get exactly what you want even in the presence of concurrent updates to the source and/or the target using the response body from the replication request.
@amedeo
amedeo / gist:820412
Created February 10, 2011 12:00
CouchDB and multiple tags

CouchDB and multiple tags

The problem

Given a set of documents, each associated with multiple tags, how can I retrieve the documents tagged with an arbitrary set of tags?

My solution

@zaius
zaius / background.sh
Created January 16, 2011 23:29
How to redirect a running process output to a file and log out
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
@pixeltrix
pixeltrix / routes.rb
Created October 29, 2010 13:21
Examples of advanced Rails 3.0 routes
Rails.application.routes.draw do
get '/(:locale)/products/(:category)/(page/:page).:extension',
:to => 'products#index',
:as => :products,
:constraints => {
:locale => /[a-z]{2}/,
:category => /.+?/,
:page => /\d+/
},
// Handles JavaScript history management and callbacks. To use, register a
// regexp that matches the history hash with its corresponding callback.
window.HashHistory = {
// The interval at which the window location is polled.
URL_CHECK_INTERVAL : 500,
// We need to use an iFrame to save history if we're in an old version of IE.
USE_IFRAME : jQuery.browser.msie && jQuery.browser.version < 8,
So what exactly is in a Sproingg node?
-------------------------------------
Sproingg is a project to bootstrap a richly featured text communication system over CouchDB using
the following apps and CouchDB features collectively referred to as a Sproingg node
a) A CouchDB database as message inbox with a CouchDB database URL as an address for sending messages (Reqd)
b) A CouchApp that is a forum app (Optional)
c) A CouchApp that is a wiki app (Optional)
d) A CouchApp blog (Optional)
@gravis
gravis / readme
Created September 26, 2010 17:26
tcp syslog logger for rails draft
tcp_syslog is now a gem :
https://github.com/tech-angels/tcp_syslog
<!DOCTYPE html>
<html>
<head>
<title>Sproingg</title>
<link rel="stylesheet" href="style/main.css" type="text/css">
</head>
<body>
#content
.row
.third
.third
.third.last
.row
.half
.half.last
.row
.fourth
@max-mapper
max-mapper / pdxapi-data-preview.html
Created August 19, 2010 03:46
loads geocouch datasets and visualizes them on an openlayers map. see it in action at http://pdxapi.com/preview.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="http://openlayers.org/dev/theme/default/style.css" type="text/css" />
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAUXDSXET8IRGdgHP9FpGw5BT-fVzUWGS_eJ2ZLPBO_6yPqTi0vhQKAzahOrduDq0xQk09GR-UP3Jgcg'></script>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script src="http://www.google.com/jsapi?key=ABQIAAAAUXDSXET8IRGdgHP9FpGw5BT-fVzUWGS_eJ2ZLPBO_6yPqTi0vhQKAzahOrduDq0xQk09GR-UP3Jgcg"></script>
<script type="text/javascript">
google.load("jquery", '1.4');
google.load("maps", "2.x");
</script>