Skip to content

Instantly share code, notes, and snippets.

View christianhanvey's full-sized avatar

Christian Hanvey christianhanvey

View GitHub Profile
@christianhanvey
christianhanvey / links
Created July 24, 2012 00:17
some useful reference links - in markdown

Website Contract

Revised date: 13/03/2013

Between us: Crunch Design

and you: [customer name]

Summary:

@christianhanvey
christianhanvey / MODX caching.md
Last active June 14, 2017 11:26
Some links on caching for MODX

If you are using git, so you can take advantage of static elements within MODX, you will need to be aware that simply updating your files does not mean MODX will pick that up. It will pick up changes in a file IF you the element is being called uncached.

http://forums.modx.com/forums/thread/73346/static-resources-don-t-update-without-cache-clear http://forums.modx.com/thread/73002/static-sources-caching-and-setup

This is not a big deal while working on a development site, performance is not your initial priority at that point. But when you get to deploying, you'll need to know that updating a file will not necessarily update how your site runs, and you don't want to be clearing your entire site cache. A big site would be taking a heavy server hit as its visitors trigger all pages regenerating their cache...

For an overview of MODX caching strategy, start at the documentation (of course) if you havn't already:

@christianhanvey
christianhanvey / modx-content-search-and-replace.php
Last active December 15, 2017 09:43
MODX utility snippet: replace absolute formed links in site content eg www.xxx.com/99 -> [[~99]] note: backing up modx_site_content table is a good idea before running this :) (original author: BobRay)
<?php
$docs = $modx->getCollection('modDocument');
$pattern = '/www.xxx.com/(\d+)/';
$replacement = '[[~$1]]';
$count = 0;
foreach ($docs as $doc) {
$content = $doc->getContent();
$hash1 = sha1($content);
@christianhanvey
christianhanvey / modx-upgrade.sh
Last active November 1, 2017 16:40
A shell script to help automate the upgrade of a MODX Revolution installation
#!/bin/bash
# modx-upgrade.sh
# ---------------
# A shell script to help automate the upgrade of a MODX Revolution installation
# This script is for traditional installations only - not advanced
#
# Instructions:
# 1. Update the config section with your own site specific details
# 2. Upload this file to your server, preferably outside of web root
@christianhanvey
christianhanvey / jquery.equalHeights.js
Created October 2, 2013 23:04
Ye olde jQuery equal heights plugin
// jQuery plugin to create equal height elements
// Will make all elements that match the seletor the same height - matching the tallest of all of the elements.
//
// usage:
// $('.selector').equalHeights();
(function ( $ ) {
$.fn.equalHeights = function(els) {
var maxHeight = 0;
this.each(function(){
@christianhanvey
christianhanvey / gist:10820339
Created April 16, 2014 06:58
angular safeApply
angular.module('ng').run(['$rootScope', function($rootScope) {
$rootScope.safeApply = function(fn) {
var phase = this.$root.$$phase;
if(phase == '$apply' || phase == '$digest') {
if(fn && (typeof(fn) === 'function')) {
fn();
}
} else {
this.$apply(fn);
}
@christianhanvey
christianhanvey / app.js
Created April 16, 2014 07:05
angular radio switch directive - an on/off switch
window.app = angular.module('mainApp', []);
app.controller('mainCtrl', function ($scope) {
$scope.include = 'yes';
});
app.directive('radioSwitch', ['analyticsSettings', function (analyticsSettings) {
return {
restrict: 'A',
scope: {
@christianhanvey
christianhanvey / prevent-animations.directive.js
Created November 8, 2021 22:15
AngularJS Prevent-Animations directive
angular
.module('utilities')
.directive('preventAnimations', ['$animate', function ($animate) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
$animate.enabled(element, false);
}
};
}]);