Skip to content

Instantly share code, notes, and snippets.

View jimklo's full-sized avatar

Jim Klo jimklo

View GitHub Profile
@jimklo
jimklo / main.js
Created May 19, 2012 06:13
BrowserID login error
[debug] [<0.1653.0>] Verifying browserid audience: localhost:5984
[debug] [<0.1653.0>] Verifying browserid assertion: %5Bobject%20Object%5D
[debug] [<0.1653.0>] Verification service response:
[{<<"status">>,<<"failure">>},{<<"reason">>,<<"malformed assertion">>}]
[debug] [<0.1653.0>] Failed verification from https://browserid.org/verify:
[{<<"status">>,<<"failure">>},{<<"reason">>,<<"malformed assertion">>}]
[debug] [<0.1653.0>] Minor error in HTTP request: {error,failed_verification}
[debug] [<0.1653.0>] Stacktrace: [{couch_httpd_browserid,
verify_id_with_crutch,3,
[{file,"src/couch_httpd_browserid.erl"},
@jimklo
jimklo / README.md
Created May 9, 2012 01:12
1.2.0 Replicator dying while trying to replicate from 1.1.1

Problem

Trying to sync a db from 1.1.1 to 1.2.0 using a replication filter. It's not clear what's happening. The log from the 1.1.1 is clean, just status 200's on the get for _changes. The log from 1.2.0 says it's timing out.

Procedure

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

curl -H 'Content-type: application/json' -X POST 'http://localhost:6984/resource_data' --data-binary @replication_db_doc.js

@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'

@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 / 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 / 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,
// 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 / 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
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 / 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: