Skip to content

Instantly share code, notes, and snippets.

@yusufhm
yusufhm / bash_commands.sh
Last active December 20, 2021 00:15
Bash Commands
#!/usr/bin/env bash
# split strings
GIT_BRANCH="origin/master"
remote=`echo $GIT_BRANCH | cut -d '/' -f 1`
branch=`echo $GIT_BRANCH | cut -d '/' -f 2`
# finding working directory of a process (where $$ is the PID, obtained through `pgrep` or other)
pwdx $$
# or
@yusufhm
yusufhm / dev-tools.md
Last active April 19, 2021 02:27
Dev tools

Environment per project/directory

@yusufhm
yusufhm / anonymous_author.html
Last active January 15, 2021 04:30
drupal.org module descriptions
<h3>Overview</h3>
Easily allow anonymous users to post content to your website by adding this field to any entity type. The most typical use-case of this module and the reason why it was initially created is for allowing the creation of forums by unauthenticated users, while requesting their name and email address, and whether they'd like to get notified.
<h3>Features</h3>
<ul>
<li>
Provides an Anonymous Author field type, containing the following values:
<ul>
<li>Name</li>
<li>Email</li>
@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 / db_backup.sh
Last active June 20, 2020 02:12
Bash scripts to backup databases & files for Drupal sites. Adapted from scripts originally written by Joseph Chin.
#!/usr/bin/env bash
WEBSITES_ROOT=/var/www
BACKUP_ROOT=/var/backups/websites
# Checks to see if arguments are provided
if [ $2 ]
then
BUCKET=$2
else
@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 / 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 / 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