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
{
"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)."
@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
@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 / marc-form-stub.html
Last active October 27, 2015 18:35
HTML and JS snippets for the basis of an HTML-based MARC editor that uses MARC-in-JSON format.
<form id="marcForm">
<div class="leader">
<!-- imagine all that leader stuff in here -->
</div>
<div class="field controlField" id="[ some-autogenerated-id ]">
<label>Tag <input type="text" name="tag" pattern="[0-9]{3}">&nbsp; <input type="text" name="data" />
</div>
<div class="field dataField" id="[some-autogenerated-id]>
@adjam
adjam / ole_fix_default_chart.sql
Last active November 6, 2015 15:46
SQL to give default chart of accounts a code that allows it to be edited. Replace 'NC' with a code that makes sense to you.
set foreign_key_checks = 0;
-- assumes 'bootstrap' chart was loaded with '01' as the code; the UI will reject this as invalid, so you need a non-numeric code
-- find/replace all occurrences of 'NC' with alphabetic code that makes sense to you.
update ca_chart_t SET FIN_COA_CD = 'NC' WHERE FIN_COA_CD = '01';
UPDATE ap_neg_pmt_rqst_aprvl_lmt_t SET FIN_COA_CD= 'NC' WHERE FIN_COA_CD= '01';
UPDATE ap_pmt_rqst_acct_chg_t SET FIN_COA_CD= 'NC' WHERE FIN_COA_CD= '01';
UPDATE ap_pmt_rqst_acct_t SET FIN_COA_CD= 'NC' WHERE FIN_COA_CD= '01';
UPDATE ap_sum_acct_t SET FIN_COA_CD= 'NC' WHERE FIN_COA_CD= '01';
@adjam
adjam / CONTRIBUTING.md
Last active December 8, 2015 17:11
OLE README.md drafts

Contributing to OLE

This project is new to GitHub and our process for pull requests is under development. Please watch this space for updates. In the meantime, if you are interested in collaborating with the OLE project, please contact Heather Beery, the project manager, at hbeery AT iu dot edu

Kuali OLE is distributed under the Educational Community License, version 2.0 (ECL 2.0), and all contributions must be distributable under that license. In order to do this, we require that contributors sign a Contributor License Agreement (CLA), which will need to be submitted to the Kuali Foundation. In addition, the Kuali Foundation requires each institution that employs contributors to sign a Corporate Contributor License Agreement (CCLA). For details, see the [License Agreement Process](http

@adjam
adjam / pager.py
Created September 1, 2016 00:48
Example of how to iterate over solr results as if it's just a list of documents
#!/usr/bin/python
from random import randint
class QueryResult(object):
"""Mock representation of a set of matching results to a query"""
def __init__(self,query,max_results):
self.query = query
self.count = randint(1,max_results)
@adjam
adjam / RecordIterator.java
Created September 8, 2016 19:34
Java decorator for marc4j MarcReader class to allow it to be using as an Iterator or a Java 8 Stream
package edu.example.lib.marc;
import org.marc4j.MarcReader;
import org.marc4j.marc.Record;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.function.Consumer;
import java.util.stream.Stream;
@adjam
adjam / tosolr.py
Last active September 14, 2016 19:00
Solr Schema "autogeneration" from Endeca Mappings spreadsheet
#!/usr/bin/env python3
import sys
from lxml import objectify, etree
import itertools
from csv import DictReader
# mnemonic for a widely used dictionary key
@adjam
adjam / extract_ice.py
Last active September 21, 2016 20:39
Extract TOCs from Syndetics ICE XML
#!/usr/bin/python
from lxml import etree
import glob
import json
import re
class Cleaner(object):