Skip to content

Instantly share code, notes, and snippets.

View craigboman's full-sized avatar

Craig Boman craigboman

View GitHub Profile

Keybase proof

I hereby claim:

  • I am craigboman on github.
  • I am libroman (https://keybase.io/libroman) on keybase.
  • I have a public key ASC8xPUIjs-cIpgYoYkpEeSS704eOl0qXoa6JEXfe4KZiQo

To claim this, I am signing this object:

(oclc-auth-python) [dude@localhost oclc-auth-python]$ sudo python setup.py install
[sudo] password for dude:
running install
running bdist_egg
running egg_info
creating authliboclc.egg-info
writing requirements to authliboclc.egg-info/requires.txt
writing authliboclc.egg-info/PKG-INFO
writing top-level names to authliboclc.egg-info/top_level.txt
writing dependency_links to authliboclc.egg-info/dependency_links.txt
@craigboman
craigboman / ffmpeg.md
Created April 30, 2019 18:14 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

## goal of code is to loop through csv imported python list of OCLC numbers, individually querying the OCLC holding status() api
## var number is not incrementing
for i in data:
counter = 0 #probably a better way to do this counter
number = data[counter][0]
holding = status(number)
print(number,holding)
counter += 1
SELECT
--*
--p.call_number_norm,
--m.record_type_code || m.record_num AS item_record_num,
--i.item_status_code,
-- Copy --not sure we can get copy
-- p.call_number_norm,
-- Volume
-- b.best_author,
-- b.best_title,
@craigboman
craigboman / 008-control_field-merge
Created September 11, 2018 18:15
Merging sql fields to create an 008
SELECT
--
c.p00||c.p01||c.p02||c.p03||c.p04||c.p05||c.p06||c.p07||c.p08||c.p09||c.p10||c.p11||c.p12||c.p13||c.p14||c.p15||c.p16||c.p17||c.p18||c.p19||c.p20||c.p21||c.p22||c.p23||c.p24||c.p25||c.p26||c.p27||c.p28||c.p29||c.p30||c.p31||c.p32||c.p33||c.p34||c.p35||c.p36||c.p37||c.p38||c.p39||c.p40||c.p41||c.p42||c.p43
--merging control_field table into an 008 field
FROM
sierra_view.control_field AS c
limit 100;
@craigboman
craigboman / file write error.py
Created August 24, 2018 18:42
describes a file read/write error in python
pth= '../json/'
#failed attempt to split out base filename: base = os.path.splitext(filename)[0]
merge = os.path.join(pth, Path(filename).stem)
with open(merge, 'w') as f:
json.dump(words, f, ensure_ascii=False)
f.close()
jsn = merge+'.json'
os.rename(merge, jsn)
SELECT
*
FROM
sierra_view.phrase_entry AS p
WHERE
p.index_entry IN --how can we do IN but also do fuzzy matching?
('9780870233227%',
'9781781884652%' --plus 10,000 ISBNs
)
from configparser import ConfigParser
from base64 import b64encode
import requests
import json
import re
# get the api paramaters from the configuration file
# config file looks like this:
# [api]
# base_url = https://sierra-test.library.org/iii/sierra-api/v5
marvin@ubuntu-1gb-nyc3-01:~/projects/search_app$ rake solr:marc:index_test_data
2017-10-18T13:32:17+00:00 INFO Traject::SolrJsonWriter writing to 'http://127.0.0.1:8983/solr/blacklight-core/update' in batches of 100 with 1 bg threads
2017-10-18T13:32:17+00:00 INFO Indexer with 1 processing threads, reader: Traject::MarcReader and writer: Traject::SolrJsonWriter
2017-10-18T13:32:17+00:00 ERROR Error in Solr batch add. Will retry documents individually at performance penalty: Solr response: 404: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Erro