Skip to content

Instantly share code, notes, and snippets.


Yusuf Hasan Miyan yusufhm

View GitHub Profile
yusufhm / drupal-entity-updates.php
Last active Oct 2, 2020
Drupal entity updates
View drupal-entity-updates.php
* Update an entity type's storage definition.
* An example is when the cardinality of a field is updated in config; since
* `drush updatedb` no longer performs entity updates, this has to be done
* manually now.
function _MODULE_NAME_update_field_definition($entity_type_id, $field_name) {
yusufhm / backup-bucket.json
Created May 20, 2020
s3 bucket policy for uploads
View backup-bucket.json
"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Action": [
"Resource": "arn:aws:s3:::*"

Keybase proof

I hereby claim:

  • I am yusufhm on github.
  • I am yusufhm ( on keybase.
  • I have a public key ASApjd3pUzWFOGkOKWHV1Q34v6hxiWFba7sCKt1lBegO0wo

To claim this, I am signing this object:

yusufhm / drupal-di-setter-pattern.php
Last active Apr 9, 2020
drupal dependency inject setter pattern
View drupal-di-setter-pattern.php
public static function create(...) {
/* @see */
/* @see */
$instance = parent::create(...);
yusufhm / test-output.php
Created Jan 28, 2020
phpunit screenshot & html output
View test-output.php
file_put_contents('public://screenshot.jpg', $this->getSession()->getScreenshot());
file_put_contents('public://' . drupal_basename($this->getSession()->getCurrentUrl()) . '.html', $this->getCurrentPageContent());
yusufhm /
Last active Sep 23, 2019
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 /
Created Aug 28, 2019
List biggest files & directories
du -cks * | sort -rn | head
yusufhm /
Last active Aug 2, 2019
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 /
Last active Sep 10, 2020
wp-cli commands
#!/usr/bin/env bash
# Create an admin user.
wp user create username --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
# 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='${}')
You can’t perform that action at this time.