Skip to content

Instantly share code, notes, and snippets.

View opengeek's full-sized avatar

Jason Coward opengeek

View GitHub Profile
@opengeek
opengeek / InstagramAspectPadding.js
Last active March 9, 2022 19:26
Use Photoshop scripting to adjust any image that exceeds Instagram aspect ratios by padding the canvas size with white background color.
var docRef = app.activeDocument;
var currentWidth = docRef.width;
var currentHeight = docRef.height;
var aspectRatio = currentWidth / currentHeight;
var mycolor = new SolidColor();
mycolor.rgb.hexValue = "ffffff";
app.backgroundColor = mycolor;
if (aspectRatio < 0.8) {
<?php
$tstart = microtime(true);
set_time_limit(0);
require 'config.core.php';
require MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = modX::getInstance();
$modx->initialize('mgr');

A New Branching Strategy for MODX Revolution

This week we have modified the branching strategy that we have been using when maintaining the MODX Revolution repository at Github. The long familiar master and develop branch are gone, and in their place we have major and minor version branches that serve the same purposes for each major and the current stable minor releases of MODX Revolution. Since the current stable minor release of version 2 is 2.4.0, that means we have a 2.x (default) branch and a 2.4.x branch which replace—in terms of where to target Pull Requests—develop and master respectively for version 2. In the coming days, a 3.x development branch will appear as well.

Following are some tips for keeping up with the changes.

Updating Existing Clones

If you have a clone of the official repository, you can quickly fetch and checkout the latest branches.

@opengeek
opengeek / teleport-test-set-modx.php
Created August 11, 2015 03:09
An example of using the `setMODX()` method I'm proposing for Teleport
<?php
require __DIR__ . '/config.core.php';
require MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
require __DIR__ . '/src/bootstrap.php';
@opengeek
opengeek / implodeAssociativeArrayWithArrayWalk.php
Created August 4, 2015 03:23
Implode an associative array using `array_walk()`
<?php
$array = array(
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3',
);
$flattened = $array;
array_walk($flattened, function(&$value, $key) {
$value = "{$key} ({$value})";
});
@opengeek
opengeek / src-Middleware-MODSlim.php
Created June 9, 2015 15:52
This is a proof of concept for using MODX 2.x as a dependency in a Slim application
<?php
/*
* This file is part of the MODSlim package.
*
* Copyright (c) Jason Coward <jason@opengeek.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@opengeek
opengeek / gist:483d830bf35b60a2ef22
Created April 17, 2015 18:58
PHP ZipArchive::extractTo() truncates path segments ending in `.`
<?php
$filename = 'test-archive.zip';
if (is_readable('test/test.txt')) {
unlink('test/test.txt');
}
if (is_readable('test./test.txt')) {
unlink('test./test.txt');
}
if (is_readable('.test/test.txt')) {
@opengeek
opengeek / Changeset configuration example
Last active February 8, 2023 12:19
Adding the following config_options entries to your MODX Revolution config file will allow you to track changes made to any xPDOObject class via the `xPDOObject::save()`, `xPDOObject::remove()`, `xPDO::updateCollection()`, or `xPDO::removeCollection()` methods. This example records changes into a database register called `changes` under a config…
<?php
$config_options = array (
'callback_excludes' => array(
'modSession',
'modManagerLog',
'modActiveUser',
'modDbRegisterQueue',
'modDbRegisterTopic',
'modDbRegisterMessage',
'modUser',
@opengeek
opengeek / useTranslitService.php
Created September 20, 2012 13:26
Example of using the MODX transliteration service
<?php
$translitClassPath = $this->xpdo->getOption(
'friendly_alias_translit_class_path',
$options,
$this->xpdo->getOption('core_path', $options, MODX_CORE_PATH) . 'components/'
);
if ($this->xpdo->getService('translit', $translitClass, $translitClassPath, $options)) {
$alias = $this->xpdo->translit->translate($stringToApplyTransliterationTo, $translitTableName);
}
@opengeek
opengeek / optimized.html
Created September 18, 2012 17:08
Example of optimizing conditional filters using a Chunk wrapper
[[[[*page-image:notempty=`$wrapImgThumb? &src=`*page-image` &alt=`[[*pagetitle]]` &thumbOpts=`w=480&h=320``]]]]