Skip to content

Instantly share code, notes, and snippets.

View slattery's full-sized avatar

Mike Slattery slattery

View GitHub Profile
@slattery
slattery / filefield_paths_fix_nothirdpartysettings.patch
Created August 8, 2022 23:32
filefield_paths_fix_nothirdpartysettings.patch
--- a/filefield_paths.module 2022-08-08 16:04:37.000000000 -0400
+++ b/filefield_paths.module 2022-08-08 19:23:33.000000000 -0400
@@ -212,11 +212,13 @@
// Force all File (Field) Paths uploads to go to the temporary file system
// prior to being processed.
if (isset($element['#type']) && $element['#type'] == 'managed_file') {
- $settings = $context['items']->getFieldDefinition()
- ->getThirdPartySettings('filefield_paths');
- if (isset($settings['enabled']) && $settings['enabled']) {
- $element['#upload_location'] = \Drupal::config('filefield_paths.settings')
@slattery
slattery / README.md
Created May 21, 2016 02:27 — forked from Neilos/README.md
Bi-directional hierarchical sankey diagram

This is a demonstration of a bi-directional hierarchical sankey diagram produced in javascript, html and css using d3. (Refresh page to generate new random data)

Sankey diagrams represent flows between nodes by varying the thickness of the connecting links.

This diagram was based off of Mike Bostock's sankey diagram, but additionally incorporates bi-directionality into the flow and caters for hierarchical relationships between nodes to allow drill down into the data.

All javascript code to generate the diagram markup is contained in the app.js file, but the underlying calculations are performed using a custom plugin: bihisankey.js.

@slattery
slattery / README.md
Created July 28, 2022 19:47
Enforces unique values for DOI in the drupal 9 bibcite module - very rough start!

Bibcite Unique Constraint DOI

Places a UniqueField constraint on the bibcite_doi field

v001

  • Implements hook_entity_base_field_info_alter() to add the constraint to the field
  • Implements hook_ENTITY_TYPE_presave() to insure validation is run during bulk imports

Dependencies

Needs the Bibliography & Citation module to work

@slattery
slattery / query-aws-logs-insights.bash
Created February 6, 2022 18:12 — forked from dsmrt/query-aws-logs-insights.bash
Using AWS CLI to query CloudWatch Logs with Insights. Looking -30 mins to now.
aws logs start-query \
--profile clientProfile \
--log-group-name MY-LOG_GROUP \
--start-time `date -v-30M "+%s"` \
--end-time `date "+%s"` \
--query-string 'fields @message | filter @message like /my query/'
@slattery
slattery / index.html
Created December 13, 2021 22:32
wee images
<html>
<table>
<tbody>
<tr>
<td><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdjuHDx2X8ACIMDh8l8Vc8AAAAASUVORK5CYII=" width="33" height="33"></td>
<td>6</td><td>#d0d1e6</td></tr>
<tr>
<td>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdjWLb39n8AB4kDPi2Q/CYAAAAASUVORK5CYII=" width="33" height="33"></td>
<td>5</td><td>#a6bddb</td></tr>
@slattery
slattery / honortreeData20201221.geojson
Last active December 22, 2020 03:55
Locations for Yale Employee Milestone Trees
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@slattery
slattery / README.md
Last active March 12, 2020 13:59
world map svgs from natural earth

Bash script to generate world map svgs, with a given grouping highlighted by color. Since this is for groupings and not detail, the script removes Antarctica, subs in French Guiana as a unit removed from France, and uses the map-units version of France.

We loop over uniques for properties: CONTINENT SUBREGION REGION_WB REGION_UN

GeoJSON sources via: natural-earth-vector

Clues and Facilities: Mike Bostock's command line cartography series. You'll need to install the nodejs packages including:

npm install -g d3-geo-projection
@slattery
slattery / README.md
Last active March 6, 2020 19:15
topojson landmasses from 50m natural earth source

Source: https://raw.githubusercontent.com/nvkelso/natural-earth-vector/master/geojson/ne_50m_admin_0_countries.geojson Clues: https://medium.com/@mbostock/command-line-cartography-part-2-c3a82c5c0f3 Example:

  ndjson-split 'd.features'  < ne_50m_admin_0_countries.geojson  \
  | ndjson-filter 'd.properties.SUBREGION == "South-Eastern Asia" || d.properties.SUBREGION == "Southern Asia" || d.properties.SUBREGION == "Northern Africa" || d.properties.REGION_WB == "Sub-Saharan Africa" || d.properties.REGION_WB == "Oceania" || d.properties.REGION_WB == "Latin America & Caribbean"' \
  | ndjson-filter 'd.properties = {ISO_A3: d.properties.ISO_A3, ISO_N3: d.properties.ISO_N3, REGION_UN: d.properties.REGION_UN, SUBREGION: d.properties.SUBREGION, NAME: d.properties.GEOUNIT, REGION_WB: d.properties.REGION_WB, CONTINENT: d.properties.CONTINENT }' \
  > ne50_studyarea.ndjson
  
@slattery
slattery / README.md
Created March 6, 2020 17:44
topojson countries from 50m natural earth source
@slattery
slattery / README.md
Last active March 6, 2020 17:30
topojson with regions, subregions, and countries from 50m natural earth source

Source: https://raw.githubusercontent.com/nvkelso/natural-earth-vector/master/geojson/ne_50m_admin_0_countries.geojson Clues: https://medium.com/@mbostock/command-line-cartography-part-2-c3a82c5c0f3 Commands:

ndjson-split 'd.features' \
 < ne_50m_admin_0_countries.geojson \
 | ndjson-filter 'd.properties.ISO_A3 !== "ATA"' \
 | ndjson-filter 'd.properties = {ISO_A3: d.properties.ISO_A3, ISO_N3: d.properties.ISO_N3, REGION_UN: d.properties.REGION_UN, SUBREGION: d.properties.SUBREGION, NAME: d.properties.GEOUNIT, REGION_WB: d.properties.REGION_WB, CONTINENT: d.properties.CONTINENT }' \
 | geo2topo -n countries=- \