Skip to content

Instantly share code, notes, and snippets.

@jpdevries
jpdevries / gist:5733212
Created June 7, 2013 23:55
jQuery Class Example. Originally written for Holden Outerwear 2011 site.
/*
upcModel used to get upc when provided fabric, colorway, and size
invModel used to get the regions and retailers carring the given upc
*/
/* __
/\ \ /\ \__
\_\ \ __ \ \ ,_\ __
/'_` \ /'__`\ \ \ \/ /'__`\
@jpdevries
jpdevries / gist:5846502
Last active December 18, 2015 21:19
Algorithm to Abbreviate file names from the center. OS X style.
filename = (numChars < maxChars) ? fileName : (fileName.substr(0,(numChars / 2) - ((numChars - maxChars) / 2)) + '...' + fileName.slice( - ((numChars / 2) - ((numChars - maxChars) / 2) - (fileExtension.length + 1))));
@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');
@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: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 / 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:8902471
Created February 9, 2014 17:24
Sass to override Redactor font-family
/* this will override the redactor font-family declaration regarldess order */
body { /* add specificity */
.redactor-link-tooltip,
.redactor-link-tooltip a {
font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif !important; /* your other font here */
}
}
@jpdevries
jpdevries / SassMeister-input-HTML.html
Created April 8, 2014 17:10
Generated by SassMeister.com.
<h1>modmore rules!</h1>
@jpdevries
jpdevries / SassMeister-input-HTML.html
Created April 28, 2014 00:15
Generated by SassMeister.com.
<div class="vanity">
<div class="focus">
<h2>Hello World</h2>
</div>
</div>
@jpdevries
jpdevries / gist:cff53d6ff3481661eeca
Last active August 29, 2015 14:04
redactor patch
<?php
// patches https://github.com/modxcms/revolution/issues/11291 for Redactor 1.4.3 and MODX 2.2.15 - 2.3.1
$this->patch_11291 =
(bool)((bool)$this->modx->getOption('redactor.patch_11291', null, false)
&& version_compare('2.2.15-pl',$vd['full_version'],'<=')
&& version_compare('2.3.1-pl',$vd['full_version'],'>='))
;