Skip to content

Instantly share code, notes, and snippets.

@yusufhm
yusufhm / backup-bucket.json
Created May 20, 2020 04:44
s3 bucket policy for uploads
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListMultipartUploadParts"
],
"Resource": "arn:aws:s3:::*"
},

Keybase proof

I hereby claim:

  • I am yusufhm on github.
  • I am yusufhm (https://keybase.io/yusufhm) on keybase.
  • I have a public key ASApjd3pUzWFOGkOKWHV1Q34v6hxiWFba7sCKt1lBegO0wo

To claim this, I am signing this object:

@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');