Skip to content

Instantly share code, notes, and snippets.

View anandology's full-sized avatar

Anand Chitipothu anandology

View GitHub Profile
@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 / 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 / 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 / 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
@anandology
anandology / format_skype_text.py
Created June 3, 2011 10:01
Script to format the conversation text copied from skype window for better readability.
"""Script to format the conversation text copied from skype window for better readability.
"""
import sys
import re
import web
re_timeline = re.compile("^([^/]* )?((?:\d\d/\d\d/\d\d )?\d\d?:\d\d [AP]M) *$")
def parse_text(text):
lines = text.strip().splitlines()
#! /usr/bin/env python
import json
import urllib
def jsonget(url):
text = urllib.urlopen(url).read()
return json.loads(text)
def get_edition(key):
url = "http://openlibrary.org" + key + ".json"