Skip to content

Instantly share code, notes, and snippets.

View slattery's full-sized avatar

Mike Slattery slattery

View GitHub Profile
@slattery
slattery / ckeditor_link_styles_decorator_update_5_v29_1.patch
Created December 5, 2023 05:47
ckeditor_link_styles_decorator_update_5_v29_1.patch
@slattery
slattery / README.md
Created January 8, 2016 17:27 — forked from mwise/README.md
Git hook to prevent merging staging branch into master branch

To use this hook:

  • add the prepare-commit-msg file at .git/hooks/prepare-commit-msg and edit as needed
  • make it executable: chmod +x .git/hooks/prepare-commit-msg
  • disable fast-forward merges: git config branch.master.mergeoptions "--no-ff"
  • that's it!

NOTE: after a failed merge from a forbidden branch, the working tree will still be in a MERGING state. To discard the local working copy state, run: git reset --merge

@slattery
slattery / bibcite-ris-ris-entity-bibtex-20231103-01.patch
Last active November 14, 2023 14:28
bibcite-ris-ris-entity-bibtex-20231103-01.patch
diff --git a/modules/bibcite_bibtex/src/Encoder/BibtexEncoder.php b/modules/bibcite_bibtex/src/Encoder/BibtexEncoder.php
index a0ea233..e4f1307 100644
--- a/modules/bibcite_bibtex/src/Encoder/BibtexEncoder.php
+++ b/modules/bibcite_bibtex/src/Encoder/BibtexEncoder.php
@@ -22,14 +22,14 @@ class BibtexEncoder implements EncoderInterface, DecoderInterface {
/**
* {@inheritdoc}
*/
- public function supportsDecoding(string $format): bool {
+ public function supportsDecoding($format): bool {
@slattery
slattery / README.md
Last active November 7, 2023 17:39
compare two lando template dirs

Diff lando template dirs

Sometimes you want to know how two files in two sites differ.

Setup

Place the diffwith.sh file somewhere you can get at it, and either

  • chmod 755 path/to/diffwith.sh to make it executable
  • just know you'll type bash path/to/diffwith.sh name-of-comparedir each time, which is legit too.
@slattery
slattery / WOS_000926394000002.ris
Created November 3, 2023 22:30
Single RIS record with plus sign for EP
TY - JOUR
AU - Uribe, MD
AU - Coe, MT
AU - Castanho, ADA
AU - Macedo, MN
AU - Valle, D
AU - Brando, PM
TI - Net loss of biomass predicted for tropical biomes in a changing climate
T2 - NATURE CLIMATE CHANGE
AB - Tropical ecosystems store over half of the world's aboveground live carbon as biomass, and water availability plays a key role in its distribution. Although precipitation and temperature are shifting across the tropics, their effect on biomass and carbon storage remains uncertain. Here we use empirical relationships between climate and aboveground biomass content to show that the contraction of humid regions, and expansion of those with intense dry periods, results in substantial carbon loss from the neotropics. Under a low emission scenario (Representative Concentration Pathway 4.5) this could cause a net reduction of aboveground live carbon of -14.4-23.9 PgC (6.8-12%) from 1950-2100. Under a high emissions scenario (Representative Concentration Pathway 8.5) net carbon losses could double a
@slattery
slattery / bibcite-ris-encoder-nondigitfix-20231103-01.patch
Created November 3, 2023 22:24
bibcite-ris-encoder-nondigitfix-20231103-01.patch
diff --git a/modules/bibcite_ris/src/Encoder/RISEncoder.php b/modules/bibcite_ris/src/Encoder/RISEncoder.php
index 78cc087..f5af92d 100644
--- a/modules/bibcite_ris/src/Encoder/RISEncoder.php
+++ b/modules/bibcite_ris/src/Encoder/RISEncoder.php
@@ -60,7 +60,7 @@ class RISEncoder implements EncoderInterface, DecoderInterface {
$record['EP'] = (array) $record['EP'];
}
$max_sp = array_key_exists('SP', $record) ? max($record['SP']) : NULL;
- $max_ep = array_key_exists('EP', $record) ? max($record['EP']) : 0;
+ $max_ep = array_key_exists('EP', $record) && is_int($record['EP']) ? max($record['EP']) : 0;
@slattery
slattery / firstboot.sh.erb
Created December 16, 2015 14:19 — forked from mtak/firstboot.sh.erb
Generator for Debian preseed files
#!/bin/sh
# set hostname
echo <%= hostname %> > /etc/hostname
/etc/init.d/hostname.sh
# Set up networking
cat > /etc/network/interfaces << EOF
# The loopback network interface
auto lo
@slattery
slattery / .lando.local.yml
Created May 25, 2023 18:51
_lando.local.yml to defeat spinning scanners on macos M2
services:
appserver_nginx:
scanner:
okCodes:
- 302
- 404
edge:
scanner:
okCodes:
- 302
@slattery
slattery / drupal.md
Last active October 11, 2022 14:44 — forked from megclaypool/drupal.md
[I forgot my Password: Command Line Tools to the Rescue!] Note that these commands can also come in handy if your front-end is so messed up that you can't access the login screen...

Drush one-time login link for Drupal accounts

Holy crap, I never knew about this before, but this is awesome.

The command is drush uli

It's got options,

  • name for the username
  • uri to specify the url of the site (our weird setup requires us to specify the url of our site)
@slattery
slattery / mymodule--feature.js.js
Created August 12, 2022 19:11 — forked from edutrul/mymodule--feature.js.js
How to add javascript by using drupal 8 libraries using Drupalsettings(to pass php(backend) variables to js(frontend). This can be applied to files: ".theme", ".module"m "field formatter class", "views field handler", etc files. Also uses javascript drupal behaviours (great practice in D8) Plus contains "once" which only enables to execute one t…
// File js/mymodule--feature.js
(function ($) {
Drupal.behaviors.mymodule__feature = {
attach: function (context, drupalSettings) {
// Use once to avoid tu call multiple times a js.
$(document).once('feature').on('click', '.button--feature', (function (event) {
event.preventDefault();
if (typeof drupalSettings.mymodule.feature.id != 'undefined') {
console.log('Your great logic goes here and will NOT be called multiple times');
}