Skip to content

Instantly share code, notes, and snippets.

View smulvih2's full-sized avatar

Stephen Mulvihill smulvih2

View GitHub Profile
@smulvih2
smulvih2 / azure-pipelines.yml
Last active August 14, 2024 18:08
Example Azure pipeline file for drupalwxt/docker-scaffold appsvc image
# Starter pipeline for the drupalwxt/docker-scaffold appsvc image
trigger:
tags:
include:
- '*'
pr: none
# Use a generic Ubuntu pool provided by Azure DevOps
@smulvih2
smulvih2 / cli.sh
Created May 5, 2024 16:37
Use sed to remove LOCK TABLES from an SQL file
sed -E 's/^.*LOCK TABLES.*$//' before.sql > after.sql
@smulvih2
smulvih2 / gist:3977d611c2548f8bcbdbdea85bfc16cf
Created April 26, 2024 18:14
Function to get memory usage
// Function to calculate memory usage
function getMemoryUsage() {
$memory = memory_get_usage(true);
$units = array('B', 'KB', 'MB', 'GB', 'TB');
return @round($memory / pow(1024, ($i = floor(log($memory, 1024)))), 2) . ' ' . $units[$i];
}
@smulvih2
smulvih2 / ModuleHandler.php
Last active April 26, 2024 17:08
Drupal 10 - Get times for each hook call
// html/core/lib/Drupal/Core/Extension/ModuleHandler.php
/**
* {@inheritdoc}
*/
public function invokeAllWith(string $hook, callable $callback): void {
foreach (array_keys($this->getImplementationInfo($hook)) as $module) {
$hookInvoker = \Closure::fromCallable($module . '_' . $hook);
$before = microtime(true);
@smulvih2
smulvih2 / BatchService.php
Created July 25, 2023 19:40
Drupal 9/10 Default Content Deploy Batch Export
<?php
namespace Drupal\my_module;
/**
* Class BatchService.
*/
class BatchService {
/**
@smulvih2
smulvih2 / Credential helper commands
Last active July 28, 2023 15:51
Git credential helper
# Add credential helper
$ git config credential.helper store
# Remove credential helper
$ sudo git config credential.helper ''
diff --git a/webform_validation.info.yml b/webform_validation.info.yml
index 67266d3..3c978eb 100644
--- a/webform_validation.info.yml
+++ b/webform_validation.info.yml
@@ -3,7 +3,7 @@ description: 'Add validation rules to Webforms.'
package: 'Webform'
type: module
-core_version_requirement: ^9.4 || ^10
+core_version_requirement: ^9.2 || ^10
@smulvih2
smulvih2 / gist:25aa4f3dd06bc22ccbcc71d0e565fba9
Created August 5, 2022 14:42
Outout object to Drupal 9 DB log
\Drupal::logger('my_module')->notice('<pre><code>' . print_r($object, TRUE) . '</code></pre>' );
https://wet-boew.github.io/wet-boew-styleguide/design/proximity-en.html
0 = 0px
sm = 5px
md = 15px
lg = 30px
xl = 50px
Margin bottom
GCWeb and GCIntranet theme examples: https://ssl-templates.services.gc.ca/app/cls/wet/gcintranet/v4_0_39/cdts/appTop/apptop-en.shtml