Skip to content

Instantly share code, notes, and snippets.

View michaellopez's full-sized avatar

Michael Zetterberg fd. Lopez michaellopez

View GitHub Profile
@michaellopez
michaellopez / swiftmailer-bad-missing-attachment-fix.patch
Created January 11, 2024 07:58
swiftmailer bad/missing attachment fix patch
diff --git a/src/Plugin/Mail/SwiftMailer.php b/src/Plugin/Mail/SwiftMailer.php
index e9830ac..4e0bcb9 100644
--- a/src/Plugin/Mail/SwiftMailer.php
+++ b/src/Plugin/Mail/SwiftMailer.php
@@ -479,7 +479,15 @@ class SwiftMailer implements MailInterface, ContainerFactoryPluginInterface {
$content = file_get_contents($image->uri);
}
else {
- $content = file_get_contents(\Drupal::service('file_system')->realpath($image->uri));
+ $image_path = \Drupal::service('file_system')->realpath($image->uri);
@michaellopez
michaellopez / README.md
Created December 3, 2020 12:43 — forked from pgib/README.md
Clean up the bloated Backblaze bzfileids.dat

Place in /Library/Backblaze.bzpkg/bzdata/bzbackup, and run with:

ruby purge_nonexistent.rb

It will process bzfileids.dat placing any file that exists in bzfileids.dat-found and any missing file in bzfileids.dat-missing. You can then back up your original file and replace it with bzfileids.dat-found.

My original file was almost 1.4GB. It had grown so large that the backup would cause all my fans spin and it never seemed to complete. Backblaze support suggested I delete my entire backup with them and start over. After running this script, my new bzfileids.dat file is 301MB. Still huge, but about 1/5th the size. The backup seemed to go much more smoothly.

@michaellopez
michaellopez / readme.md
Created December 3, 2020 12:43 — forked from nickcernis/readme.md
Exclude node_modules and .git from Backblaze backups on Mac

Exclude node_modules and .git from Backblaze backups on Mac

  1. Edit the file at /Library/Backblaze.bzpkg/bzdata/bzexcluderules_editable.xml.
  2. Add these rules inside the bzexclusions tag:
<!-- Exclude node_modules. -->
<excludefname_rule plat="mac" osVers="*"  ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/node_modules/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
<excludefname_rule plat="mac" osVers="*"  ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/.git/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
@michaellopez
michaellopez / readme.md
Created December 3, 2020 12:43 — forked from jb510/readme.md
Exclude vcs (git, svn, hg) and node_modules from Backblaze backups on Mac

Backblaze's bztransmit process loads a file called bzfileids.dat into RAM. This file is a list of all files Backblaze has previously uploaded, including a unique identifier for each file. On most systems, this files is under 100MB in size (paraphrased from Backblaze support rep Zack).

Mine had grown to 6GB. This means that anytime bztransmit runs, it will load this 6GB file into RAM while it is backing up. In doing so it was purging massive ammounts of memory causing behavior like Chrome (usign 10GB of memory on it's own) to hang/beachball for 30 seconds and then refresh all it's windows.

There is no way to alter this behavior once it's begun, aside from starting over with some files excluded. The index needs to be rebuilt from scratch without the excessibe file count, that also means you can't restart and "inherit" a previous backup.

In my case the biggest culprits were .git and node_modules, so I excluded those, started a new backup (transfered licnese) and spent a week hunting for fast internet I could

@michaellopez
michaellopez / output.sh
Last active October 25, 2019 15:09
now: yarn lint errors
$ yarn lint
yarn run v1.19.1
$ eslint . --ext .ts,.js
.../now/packages/now-build-utils/src/debug.ts
1:63 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
.../now/packages/now-build-utils/src/fs/glob.ts
48:30 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
49:23 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
@michaellopez
michaellopez / output.sh
Created October 25, 2019 15:08
now: yarn test error
$ yarn test
yarn run v1.19.1
error Command "test" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@michaellopez
michaellopez / readme.md
Created April 26, 2019 09:07 — forked from astoilkov/readme.md
Async Operations with useReducer Hook

Async Operations with useReducer Hook

We were discussing with @erusev what we can do with async operation when using useReducer() in our application. Our app is simple and we don't want to use a state management library. All our requirements are satisfied with using one root useReducer(). The problem we are facing and don't know how to solve is async operations.

In a discussion with Dan Abramov he recommends Solution 3 but points out that things are fresh with hooks and there could be better ways of handling the problem.

Problem

Doing asynchronous operations in a useReducer reducer is not possible. We have thought of three possible solutions and can't figure which one is better or if there is an even better solution.

@michaellopez
michaellopez / sparkpost-return_path.patch
Created January 22, 2019 04:05
Patch that adds return_path / envelope FROM to Sparkpost Drupal module
diff --git a/config/install/sparkpost.settings.yml b/config/install/sparkpost.settings.yml
index e014059..504215a 100644
--- a/config/install/sparkpost.settings.yml
+++ b/config/install/sparkpost.settings.yml
@@ -2,6 +2,7 @@ api_key:
debug: true
sender:
sender_name:
+return_path:
format: ''
diff --git a/field_collection.entity.inc b/field_collection.entity.inc
index 2e8a11b..ed8dfb7 100644
--- a/field_collection.entity.inc
+++ b/field_collection.entity.inc
@@ -291,24 +291,29 @@ class FieldCollectionItemEntity extends Entity {
protected function fetchHostDetails() {
if (!isset($this->hostEntityId)) {
if ($this->item_id) {
+ $in_use = $this->isInUse();
+
diff --git a/src/Patches.php b/src/Patches.php
index 70c5b83..ba01d6d 100644
--- a/src/Patches.php
+++ b/src/Patches.php
@@ -8,10 +8,14 @@
namespace cweagans\Composer;
use Composer\Composer;
+use Composer\DependencyResolver\DefaultPolicy;
+use Composer\DependencyResolver\Pool;