Skip to content

Instantly share code, notes, and snippets.

View anandology's full-sized avatar

Anand Chitipothu anandology

View GitHub Profile
@anandology
anandology / edition.
Created March 20, 2009 11:14
couchdb view for /type/edition
{
"_rev": "1-262566171",
"_id": "_design/type_edition",
"language": "javascript",
"views": {
"by_title": {
"map": "function(doc) { if (doc.type.key == '/type/edition' && doc.title) emit(doc.title, doc.key);}"
},
"by_isbn_10": {
"map": "function(doc) { if (doc.type.key == '/type/edition' && doc.isbn_10) for (var i in doc.isbn_10) emit(doc.isbn_10[i], doc.key);}"
@anandology
anandology / ol.conf
Created April 17, 2009 09:23
OL configurations in various formats
[infogami]
infogami_server = "http://ia331526:7070"
smtp_server = "mail.archive.org"
secret_key = "xxx"
plugins = ["openlibrary", "search", "scod", "recaptcha", "akismet", "i18n"]
python_path = ["/0/pharos/code/openlibrary/pharos"]
[plugin_search]
solr_server_address = "pharosdb-bu.us.archive.org:7983"
solr_fulltext_address = "ia301443:7983"
"""web frontend for fastcgi process.
Usage:
python fcgi_server.py socket-file
"""
from web.wsgiserver import CherryPyWSGIServer
from flup.client.fcgi_app import FCGIApp
server_address = ("0.0.0.0", 8080)
"""Utility to iterate over couchdb view result."""
import urllib
import simplejson
class Result:
def __init__(self, total_rows, offset, data):
self.total_rows = total_rows
self.offset = offset
self._data = data
def f(x):
def g(y):
fail
return g
def format_tb(tb):
# this should get value of x
f1 = f(1)
try:
@anandology
anandology / subdomain_wsgi.py
Created November 1, 2010 12:11
WSGI application to delegate requests based on domain name.
import re
class SubDomainApp:
"""WSGI application to delegate requests based on domain name.
"""
def __init__(self, mapping):
self.mapping = mapping
def __call__(self, environ, start_response):
host = environ.get("HTTP_HOST", "")
@anandology
anandology / jsoneval.js
Created November 4, 2010 09:37
node.js script to process JSON strings one per each line.
#!/usr/bin/env node
var carrier = require('carrier');
var stdin = process.openStdin();
stdin.setEncoding('utf8');
carrier.carry(stdin, function(line) {
var body = JSON.parse(line);
eval(process.argv[2]);
@anandology
anandology / coucheval.js
Created November 4, 2010 09:39
node.js script to process couchdb output
#!/usr/bin/env node
// Sample usage:
//
// $ curl -s 'http://127.0.0.1:15984/seeds/_all_docs?limit=10&include_docs=true' | coucheval.js 'console.log(JSON.stringify(row.doc));'
//
var carrier = require('carrier');
var stdin = process.openStdin();
@anandology
anandology / seeds_view.py
Created November 10, 2010 04:49
Python Script to add design document to couchdb database
import couchdb
view = {
"_id": "_design/seeds",
"fulltext": {
"by_seed": {
"index": """function(doc) {
if (doc.seeds) {
var d = new Document();
for (var i=0; i<doc.seeds.length; i++) {
@anandology
anandology / subject_comparision.txt
Created December 2, 2010 10:06
Comparison of works for subject:carpentry in solr (via subjects API) and couchdb (lists).
# key has_subject in_solr in_couch
/works/OL7714039W True False True
/works/OL7714035W True False True
/works/OL10612120W True False True
/works/OL7713011W True False True
/works/OL7713015W True False True
/works/OL36429W True False True
/works/OL9365418W False True False
/works/OL13571022W False True False
/works/OL5264422W False True False