Skip to content

Instantly share code, notes, and snippets.

View garrensmith's full-sized avatar

Garren garrensmith

View GitHub Profile
package main
import (
"bytes"
"fmt"
"log"
badger "github.com/dgraph-io/badger/v4"
)
@garrensmith
garrensmith / instrumentation.rb
Created June 26, 2012 16:41
CouchRest Instrumentation for Rails 3
# add to config/initializers/instrumentation.rb
module CouchRest
class Database
alias_method :old_get, :get
alias_method :old_view, :view
alias_method :old_update_doc, :update_doc
alias_method :old_delete_doc, :delete_doc
// This is a follow on example from @bennadel blogpost https://www.bennadel.com/blog/3256-monkey-patching-the-mango-find-plugin-to-use-alldocs-in-pouchdb-6-2-0.htm
// This uses allDocs() with the keys selector to do a quick find for specific id's.
// It then uses pouchdb-selector-core to further filter the results. pouchdb-selector-core is the library that does the in-memory filtering
// for pouchdb-find and in the changes feed and with replication
// use pouchdb-browser here if you are running this in the browser
var PouchDB = require('pouchdb-node');
var selectors = require('pouchdb-selector-core');
#!/bin/bash -e
rm -rf couchdb
git clone https://github.com/apache/couchdb.git
cd couchdb
echo ""
add_subtree () {
name=$1
{
"version": "0.2.0",
"configurations": [
{
"name": "Tests",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
"stopOnEntry": false,
use serde_json;
macro_rules! query_type {
("fields" => $fields:expr) => {{
println!("field {:?}", $fields);
"boom".to_string()
}};
(
{$section:expr => {
use std::fmt;
use hyper::Error as hyperError;
use std::error::Error as StdError;
use std::collections::HashMap;
use serde_json;
#[derive(Debug)]
pub struct Error {
pub error: String,
pub description: String
@garrensmith
garrensmith / server.go
Created February 11, 2013 07:23
Sql invalid memory address or nil pointer deference error
ab -c 35 -n 1000 http://127.0.0.1:8000/
var db = new PouchDB('ddd');
db.bulkDocs([
{ name: 'Mario', _id: 'mario', rank: 5, series: 'Mario', debut: 1981, awesome: true },
{ name: 'Jigglypuff', _id: 'puff', rank: 8, series: 'Pokemon', debut: 1996,
awesome: false },
{ name: 'Link', rank: 10, _id: 'link', series: 'Zelda', debut: 1986, awesome: true },
{ name: 'Donkey Kong', rank: 7, _id: 'dk', series: 'Mario', debut: 1981, awesome: false },
{ name: 'Pikachu', series: 'Pokemon', _id: 'pikachu', rank: 1, debut: 1996, awesome: true },
{ name: 'Captain Falcon', _id: 'falcon', rank: 4, series: 'F-Zero', debut: 1990,
%Replace from line 251 in couch_httpd_misc_handlers.erl
% httpd log handlers
handle_log_req(#httpd{method='GET'}=Req) ->
ok = couch_httpd:verify_is_server_admin(Req),
Bytes = list_to_integer(couch_httpd:qs_value(Req, "bytes", "1000")),
Offset = list_to_integer(couch_httpd:qs_value(Req, "offset", "0")),
Chunk = couch_log:read(Bytes, Offset),
case couch_httpd:qs_value(Req, "format", "text") of
"json" ->