Skip to content

Instantly share code, notes, and snippets.

@ptmkenny
ptmkenny / README.md
Last active September 22, 2020 19:22
Hosting Drulma depenencies locally + minimizing CSS/JS

How to host all drulma dependencies locally + minimize the CSS/JS

The steps in this guide enabled me to avoid using any CDNs and shrink my bulma CSS to just 19 KB. It also shrinks BulmaJS from 100+ Kb to ~20 Kb with a custom fork of BulmaJS that only builds the navbar, file, and dropdown components.

First, we have to create a subtheme of drulma.

Next, we override the drulma libraries.

Add the following lines to mydrulmasubtheme.info.yml:

@ptmkenny
ptmkenny / README.md
Last active February 23, 2021 08:16
patch league/oauth2-server to allow the permissions check on pantheon

How to set up simple OAuth / OAuth 2.0 on Pantheon

According to the docs (https://pantheon.io/docs/modules-known-issues#simple-oauth--oauth-20), because it is not possible to change file permissions on Pantheon, even in the private directory, you can't use the Oauth module out of the box.

How to fix this

  1. Create the keys and put them in your Pantheon private files directory (for example, /files/private/oauth/public.key, needs permission 770) or commit them to git outside the web root (needs permission 644).
@ptmkenny
ptmkenny / feeds-drush_import_by_machine_name.patch
Created August 7, 2022 15:57
Patch Drupal Feeds module 3.x to allow drush to use machine name import in addition to EID
diff --git a/src/Commands/FeedsDrushCommands.php b/src/Commands/FeedsDrushCommands.php
index bab6a1c5..3affe55f 100644
--- a/src/Commands/FeedsDrushCommands.php
+++ b/src/Commands/FeedsDrushCommands.php
@@ -408,7 +408,7 @@ class FeedsDrushCommands extends DrushCommands {
/**
* Get the feed entity by ID.
*
- * @param int $fid
+ * @param int|string $fid
@ptmkenny
ptmkenny / setThemeTextSize.ts
Created August 19, 2022 04:09
Variable font size in Ionic react
const setThemeTextSize = (newTextSize: string): void => {
const root = document.querySelector(':root') as HTMLElement;
if (root) {
root.style.setProperty('--app-text-size-base', `${newTextSize}px`);
}
};
export default setThemeTextSize;
@ptmkenny
ptmkenny / ddevoutput.txt
Created December 12, 2022 20:58
ddev debug test MBP M1Pro 2022-12-13
ddev debug test
Running bash [-c /var/folders/n_/4z8jyx457vx4sy3xm7080rs00000gq/T/test_ddev.sh]
OS Information: Darwin 16.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64
ProductName: macOS
ProductVersion: 13.0.1
BuildVersion: 22A400
User information: uid=503(private) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),701(com.apple.sharepoint.group.1),33(_appstore),100(_lpoperator),204(_developer),250(_analyticsusers),395(com.apple.access_ftp),398(com.apple.access_screensharing),399(com.apple.access_ssh),400(com.apple.access_remote_ae),703(com.apple.sharepoint.group.3),702(com.apple.sharepoint.group.2)
DDEV version: ITEM VALUE
DDEV version v1.21.3
architecture arm64
@ptmkenny
ptmkenny / composer.json
Created December 12, 2022 21:02
platformsh composer config that does not work with ddev
{
"name": "ptmkenny/abc",
"type": "project",
"license": "MIT",
"require": {
"php": ">=8.1",
"ext-curl": "*",
"ext-fileinfo": "*",
"ext-json": "*",
"ext-sodium":"*",
@ptmkenny
ptmkenny / gist:32405d348b35f6d491c4ef74e1a9b3bc
Created December 14, 2022 00:46
ddev debug test 20221214
Running bash [-c /var/folders/n_/4z8jyx457vx4sy3xm7080rs00000gq/T/test_ddev.sh]
OS Information: Darwin 16.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64
ProductName: macOS
ProductVersion: 13.0.1
BuildVersion: 22A400
User information: uid=503(private) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),701(com.apple.sharepoint.group.1),33(_appstore),100(_lpoperator),204(_developer),250(_analyticsusers),395(com.apple.access_ftp),398(com.apple.access_screensharing),399(com.apple.access_ssh),400(com.apple.access_remote_ae),703(com.apple.sharepoint.group.3),702(com.apple.sharepoint.group.2)
DDEV version: ITEM VALUE
DDEV version v1.21.3
architecture arm64
db drud/ddev-dbserver-mariadb-10.4:v1.21.3
@ptmkenny
ptmkenny / MediaFeedsEmbed.php
Created January 18, 2023 10:50
Drupal 10 filter plugin (mymodule/src/Plugin/Filter) for importing media by Feeds GUID
<?php
namespace Drupal\my_module\Plugin\Filter;
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
use Drupal\Core\Security\TrustedCallbackInterface;
use Drupal\filter\FilterProcessResult;
use Drupal\media\MediaInterface;
use Drupal\media\Plugin\Filter\MediaEmbed;