Skip to content

Instantly share code, notes, and snippets.

@brandonkelly
brandonkelly / templating.md
Last active February 7, 2024 15:20
Templating in EE vs. Craft
@brandonkelly
brandonkelly / keybase.md
Created January 18, 2022 13:06
keybase.md

Keybase proof

I hereby claim:

  • I am brandonkelly on github.
  • I am brandonkelly (https://keybase.io/brandonkelly) on keybase.
  • I have a public key ASBSTBHBxc0E6qGHlzL0iNPFzO-j9rWbFHyjoGuYIxhbygo

To claim this, I am signing this object:

@brandonkelly
brandonkelly / LogTarget.php
Last active January 15, 2021 14:39
How to capture DB query logs in Yii2
<?php
namespace foo\bar;
use yii\log\Target;
/**
* Define a LogTarget class that only collects the log messages, but never flushes them out anywhere
*/
class LogTarget extends Target
{
@brandonkelly
brandonkelly / gist:1051722
Created June 28, 2011 17:56
Assets.Sheet usage
// -------------------------------------------
// Include the Sheet resources in PHP
// -------------------------------------------
if (! class_exists('Assets_helper'))
{
require PATH_THIRD.'assets/helper.php';
}
$assets_helper = new Assets_helper;
@brandonkelly
brandonkelly / gist:1671737
Created January 24, 2012 18:27
Cross-compatible get_upload_preferences() for EE 2.0 thru 2.4
<?php
/**
* Get Upload Preferences (Cross-compatible between ExpressionEngine 2.0 and 2.4)
* @param int $group_id Member group ID specified when returning allowed upload directories only for that member group
* @param int $id Specific ID of upload destination to return
* @return array Result array of DB object, possibly merged with custom file upload settings (if on EE 2.4+)
*/
function get_upload_preferences($group_id = NULL, $id = NULL)
{
@brandonkelly
brandonkelly / Module.php
Last active April 11, 2020 23:16
Custom Preview Target for Craft 3.2
<?php
// -- modules/Module.php --
namespace modules;
use Craft;
use craft\base\Element;
use craft\elements\Entry;
use craft\events\RegisterPreviewTargetsEvent;
@brandonkelly
brandonkelly / gist:8149062
Last active July 30, 2018 08:26
Saving new Matrix data
<?php
// Get the entry
$entry = craft()->entries->getEntryById(100);
// Convert the existing data to what it would look like in POST
$matrixData = array();
foreach ($entry->matrixField as $block)
{
@brandonkelly
brandonkelly / Make 'git difftool' use Changes.app
Created October 30, 2010 13:41
Make 'git difftool' use Changes.app
After clicking Changes > Install Terminal Utility…, add this to ~/.gitconfig:
[diff]
tool = changes-app
[difftool "changes-app"]
cmd = /usr/bin/chdiff $LOCAL $REMOTE
[difftool]
@brandonkelly
brandonkelly / gist:3217046
Created July 31, 2012 13:30
Wygwam extension for adding custom toolbar buttons
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
require_once PATH_THIRD.'matrix/config.php';
/**
* Wygwam Custom Toolbar Button
*
* This is a sample extension that would add a plugin to Wygwam’s extraPlugins setting,
@brandonkelly
brandonkelly / comparisons.md
Last active February 13, 2017 14:30
Craft Benchmarks

Test Info

  • Hardware: 2016 MacBook Pro w/ 2.9 GHz Intel Core i7, 16 GB 2133 MHz LPDDR3
  • MAMP Pro 4.1
  • Nginx 1.11.4
  • MySQL 5.6.34
  • PHP 5.6.28 / 7.1.0 (CGI mode, OPcache enabled)
  • ApacheBench 2.3
  • Craft CMS 2.6.2958 / 3.0.0-beta.1