Skip to content

Instantly share code, notes, and snippets.

View ginkgomzd's full-sized avatar

Michael Z Daryabeygi ginkgomzd

View GitHub Profile
@ginkgomzd
ginkgomzd / locate-civi-log
Last active October 4, 2017 20:20
Locate ConfigAndLog Latest
#! /usr/bin/env bash
# Finds the last modified CiviCRM ConfigAndLog file.
# Configure the ConfigAndLog dir in $LOG_DIR
#
# TIP: create a symlink to ConfigAndLog as a sibling of your project utils folder
# called logs, and you can use the default configs below.
pushd $(dirname $0) >/dev/null
__DIR__=$(pwd -P)
SITE=sandbox-volunteer.leadercenter.org
HTDOCS=/home/leaderce/websites/$SITE/htdocs
DRUSH=/usr/local/bin/drush
pushd $HTDOCS > /dev/null
while read line ; do
read contact_id
$DRUSH cvapi --out=pretty \
@ginkgomzd
ginkgomzd / archive_rotate
Last active July 14, 2017 17:33
Rotate Snapshots
#!/bin/sh
CP='cp -rp'
RM='rm -rf'
MAX=7 # keep MAX + 1 archives
SRC=$1
MY_BU=$2
# if second arg is not set, don't change bu name
$participants = civicrm_api3('Participant', 'get', array(
'sequential' => 1,
'status_id' => "Registered",
'event_id' => array(
'IN' => $event_ids
),
// Get price set info if available in line below
'api.LineItem.get' => array('entity_table' => "civicrm_participant", 'entity_id' => "\$value.participant_id")
)) ['values'];
-- Find suspect Memberships due to contributions being linked to multiple membership-payment records
SELECT
mempay.id AS mempay_id,
mempay.contribution_id AS contrib_id,
contrib.receive_date, contrib.total_amount,
mempay.membership_id AS mem_id, memtype.name,
c_contrib.display_name AS contrib_contact_name, c_contrib.id AS contrib_contact_id,
c_mem.id AS mem_contact_id, c_mem.display_name AS mem_contact_name
@ginkgomzd
ginkgomzd / cron-build-caches.php
Created September 30, 2016 21:40
a cron job to build a month's worth of daily API requests
<?php
// MZD's JANKY CACHE
define('VKA_API_CACHE_DIR', '/home/vegeta85/public_html/sites/default/files/api-cache');
$types = array('recipes', 'days', 'images','test');
for ($d=1;$d < 32; $d++) {
$lastMonths = genFileNamesForDate($d, 'last');
if ($lastMonths === FALSE) continue;
@ginkgomzd
ginkgomzd / .htaccess-partial
Last active September 30, 2016 21:31
an htaccess cache router that works with drupal
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^ - [E=vka_api_cache:sites/default/files/api-cache]
# Enable back-door and skip the rewriting
# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php
index 54962f9..205cb0b 100644
--- a/CRM/ACL/BAO/ACL.php
+++ b/CRM/ACL/BAO/ACL.php
@@ -723,14 +723,54 @@ SELECT count( a.id )
}
/**
+ * Build a join and where part for a query
+ *
@ginkgomzd
ginkgomzd / extract-field-mapping-by-id.php
Created December 8, 2015 21:27
Export CiviCRM Field mapping
#!/usr/bin/php
<?php
$usage = "Given the ID of a field mapping (e.g., for imports), returns the SQL "
. "required to import the mapping into another system. The output *should* be pipeable "
. "to mysql (not tested).\n\nExample: " . basename($argv[0]) . " <id>";
// TODO: if we did this as a drush script we could leave out all the DB stuff
// CONFIG //
$db_host = 'localhost';
$db_name = 'test_drupal7_civicrm';
@ginkgomzd
ginkgomzd / before_build_hook.js
Created September 16, 2015 19:35
Why does gradle do that? - stop appending digit to version code.
#!/usr/bin/env node
// this plugin replaces arbitrary text in arbitrary files
// remove strange appending of integer zero to versionCode
var fs = require('fs');
var path = require('path');
var rootdir = process.argv[2];
var platform = process.env.CORDOVA_PLATFORMS;