Skip to content

Instantly share code, notes, and snippets.

View DieterHolvoet's full-sized avatar

Dieter Holvoet DieterHolvoet

View GitHub Profile
@DieterHolvoet
DieterHolvoet / xdebug-mode.sh
Last active May 10, 2023 08:55
Get or set the xdebug.mode option for the current project's PHP version.
#!/usr/bin/env bash
# This function requires:
# - GNU sed (brew install gnu-sed)
# - Homebrew-managed PHP versions (e.g. brew install php@8.0)
# - The project_php_version function (https://gist.github.com/DieterHolvoet/49e1677e3ba0a7fd813fbbd92a7df70d)
function xdebug_mode() {
if [[ "$1" == "-h" ]]; then
echo "Get or set the xdebug.mode option for the current project's PHP version. Call without argument to get the current value, call with an argument to change it."
@DieterHolvoet
DieterHolvoet / LightweightQueueRunnerCommands.php
Last active October 9, 2023 10:39
Lightweight Drupal queue processor using Drush and systems
<?php
namespace Drush\Commands;
use Drupal\Core\Database\Database;
use Drupal\Core\Queue\DelayableQueueInterface;
use Drupal\Core\Queue\DelayedRequeueException;
use Drupal\Core\Queue\RequeueException;
use Drupal\Core\Queue\SuspendQueueException;
use Drush\Drush;
@DieterHolvoet
DieterHolvoet / php-valet-provision.sh
Last active April 13, 2022 21:14
Bash scripts for automatic PHP installation, configuration and version switching with Laravel Valet
#!/usr/bin/env bash
# Run php_install_valet once to set up your environment.
# This can be used in combination with https://gist.github.com/DieterHolvoet/49e1677e3ba0a7fd813fbbd92a7df70d:
# function switch_php_version() {
# switch_php_version_valet $1
# }
# These functions require GNU sed:
@DieterHolvoet
DieterHolvoet / php-switch-version.sh
Last active March 21, 2023 11:03
Automatically switch the active PHP version based on composer.json
# The jq command is required to run this script. Install using 'brew install jq'
# Add the following script yourself, choosing the switching method that works for you:
# function switch_php_version() {
# # switch_php_version_brew $1
# # switch_php_version_cli_brew $1
# # switch_php_version_cli_mamp $1
# }
# If you're using zsh, include this to automatically switch on cd:
@DieterHolvoet
DieterHolvoet / composer2-compat.sh
Last active January 17, 2024 13:50
Install Composer 2 and automatically switch to the right version depending on the project
#!/usr/bin/env bash
# Include this in your shell configuration file (.bashrc, .bash_profile, .zshrc, ...)
# The jq command is required to run this script. Install using 'brew install jq'
if ! type "composer" > /dev/null; then
brew install composer
fi
mkdir -p /usr/local/bin/
@DieterHolvoet
DieterHolvoet / reset_mysql_password.md
Created March 13, 2017 14:51
Reset the root password of a MySQL server
  1. sudo nano /etc/mysql/my.cnf
  2. Add the following lines at the end: [mysqld] skip-grant-tables
  3. sudo service mysql restart
  4. mysql -u root
  5. UPDATE mysql.user set authentication_string = PASSWORD('your_new_password') where user = 'root' and host = 'localhost';
  6. exit
  7. Remove the lines added in step 2 if you want to keep your security standards.
@DieterHolvoet
DieterHolvoet / ESDocumentGetFileExtension.js
Created March 27, 2016 16:52
A series of Document prototype functions for Adobe Extendscript
/* Get file extension of document */
Document.prototype.getFileExtension = function() {
var str = this.fullName.fsName;
return str.substring(str.lastIndexOf(".") + 1);
};
@DieterHolvoet
DieterHolvoet / ESFileAsDocument.js
Last active March 27, 2016 16:50
A series of File prototype functions for Adobe ExtendScript
/* Return the corresponding Document object of a given File object, and open the file if necessary. */
File.prototype.asDocument = function() {
var document = false;
for(var i = 0; i < app.documents.length; i++) {
if(app.documents[i].getFullPath() === this.getFullPath()) {
$.writeln("Found at index " + i + " => " + this.getFullPath());
document = app.documents[i];
break;
}