Skip to content

Instantly share code, notes, and snippets.

<table>
<thead>
<tr>
<th>Setting</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Setting A</td>
<?php
/**
*
* Plugin fires OnWebPagePrerender system event, loads Minify HTML by Mr Clay and minifies the requested Resource HTML inc. inline css and js.
*
* If used in conjunction with StatCache the minified HTML is cached and served as a flat file via IIS Rewrite.
*
* CREDITS
*
* http://rtfm.modx.com/revolution/2.x/developing-in-modx/basic-development/plugins
@jpdevries
jpdevries / gruntfile.js
Last active February 9, 2016 23:12
SVG-Sprite Gruntfile
module.exports = function(grunt) {
// Project configuration.
var initConfig = {
pkg: grunt.file.readJSON('package.json'),
dirs: { /* just defining some properties */
lib: './lib/',
theme: '../',
assets: 'assets/',
img: 'img/'
@jpdevries
jpdevries / SassMeister-input.scss
Created February 9, 2016 18:07
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
%greedy {
width:100%;
}
div {
// we can do this
@jpdevries
jpdevries / SassMeister-input.scss
Created February 9, 2016 18:05
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
%greedy {
width:100%;
}
div {
// wish we could do this
@jpdevries
jpdevries / math.js
Created January 2, 2016 02:46
cool math in js
function distanceBetweenTwoPoints(_a,_b) {
return Math.sqrt(Math.pow(Math.abs(_a.y - _b.y),2) + Math.pow(Math.abs(_a.x - _b.x),2))
}
@jpdevries
jpdevries / gruntfile.js
Created August 27, 2013 07:32
Reproducing potential Sass bug with extending silent classes from within silent classes using grunt-sass. To test, Download files, cd to directory and: npm install grunt Logged bug for grunt-sass here https://github.com/sindresorhus/grunt-sass/issues/40
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: { // Task
dist: { // Target
files: { // Dictionary of files
'style.css': 'style.scss' // 'destination': 'source'
}
},
@jpdevries
jpdevries / gist:5923886
Created July 3, 2013 23:56
Dynamically set current user's redactor.image_upload_path Setting based on the alias of the currently edited resource's parent
<?php
switch ($modx->event->name) {
case 'OnDocFormPrerender':
if(!$resource) return;
$key = 'redactor.image_upload_path';
$userId = $modx->user->get('id');
$usersetting = $modx->getObject('modUserSetting', array('key' => $key, 'user' => $userId));
if(!$usersetting) return;
@jpdevries
jpdevries / hits.sync.php
Last active December 19, 2015 05:49
Run this php script from outside MODX to Sync Page hits from HitsPage to Hits. HitsPage uses Template Variables this will import those values into a custom table for found resources. See comments for usage.
<?php
$tstart = microtime(true);
set_time_limit(0);
require 'config.core.php'; // absolute path to your MODX config
require MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = modX::getInstance();
$modx->initialize('mgr');
@jpdevries
jpdevries / gist:5894834
Created June 30, 2013 11:34
Correct Broken TinyMCE & CKEditor Image URLs Note: It's fine to have the / at the beginning, it will go to site root or the base href if one is set
UPDATE modx_site_content SET content = replace(content, 'src="assets', 'src="/assets');