Skip to content

Instantly share code, notes, and snippets.

@yusufhm
yusufhm / README.md
Last active February 25, 2024 20:34
Drupal - Remove db entries for missing files

Drupal - Remove DB entries for missing temporary files

This script aims to address the error that often appear when running Drupal cron jobs, for temporary files that have an entry in the database but not actually existing in the file system:

[error]  Could not delete temporary file "public://example_file.pdf" during garbage collection

It can be run to get a count of the files:

drush scr /path/to/remove-missing-files.php
@yusufhm
yusufhm / requirements.txt
Created January 16, 2024 08:19
Migrate Wallabag entries to Nextcloud bookmarks
requests
@yusufhm
yusufhm / replace-apt-mirror.md
Last active October 18, 2023 15:03
replace default apt with au mirror using Vim or sed
@yusufhm
yusufhm / message
Created April 3, 2023 04:07
signed message for keys.pub
BEGIN MESSAGE.
lKvHUyNxgsGdfax uVtOtl6uvD204gN IEvxV8rQFk38YHH 0kdJOnTrnyY9DW3
NwHFi2fp9lkfgA7 sY2DQQYjfj3TCKq 6Xr2MZHgg4izyZ4 ETcON0Q40PLebmO
aE8v6UEexRqTVLn jx8MzdrzPY0e05G HI9x8CxD6Ru0c9o Zj7Rlj9CfsqIPRJ
mOUD88TeK5ZfBl4 jgdTVnqUwjXRM2M qBpnG2IP.
END MESSAGE.
@yusufhm
yusufhm / kube-commands.sh
Last active November 9, 2022 05:22
kube commands - kubernetes | kubectl | lagoon
# Tail logs of running build of a Lagoon project's environment.
kubectl -n env-ns logs -f --selector=lagoon.sh/jobType=build
# Run a busybox image.
kubectl run -i -t busybox --image=busybox --restart=Never
# Run a curl image.
kubectl run curl --image=curlimages/curl --restart=Never -- https://google.com
@yusufhm
yusufhm / .envrc
Last active September 28, 2022 05:47
podman setup
# Allows for builds using `docker-compose build`.
export COMPOSE_DOCKER_CLI_BUILD=0
@yusufhm
yusufhm / drush_commands.sh
Last active September 15, 2022 07:31
Drush commands
# THESE COMMANDS HAVE TO BE RUN FROM INSIDE AN EXISTING DOCROOT
# Get docroot path
drush st root --no-field-labels --format=list
# Generate Drupal Hash - Drupal 8
drush php:eval '$hash = Drupal\Component\Utility\Crypt::randomBytesBase64(55); print $hash . "\n";'
# Generate Drupal Hash - Drupal 7
drush php:eval '$hash = drupal_random_key(); print $hash . "\n";'
@yusufhm
yusufhm / d8_import_config.php
Created February 14, 2017 04:12
drupal 8 import config programmatically
<?php
// The following snippet updates the filter format configuration.
$config_path = drupal_get_path('module', 'my_custom_module') . '/config/install'; // or any path containing config files theoretically.
$source = new FileStorage($config_path);
$config_storage = \Drupal::service('config.storage');
$config_storage->write('filter.format.basic_html', $source->read('filter.format.basic_html'));
@yusufhm
yusufhm / composer-local-directory-package.md
Created March 28, 2022 06:48
composer use local directory

Add the following snippet to ~/.composer/config.json:

{
  "repositories": [
        {
            "type": "path",
            "url": "/path/to/package",
            "options": {
                "versions": {
 "owner/repo": "3.1.10"
@yusufhm
yusufhm / redis.sh
Last active March 1, 2022 06:14
redis commands
# Get info.
redis-cli INFO
# DB size.
redis-cli DBSIZE
# Get real-time stats.
redis-cli --stat
# Monitor.