Skip to content

Instantly share code, notes, and snippets.

@totten
totten / LoggerInterface.php
Created November 20, 2012 19:59 — forked from Seldaek/LoggerInterface.php
LoggerInterface PSR Proposal (with fluent options)
<?php
namespace PSR\Log;
/**
* Describes a logger instance
*
* The $message MUST be a string.
* The $message MAY contain variable expressions like "%var%" which reference $data.
* The $message SHOULD NOT include runtime data using plain string concatenation.
@totten
totten / LoggerInterface.php
Created November 24, 2012 19:45 — forked from Seldaek/LoggerInterface.php
LoggerInterface PSR Proposal
<?php
namespace PSR\Log;
/**
* Describes a logger instance
*
* The $message MUST be a string.
* The $message MAY contain variable expressions like "%var%" which reference $data['var'].
* The "%var%" notation MUST NOT reference values of nested arrays (eg no "%parent.child%" notation).
@totten
totten / gist:5518406
Created May 4, 2013 19:05
Compare performance of checking for existence 10,000 times using (a) function_exists or (b) a data structure cached in DB
<?php
civicrm_initialize();
$a = microtime(TRUE);
function_exists('abc');
$b = microtime(TRUE);
@totten
totten / 1-current.txt
Created August 21, 2014 22:59
Pseudocode for demo rebuilds
foreach $demosite
mark $demosite offline
civibuild destroy $demosite
civibuild create $demosite
mark $demosite online
// Currently going to latest.civicrm.org/stable.php outputs:
4.5.2
// Proposed new output (B)
[
{version: "4.4.0"},
{version: "4.4.1"},
{version: "4.4.2", security: true}
{version: "4.5.0"},
{version: "4.5.1"},
diff --git a/Civi/API/Kernel.php b/Civi/API/Kernel.php
index 9d85508..85c5976 100644
--- a/Civi/API/Kernel.php
+++ b/Civi/API/Kernel.php
@@ -50,6 +50,12 @@ class Kernel {
protected $apiProviders;
/**
+ * @var array
+ * Stack of pending API requests.
@totten
totten / workflow.md
Created January 16, 2016 05:09
Page-oriented site customization workflow

Concepts:

  • Gum: A notation for diff'ing and merging HTML documents. (Normal line-oriented diffs are prone to gratuitious merge-conflicts when moving or reindenting code. Gum handles these changes explicitly, but it requires that every HTML node have a unique ID.)
  • Page: A broad HTML document that describes the major elements of the screen. A page is an amalgamation that merges together preferences from multiple sources (e.g. the original/upstream page, the local configuration, the active extensions). (Civi Examples: "View Contact", "Event Registration", "Contribution Page", "New Mailing".)
  • Component: A widget, input, or layout element that can be used within a page. Components look like special HTML tags or attributes. (Angular 1.x Directives, Angular 2.x Components, WebComponents, and Bootstrap CSS would all be examples.) (Civi Examples: "API Field", "Name block", "Billing block", "Emails block")
  • Well-formed page: A page with an open-ended vocabulary of tags, attributes, class
@totten
totten / resolve-all-files.php
Last active August 16, 2016 23:28
Test performance of file-lookups
<?php
// Locate all PHP files, one-by-one, using smarty_core_get_include_path().
// Display the total runtime.
// usage: cv scr resolve-all-files.php
// The number of times to fetch each file.
$trials = 100;
@totten
totten / notes.md
Last active February 16, 2021 14:27
An Opinionated Hierarchy of Unified Page Architectures (OHUPA)

An Opinionated Hierarchy of Unified Page Architectures (OHUPA)

OHUPA is a classification scheme for page/form/layout/composition-systems. The main concern of OHUPA is how much your ecosystem relies on you to provide clear, stable, high-quality components.

Table of Contents

  • Context
  • Level 0: Non-Componentized
  • Level 1: Component-Oriented; Component-Library
  • Level 2: Developer Customization (e.g Hook, Selector)
@totten
totten / 1-packages.txt
Last active July 17, 2017 19:55
Example listing of hard-coded references to key dirs
$ svngrep packages/ CRM/ api Civi templates/
CRM/Contact/Form/Search.php: ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
CRM/Contact/Form/Search.php: ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
CRM/Core/BAO/RecurringEntity.php:require_once 'packages/When/When.php';
CRM/Core/ClassLoader.php: $file = dirname(__FILE__) . '/../../packages/IDS/vendors/htmlpurifier/HTMLPurifier/Bootstrap.php';
CRM/Core/CodeGen/Util/Smarty.php: $smarty->plugins_dir = array("$base/packages/Smarty/plugins", "$base/CRM/Core/Smarty/plugins");
CRM/Core/IDS.php: filter_path = {$civicrm_root}/packages/IDS/default_filter.xml
CRM/Core/Resources.php: "packages/jquery/plugins/jquery.mousewheel.min.js",
CRM/Core/Resources.php: "packages/jquery/plugins/jquery.form.min.js",
CRM/Core/Resources.php: "packages/jquery/plugins/jquery.timeentry.min.js",