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 / configurable.rb
Last active August 21, 2018 13:37
'Configurable' module for Ruby, similar to https://github.com/markevans/configurable
#!/usr/bin/env ruby
# Makes a class globally configurable, e.g. in a Rails initializer.
# Usage:
# `class MyClass
# include Configurable
# create_config do
# # url attribute has a default value, which is the return value of the block
# url { 'http://www.example.com'}
# # name attribute is allowed but has no default value
@adjam
adjam / marcsplit
Created June 19, 2018 19:45
Groovy script to take a batch of MARC files and split them into smaller files with a discrete size.
#!/usr/bin/env groovy
@Grapes(
@Grab(group='org.marc4j', module='marc4j', version='2.8.3')
)
import org.marc4j.MarcStreamReader
import org.marc4j.MarcXmlReader
import org.marc4j.MarcXmlWriter
import org.marc4j.marc.Record
import org.marc4j.converter.impl.AnselToUnicode
@adjam
adjam / encrypt.sh
Last active April 10, 2018 15:37
Quick tool to allow a correspondent to encrypt a secret of their devising and send it to you using your GPG key
#!/bin/sh
cat << 'END_OF_PUBKEY' > my_gpg_key.pub
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2
blah blah
-----END PGP PUBLIC KEY BLOCK-----
END_OF_PUBKEY
@adjam
adjam / apache_download.py
Last active July 27, 2022 23:52
Ansible action_plugin for downloading apache projects to localhost so they can be deployed to managed hosts. Validates checksum of download.
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
__doc__ = """Ansible Action Plugin that downloads (various) Apache projects
to the local machine, for easy deployment to managed machines via the `copy`
or `unarchive` modules. Fetches projects from nearest mirror and validates
their sha1 sum against the values downloaded from the main Apache site.
This plugin _requires_ the `requests` module be installed for all HTTPish
activities.
module MarcToArgot
# namespace for institution-specific macros to be used in Traject config files
module Macros
autoload :Shared, 'marc_to_argot/macros/shared_macros'
autoload :NCSU, 'marc_to_argot/macros/ncsu_macros'
end
end
@adjam
adjam / rds-control
Created July 18, 2017 19:59
Allows pretty simple commands to list, start and stop AWS RDS instances from the command line
#!/usr/bin/env python3
# NB Python 3
# need boto3, attr, and tabulate python libraries.
# all installable via pip; your linux distribution
# may also supply them via its package installer
# usage -- you should have already configured the AWS CLI
# before using this. Mostly it's a wrapper around some common
@adjam
adjam / add-dochandler.json
Created July 11, 2017 20:22
Example: add request handler for TRLN argon to Solr at runtime
{
"add-requesthandler" : {
"name" : "/document",
"class" : "solr.SearchHandler",
"defaults" : {
"echoParams" : "explicit",
"fl" : "*",
"rows" : 1,
"q" : "{!term f= id v = $id}"
}
@adjam
adjam / marcrenaissance.sh
Created June 22, 2017 14:55
Decruftify old MARC
#!/bin/sh
# you need the yaz tools installed, these are readily available on many Linux distros
# via the package manager or on Macs via homebrew
yaz-marcdump -i marc -o marcxml -f marc8 -t utf8 -l 9=97 mar21encodedasmarc8.mrc > marcxmlencodedasutf8.xml
#!/usr/bin/env python3
# NB Python 3
# need boto3, attr, and tabulate python libraries.
# all installable via pip; your linux distribution
# may also supply them via its package installer
# usage -- you should have already configured the AWS CLI
# before using this. Mostly it's a wrapper around some common
#!/usr/bin/env python3
import threading
import time
from queue import Queue
eq = Queue()
class Dead(Exception):