Skip to content

Instantly share code, notes, and snippets.

@yusufhm
yusufhm / test-output.php
Created January 28, 2020 22:50
phpunit screenshot & html output
<?php
file_put_contents('public://screenshot.jpg', $this->getSession()->getScreenshot());
file_put_contents('public://' . drupal_basename($this->getSession()->getCurrentUrl()) . '.html', $this->getCurrentPageContent());
@yusufhm
yusufhm / homebrew-passwordless-services.md
Last active September 23, 2019 05:33
Homebrew passwordless services start stop

Type sudo visudo -f /etc/sudoers.d/30-brew and enter the following content:

%admin ALL = (ALL) NOPASSWD: /usr/local/bin/brew
@yusufhm
yusufhm / get-list-of-file-dir-sizes.sh
Created August 28, 2019 04:52
List biggest files & directories
#/bin/bash
du -cks * | sort -rn | head
@yusufhm
yusufhm / set-config.sh
Last active August 2, 2019 05:43
Set config via drush
# Get the config as yaml first.
drush config:get search_api.index.acquia_search_index datasource_settings.entity:node.bundles.selected > config-overrides.yml
# Make modifications to config-overrides.yml.
cat config-overrides.yml | drush config:set search_api.index.acquia_search_index datasource_settings.entity:node.bundles.selected - --input-format=yaml
@yusufhm
yusufhm / wp-commands.sh
Last active September 10, 2020 00:13
wp-cli commands
#!/usr/bin/env bash
# Create an admin user.
wp user create username user@example.com --role=administrator
# Reset user password.
wp user update user --user_pass=password --skip-email
# Create a database backup.
wp db export - | gzip -9 > db.sql.gz
@yusufhm
yusufhm / drupal-testing.sh
Last active September 25, 2019 01:41
drupal testing
# PHPUnit testing.
# Set `BROWSERTEST_OUTPUT_DIRECTORY` so we get the browser output.
(export BROWSERTEST_OUTPUT_DIRECTORY=$(pwd)/docroot/sites/simpletest/browser_output; blt tests:phpunit:run -vvv)
# Behat testing.
(export BUILDKITE_BUILD_CHECKOUT_PATH=$(pwd); blt tests:behat:run --environment=ci --no-interaction --yes --ansi --define drush.alias='${drush.aliases.ci}')
@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 / wordpress-url-update.sql
Created January 17, 2019 03:11
wordpress update site for localhost
UPDATE ixs_options
SET option_value = 'http://localhost:8080'
WHERE option_name = 'home';
UPDATE ixs_options
SET option_value = 'http://localhost:8080'
WHERE option_name = 'siteurl';
UPDATE ixs_posts
SET post_content = REPLACE(post_content,'http://old.url','http://localhost:8080');
@yusufhm
yusufhm / lambda-last-commit.py
Created August 30, 2018 02:03
Get the last commit of a Lambda function in Python
#!/usr/bin/env python
import sys
import boto3
import os
def get_lambda_last_commit(arn):
"""Get the commit hash of the last lambda push.
Keyword arguments:
@yusufhm
yusufhm / visually-hidden.css
Created April 12, 2018 05:30
CSS Visually Hidden
#logo a {
position: absolute !important;
height: 1px;
width: 1px;
overflow: hidden;
clip: rect(1px, 1px, 1px, 1px);
}