Skip to content

Instantly share code, notes, and snippets.

@yusufhm
yusufhm / kube-commands.sh
Last active Nov 9, 2022
kube commands - kubernetes | kubectl | lagoon
View kube-commands.sh
# 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 Sep 28, 2022
podman setup
View .envrc
# Allows for builds using `docker-compose build`.
export COMPOSE_DOCKER_CLI_BUILD=0
View drush_commands.sh
# 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 Feb 14, 2017
drupal 8 import config programmatically
View d8_import_config.php
<?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'));
View composer-local-directory-package.md

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 Mar 1, 2022
redis commands
View redis.sh
# Get info.
redis-cli INFO
# DB size.
redis-cli DBSIZE
# Get real-time stats.
redis-cli --stat
# Monitor.
View bash_commands.sh
#!/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
View gitlab-commands.md

Set env variables in Gitlab when pushing:

git push origin feature/ci-test  -o ci.variable="GOVCMS_CI_IMAGE_VERSION=:edge"
View dev-tools.md

Environment per project/directory

@yusufhm
yusufhm / drupal.yml
Created Feb 28, 2021
caprover app for Drupal
View drupal.yml
captainVersion: 4
services:
$$cap_appname-db:
image: bitnami/$$cap_db_type:$$cap_database_version
volumes:
- $$cap_appname-db-data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: $$cap_db_pass
MYSQL_DATABASE: drupal