Skip to content

Instantly share code, notes, and snippets.

View adjam's full-sized avatar
💭
Setting my GitHub status

Adam Constabaris adjam

💭
Setting my GitHub status
  • NC State University Libraries
View GitHub Profile
@adjam
adjam / marc-validators.json
Last active November 3, 2015 14:47
Example declarative MARC record validation in JavaScript.
{
"100" : {
"required" : true,
"description" : "Main Author",
"indicators" : [ ["#", " ", "1"], ["#"] ],
"subfields" : {
"required" : ["a"],
"optional" : ["b"]
}
@adjam
adjam / logparse.py
Last active February 6, 2023 15:45
Pretty cheap Apache log parser in Python that outputs to SQLite3 or JSON. Splits HTTP Method and path, and also logs referer and referer host separately.Not particularly efficient, but it's better than nothing and lets you do some quick analysis, e.g. after running, you can do something like: sqlite3 output-sq3.dat "select referer_host, count(1)…
#!/usr/bin/env python
# pip install --user apachelogs
# ./logparse.py [logfile] [json|db] [output file name]
# JSON output is assumed; if output filename is omitted
# output.[json|db] will be generated
import apachelogs
import os
{
"001": {
"repeatable": false,
"subfields": {},
"description": "The control number assigned by the organization creating, using, or distributing the record. The MARC code for the organization is contained in field 003 (Control Number Identifier)."
},
"003": {
"repeatable": false,
"subfields": {},
"description": "The MARC code for the organization whose control number is contained in field 001 (Control Number)."