Skip to content

Instantly share code, notes, and snippets.

@hectorcorrea
hectorcorrea / traject_config_xml.rb
Last active January 29, 2021 14:32
Basic example on how to process an XML file with Traject.
# ================================================================================
#
# NOTE: THIS IS NOT THE RECOMMENDED WAY TO PARSE MARC XML FILES WITH TRAJECT.
#
# See https://gist.github.com/hectorcorrea/78641f8d8e7b6cbbcb3dfd904116f7b0
# for an example on how to process MARC XML files.
#
# ALTHOUGH THIS CODE IS VALID AND WORKS FOR ANY XML FILE, THE RECOMMENDED
# WAY TO PARSE MARC XML FILES WITH TRAJECT IS WITH THE -t xml FLAG
# (INSTEAD OF -i xml).
@hectorcorrea
hectorcorrea / results.html
Created November 30, 2020 15:47
Sample results.html for SolrDora using hard-coded fields. Allows to easily set the display order.
{{ define "content" }}
<style>
em {
background: #e9e91966;
}
</style>
<div class="row">
<div class="col-md-4">
<form action="/search" method="GET">
<input type="text" id="q" name="q" value="{{ .Q }}" placeholder="enter text" autofocus/>
@hectorcorrea
hectorcorrea / one.html
Created November 17, 2020 16:48
Sample one.html for SolrDora using hard-coded fields. Allows to easily set the display order.
{{ define "content" }}
<style>
/* https://stackoverflow.com/a/22955585/446681 */
.input-group{
width: 100%;
}
.input-group-addon{
width: 15%;
text-align: left;
}
@hectorcorrea
hectorcorrea / install-yaz-marcdump.sh
Last active December 9, 2019 19:23
Installing yaz-marcdump on MacOS
# Building yaz-marcdump from source on MacOS.
#
# It's possible that you'll also need to run
#
# brew install libxml2
#
# if you don't have it already installed.
# Download source code
curl http://ftp.indexdata.com/pub/yaz/yaz-5.28.0.tar.gz > yaz-5.28.0.tar.gz
@hectorcorrea
hectorcorrea / passenger_report.rb
Last active September 4, 2018 13:41
Creates a tab delimited list from the passenger status log file.
# Parses a file with the output of `passenger-status` and outputs a
# tab delimited list with the date and number of requests in queue
# that `passenger-status` reported.
#
# The file `passenger_status.log` is created with via a cron job that
# runs every X minutes as follows:
#
# /path/to/.gem/gems/passenger-5.1.12/bin/passenger-status >> ./logs/passenger_status.log
#
#
@hectorcorrea
hectorcorrea / server.go
Last active October 10, 2017 17:00
An example on how to generate a local SSL certificate in Go and serve HTTPS traffic with it
// An example on how to generate a local SSL certificate in Go
// and serve HTTPS traffic with it.
//
// Code taken from the book Go Web Programming by Sau Sheong Chang
// https://github.com/sausheong/gwp
//
// Run with `--https` to serve traffic via HTTPS (it will create the certificate
// and private key files if they don't exist)
//
// Run with no parameters to serve traffic via HTTP (no certificates needed)
@hectorcorrea
hectorcorrea / solr.sh
Last active July 5, 2017 15:45
Solr shortcuts
# Delete one Solr document by ID
curl "http://localhost:8080/solr/blacklight-core/update?commit=true" \
-H "Content-Type: text/xml" \
--data-binary '<delete><id>xyz</id></delete>'
# Delete ALL Solr documents
curl "http://localhost:8080/solr/blacklight-core/update?commit=true" \
-H "Content-Type: text/xml" \
--data-binary '<delete><query>*:*</query></delete>'
@hectorcorrea
hectorcorrea / node_modules-in-git.md
Created January 19, 2017 16:34 — forked from sukima/node_modules-in-git.md
Archive of mikeal's post since his server went down today

node_modules in git

December 10 2011
By mikeal

One of the many things we have been forced to rethink in the world of node is how we handle dependencies in applications.

One of the big changes that came with 0.4.0 was support for node_modules. This change had major consequences. It elevated local modules, in a local directory, above modules installed globally. Along with npm changing its default install preference to local rather than global we've seen a nearly unanimous shift to local module installs that has made global installs somewhat distasteful.

@hectorcorrea
hectorcorrea / forever-initd-hectorcorrea.sh
Last active January 18, 2017 17:39
A sample init.d script to start a CoffeeScript application through forever. This used to be part of the source code of my hectorcorrea.com repo but since I have deleted the CoffeeScript code this script was lost. This gist is to preserve it for posterity since it is referenced in a StackOverflow question.
#!/bin/bash
#
# initd-example Node init.d
#
# chkconfig: 345
# description: Script to start a coffee script application through forever
# processname: forever/coffeescript/node
# pidfile: /var/run/forever-initd-hectorcorrea.pid
# logfile: /var/run/forever-initd-hectorcorrea.log
#