Skip to content

Instantly share code, notes, and snippets.

@kspurgin
kspurgin / name_this_transform.md
Last active July 7, 2022 18:44
name_this_transform

Combines data from multiple fields following an expected naming pattern (shown in examples below) into final fields that are part of a repeatable fieldgroup.

As an example, let's use example source data:

{displayideas: 'blah', ideadate: '2022-07-07', creditline: 'from someone'}

We want data from :displayideas and :creditline to both get mapped to annotation note fields,

@kspurgin
kspurgin / cspace_api_kw_search.md
Last active January 31, 2022 23:44
CollectionSpace API Keyword Search testing

Keyword search (collectionobjects) for: tea

As expected, to show objects that exist.

1. objectNumber: tea platter
1. title:
2. objectNumber: Tea cup
2. title:
@kspurgin
kspurgin / conditional_default_field_value.adoc
Created June 23, 2021 18:58
Conditional default field value - use case/description

I have added a Boolean authorized field to my I8 taxonomy terms via a lyrasis_module_entity_base_field_info function in my custom module. Currently the default value of this field is FALSE.

Many (but not all) of my vocabularies also have a URI external_vocabulary_uri field.

What I would like to be able to do is:

  • if there is an external_vocabulary_uri field on my taxonomy term AND if there is a value in that field, the value of authorized field gets set to TRUE automatically

  • otherwise, value of authorized field remains FALSE unless a user sets it to TRUE. If this field value gets set to TRUE, it does not ever get "automagically" set back to FALSE, but may be changed back to FALSE manually by a user, or by explicit batch change, etc.

Note:

@kspurgin
kspurgin / opt_a_in_value_list.md
Last active April 30, 2021 19:51
Options for indicating deprecated relators in Agent field

In value list

Deprecated status and "see" term shown with term in pick-list

Screen Shot 2021-04-30 at 15 35 44

Pros

  • clear and hard for a person entering metadata to miss?

Cons

@kspurgin
kspurgin / typed_id_twig_html.adoc
Last active April 16, 2021 19:30
Exploring Twig templating output for Typed identifier Paragraph type

This is what I am getting. It really wants to style the Paragraph output like it’s an entity reference, since under the hood it literally is.

<!-- BEGIN OUTPUT from 'themes/contrib/at_theme/at_core/templates/field/field.html.twig' -->

<div data-quickedit-field-id="node/17/field_typed_identifier/en/full" class="field field-node--field-typed-identifier field-formatter-entity-reference-revisions-entity-view field-name-field-typed-identifier field-type-entity-reference-revisions field-label-above has-single"><h3 class="field__label">Identifier</h3><div class="field__items"><div class="field__item">

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'paragraph' -->
@kspurgin
kspurgin / fits_example.xml
Created October 19, 2020 17:42
A JPG fits example
<?xml version="1.0" encoding="UTF-8"?>
<fits xmlns="http://hul.harvard.edu/ois/xml/ns/fits/fits_output" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hul.harvard.edu/ois/xml/ns/fits/fits_output http://hul.harvard.edu/ois/xml/xsd/fits/fits_output.xsd" version="1.5.0" timestamp="9/24/20 8:56 PM">
<identification>
<identity format="JPEG File Interchange Format" mimetype="image/jpeg" toolname="FITS" toolversion="1.5.0">
<tool toolname="Droid" toolversion="6.4" />
<tool toolname="Jhove" toolversion="1.20.1" />
<tool toolname="NLNZ Metadata Extractor" toolversion="3.6GA" />
<version toolname="Droid" toolversion="6.4">1.01</version>
<externalIdentifier toolname="Droid" toolversion="6.4" type="puid">fmt/43</externalIdentifier>
</identity>
@kspurgin
kspurgin / csv_opt.txt
Created October 2, 2020 20:34
Exploring Ruby CSV standard library default handling of empty cell values
2.6.3 :001 > require 'csv'
=> true
2.6.3 :002 > csv = CSV.parse(File.read('required_field_empty.csv'), headers: true)
=> #<CSV::Table mode:col_or_row row_count:4>
2.6.3 :003 > rows = []
=> []
2.6.3 :004 > csv.each{ |r| rows << r.to_h }
=> #<CSV::Table mode:col_or_row row_count:4>
2.6.3 :024 > rows[1]['objectNumber']
=> nil
@kspurgin
kspurgin / hidden_ct_by_fieldgroup.txt
Created October 2, 2020 19:54
hidden field counts by fieldgroup
| field group | hidden field count |
|--------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------|
| anthro_4_1_0/citation/citationRecordTypes | 1 |
| anthro_4_1_0/citation/citationTermGroupList > citationTermGroup | 2 |
| anthro_4_1_0/collectionobject/ | 8 |
| anthro_4_1_0/collectionobject/anthroOwnershipGroupList > anthroOwnershipGroup
@kspurgin
kspurgin / csv_column_report
Created September 30, 2020 21:14
csv_column_splitting_headache
I use a little awk oneliner derived from https://www.datafix.com.au/cookbook/structure1.html
to verify the structure of client-supplied CSVs (that I convert to TSVs) or TSVs. One client's
table of object data provided as TSV used CRLF row endings, AND included TAB, CRLF, CR, and LF
characters inside individual fields to format multiline notes.
The result of my check on this ONE FILE was as follows:
292 rows are broken into 82 columns
606 rows are broken into 1 columns
486 rows are broken into 0 columns
@kspurgin
kspurgin / accessionDateGroup_field_config.json
Created May 4, 2020 20:56
accessionDateGroup field config
{ "accessionDateGroup": {
"[config]": {
"dataType": "DATA_TYPE_STRUCTURED_DATE",
"messages": {
"name": {
"id": "field.acquisitions_common.accessionDateGroup.name",
"defaultMessage": "Accession date"
}
},
"searchView": {