Skip to content

Instantly share code, notes, and snippets.

View jimklo's full-sized avatar

Jim Klo jimklo

View GitHub Profile
@jimklo
jimklo / gist:1881137
Created February 22, 2012 03:40
couchdb.log
[Wed, 22 Feb 2012 03:06:22 GMT] [error] [<0.84.0>] {error_report,<0.30.0>,
{<0.84.0>,supervisor_report,
[{supervisor,{local,couch_secondary_services}},
{errorContext,start_error},
{reason,
{'EXIT',
{undef,
[{couch_spatial,start_link,[],[]},
{supervisor,do_start_child,2,
[{file,"supervisor.erl"},{line,286}]},
Apache CouchDB 1.1.1 (LogLevel=info) is starting.
[error] [<0.84.0>] {error_report,<0.30.0>,
{<0.84.0>,supervisor_report,
[{supervisor,{local,couch_secondary_services}},
{errorContext,start_error},
{reason,
{'EXIT',
{undef,
[{couch_spatial,start_link,[],[]},
{supervisor,do_start_child,2,
@jimklo
jimklo / map reduce
Created February 23, 2012 22:41 — forked from nisbus/map reduce
Map reduce problem
map function:
function(doc) {
if(doc.symbol.lastIndexOf("HFF") == 0){
emit(doc.symbol,{last_update:doc.last_updatedutc,symbol:doc.symbol,last_yield:doc.last_yield});
}
}
View output:
var ASNPatterns = [
/http:\/\/purl\.org\/ASN\/resources\/[A-Z0-9]+/g
];
var Alignment = {
parseDCT_ConformsTo: function(resource_data) {
var stds = {};
try {
var nsdl = eval(resource_data);
@jimklo
jimklo / collation.py
Created February 25, 2012 00:15
try to figure out collation in couchdb
from couchdb.client import Server
server = Server()
db = server['collation-test']
try:
for idx in range(65535):
db.save( {'unichr':unichr(idx), 'code': idx, 'hex': str(hex(idx))} )
print "{0}\n".format(hex(idx))
except Exception, e:
raise e
// jcurl 'http://localhost:5984/asn_paradata/_design/standards-alignment-lr-paradata/_list/to-json/resource-by-discriminator?limit=100&startkey=[["http://purl.org/ASN/resources/S1000674"]]&endkey=[["http://purl.org/ASN/resources/S1000674",{}]]' | jsonlint
{
"documents": [
{
"result_data": {
"resource": "http://illuminations.nctm.org/LessonDetail.aspx?ID=L299",
"discriminator": [
"http://purl.org/ASN/resources/S1000674",
"matched"
]
@jimklo
jimklo / run.py
Created March 21, 2012 20:52
LRDataPump quick fix
#Copyright 2011 SRI International
#
#Licensed 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
@jimklo
jimklo / extract-slice.js
Created March 21, 2012 21:08
Replication via Slice
var https = require('https');
var http = require('http');
var querystring = require('querystring');
var _ = require('underscore');
// https://node01.public.learningregistry.net/slice?identity=Brokers+of+Expertise
function GetSlice(identity, token, fn, db_name, doc_list) {
var q = {};
if (identity) {
@jimklo
jimklo / replication.txt
Created April 16, 2012 22:49
couchdb_stack_trace
(lr)Jim-Klos-MacBook-Pro:LRChart jklo$ jcurl -X POST 'http://localhost:5984/_replicate' -d '{"source":"resource_data_whole_thing","target":"resource_data","filter":"lr-filter/resource_data_only","create_target":true}'
{"error":"{{badmatch,{ok,<<0,0,122,128,18,65,109,135,235,206,76,135,231,208,175,83,29,\n 25,94,131,104,11,100,0,9,100,98,95,104,101,97,100,101,114,\n 97,5,98,0,31,206,212,97,0,104,3,110,5,0,43,96,17,246,2,104,\n 3,98,0,13,54,100,97,0,100,0,3,110,105,108,100,0,3,110,105,\n 108,104,3,110,5,0,147,109,17,246,2,98,0,13,54,100,100,0,3,\n 110,105,108,104,2,110,5,0,132,74,148,245,2,106,97,0,100,0,3,\n 110,105,108,100,0,3,110,105,108,98,0,0,3,232,128,0,0,19,121,\n 73,18,79,48,57,117,158,70,248,254,161,174,184,158,209,131,\n 104,2,109,0,0,0,4,131,104,1,106,109,0,0,0,2,131,106,0,0,1,\n 239,1,141,5,240,70,131,104,2,100,0,7,107,118,95,110,111,100,\n 1
@jimklo
jimklo / README.md
Created May 8, 2012 18:17
LR Upgrade Filter

Migrate pre 0.23.6 resource_data to 0.23.6 resource_data

  1. add the design doc for filtering to the old resource_data

    curl -H 'Content-type: application/json' -X POST 'http://localhost:5984/resource_data_big' --data-binary @design_doc.js

  2. create new target resource_data db

    curl -H 'Content-type: application/json' -X PUT 'http://localhost:5984/resource_data'