Skip to content

Instantly share code, notes, and snippets.

Jeff Gerhard jeffgerhard

Block or report user

Report or block jeffgerhard

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jeffgerhard
jeffgerhard / open_library_tsv_to_xml_for_alma.py
Last active Jul 31, 2019
Internet Archive / Open Library TSV file to XML for Alma import profile as portfolios
View open_library_tsv_to_xml_for_alma.py
# -*- coding: utf-8 -*-
"""
Build XML file of all our books' data for lending
for the purposes of short-term management of our electronic lending
collection in Alma
"""
import os
@jeffgerhard
jeffgerhard / update.sh
Created Apr 16, 2019
git repo auto-updater
View update.sh
git checkout -- .
git clean -fd
git pull
@jeffgerhard
jeffgerhard / md_render.py
Last active Mar 13, 2019
render markdown file (like README) in jupyter notebook
View md_render.py
from markdown2 import markdown
from IPython.core.display import HTML
with open('README.md', 'r') as fh:
m = markdown(fh.read())
HTML(m)
View trigger.sql
CREATE DEFINER=`root`@`localhost` trigger processtrigger after INSERT ON digitization_process
for each row BEGIN
UPDATE item
SET
item.PhysicalState = (SELECT
NewPhysState
FROM
process_type p
WHERE
NEW.ProcessType = p.ProcessTypeID)
View xsl_revised.css
#toc h3 {margin: 16px 8px 16px 0px;}
#toc dt {margin: 3px; padding: 4px 0px; font-weight: normal;}
#toc dd {margin-top: 3px; margin-left: 16px; padding: 4px 0px;}
#toc dt a:link, #toc dd a:link {color: #333; text-decoration: none;}
#toc dt a:visited, #toc dd a:visited {color: #679146; text-decoration: none;}
#toc dt a:active, #toc dd a:active {color: #679146;}
#toc dt a:hover, #toc dd a:hover {color: #679146;}
View xsl_original
#toc h3 {margin: 16px 8px 16px 0px;}
#toc dt {margin: 3px; padding: 4px 0px; font-weight: normal;}
#toc dd {margin-top: 3px; margin-left: 16px; padding: 4px 0px;}
#toc dt a:link, #toc dd a:link {color: #333; text-decoration: none;}
#toc dt a:visited, #toc dd a:visited {color: #333; text-decoration: none;}
#toc dt a:active, #toc dd a:active {color: #679146;}
#toc dt a:hover, #toc dd a:hover {color: #679146;}
@jeffgerhard
jeffgerhard / compare_and_replace.py
Last active Mar 30, 2017
compare two directories and optionally replace one's content (i.e., from a backup)
View compare_and_replace.py
'''
compare two directories recursively and optionally
replace directories' contents with the other
use case: replacing files from an old backup for
a cloned hard drive that has unpredictably corrupt files
'''
import os
View cleanup_IA_downloads.py
# cleans up the downloaded, bagged masters
# and moves to archival storage
#
# could combine this with the IA download script?
#
# leaves behind a log file with the id's to plug them into the Access db
import os
import shutil
from tkinter.filedialog import askdirectory
@jeffgerhard
jeffgerhard / bagit_script_for_current_directory.bat
Created Aug 2, 2016
batch script to bag-in-place all the subdirectories of the current directory, and list the file ids
View bagit_script_for_current_directory.bat
REM first make a list of the directories
for /d %%A in (*) do echo %%~A>>temp.txt
REM then send each directory to bagit to baginplace
forfiles /C "cmd /c if @isdir==TRUE cd /d C:\bagit-4.9.0\bin\ & bag baginplace @path --payloadmanifestalgorithm sha1 --tagmanifestalgorithm sha1 --version 0.97 --verbose & move /-y @path Z:\archival_master_files\books\general_collection"
REM oh and then edit the files list to drop the "master" part
REM this find/replace code via https://social.technet.microsoft.com/Forums/scriptcenter/en-US/57bd676c-e5c3-4829-bdbf-6addea238bf0/find-and-replace-string-in-a-file-using-batch-script?forum=ITCG
@echo off
set "textfile=temp.txt"
set "newfile=filelist.txt"
set Scr="%temp%\TempVBS.vbs"
You can’t perform that action at this time.