Skip to content

Instantly share code, notes, and snippets.

View ginkgomzd's full-sized avatar

Michael Z Daryabeygi ginkgomzd

View GitHub Profile
@ginkgomzd
ginkgomzd / safe-unlink-file.mk
Created May 23, 2022 14:37
Gnu Make Safe rm File
@ginkgomzd
ginkgomzd / decomposer.mk
Last active December 14, 2021 15:58
Makefile to wrap docker-compose commands
-include service/${TASK}.conf
ifdef STACK
STACK := $(strip ${STACK})
STACK_NAME := $(shell echo "${STACK}" | tr A-Z a-z)
STACK_ID := $(shell echo "${STACK}" | tr a-z A-Z)
include stack/${STACK_NAME}.conf
endif
ifdef ${STACK_ID}_STACK
@ginkgomzd
ginkgomzd / helper.sh
Last active August 16, 2021 17:56
SSH Proxy Tunnel Example
# bring up the ssh tunnel without requiring leaving a terminal open
# by opening a connection without a shell with the -N option.
# nohup helps to keep open the connection.
# provide an optional log, which might help troubleshooting.
# combine stderr and stdout( 2>&1 )
# send to background ( & )
connect() {
nohup ssh tunnel -N > ~/.tunnel.log 2>&1 &
}
@ginkgomzd
ginkgomzd / split-diffs.awk
Last active March 4, 2021 20:53
Compare two directories and generate separate patch files and a list of unique files.
BEGIN {
patch_file = "ERR" # initialize
patches = "patches" # dir to output patches
if (ENVIRON["PATCH_DIR"]) {
patches = ENVIRON["PATCH_DIR"]
}
system("test -d " patches " || mkdir -p " patches)
}
@ginkgomzd
ginkgomzd / mv-tags.awk
Created February 9, 2021 20:11
Rename tags matching a pattern
# # #
#
# CHANGE RELEASE TAG SCHEME
#
# re-name tags to remove the civicrm release version
# set env DEBUG=1 to preview the changes
#
# USAGE
#
@ginkgomzd
ginkgomzd / Makefile
Last active March 13, 2020 20:55
Makefile to on-board WP Engine sites for administration: set admin email and upgrade plugins, etc...
# # #
# Looks for ${PROJ_ROOT}conf/ssh_config.
# Export PROJ_ROOT or SSH_CONFIG
#
# Minimal orchestration through filtering of HOST_LIST
# by a prefix/suffix in ssh Host aliases specified in ENV.
# Defaults to 'stage'
#
# Targets with 'all-' prefix execute commands against all
@ginkgomzd
ginkgomzd / alias_gitsubs.sh
Created November 12, 2019 23:56
bash function (such as you might put in .bash_aliases) to perform git commands on nested repos
#!/bin/bash
gitsubs() {
gitsubs_max_depth=12
echo searching for git repos
echo directory max-depth = $gitsubs_max_depth
echo executing git $@
( # use a subshell and change the field-separator
# to allow for spaces in filenames
@ginkgomzd
ginkgomzd / Makefile
Last active November 13, 2019 00:03
create website snapshot (gnu make)
PROJ_ROOT = /var/www/#
WEB_ROOT = ${PROJ_ROOT}html/#
ARCH_DIR = ${PROJ_ROOT}util/#
TAR_EXCLUDES = templates_c ConfigAndLog private/backup_migrate naloxone-training files/civicrm/custom default/files/civicrm/upload
all snapshot: clean html.tgz members.sql.gz
define tar-exclude-list
$(foreach excl,$1,--exclude=${excl} )
endef
@ginkgomzd
ginkgomzd / list-custom-msg-tpl.sql
Created September 4, 2019 13:36
List Modified System Workflow Msg Templates
SELECT
og.name,
ov.id, ov.name, ov.label
FROM
civicrm_msg_template tpl
INNER JOIN
civicrm_msg_template r -- reserved tpls
ON r.is_reserved = 1 AND r.is_default = 0
AND tpl.is_default = 1 AND tpl.is_reserved = 0
AND r.workflow_id = tpl.workflow_id
@ginkgomzd
ginkgomzd / gist:76f5d986377a685f9d6d54161c9d4f8f
Created July 8, 2019 14:34
sample bootsrap civi in drupal module
<?php
// Returns rendered markup for the hunger organization profile page
function nyccah_hunger_organization_render($hunger_organization_id) {
if(!is_numeric($hunger_organization_id)) {
drupal_access_denied();
return;
}
civicrm_initialize();