Skip to content

Instantly share code, notes, and snippets.

@eikes
eikes / jquery.uncheckable_radio.js
Created March 11, 2014 11:42
jQuery plugin to allow unchecking radio buttons
(function ($) {
$.fn.uncheckableRadio = function () {
return this.each(function () {
var radio = this,
label = $('label[for="' + radio.id + '"]');
if (label.length === 0) {
label = $(radio).closest("label");
}
var label_radio = label.add(radio);
label_radio.mousedown(function () {
@pmeenan
pmeenan / user-timing-rum.js
Last active January 18, 2024 23:46
Support routine for adding W3C user timing events to a site. Includes some basic polyfill support for browsers that don't support user timing or navigation timing (though the start time for non-navigation timing support could be improved with IE < 9 to use IE's custom start event).
// Support routines for automatically reporting user timing for common analytics platforms
// Currently supports Google Analytics, Boomerang and SOASTA mPulse
// In the case of boomerang, you will need to map the event names you want reported
// to timer names (for mPulse these need to be custom0, custom1, etc) using a global variable:
// rumMapping = {'aft': 'custom0'};
(function() {
var wtt = function(n, t, b) {
t = Math.round(t);
if (t >= 0 && t < 3600000) {
// Google Analytics
@panks
panks / export.php
Last active December 16, 2015 21:49
New /wp-admin/includes/export.php for WordPress which generates JSON output.
<?php
/**
* WordPress Export Administration API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Version number for the export format.
@Fi1osof
Fi1osof / gist:5062419
Created March 1, 2013 04:11
OnWebPageComplete stats plugin
<?php
$memory = round(memory_get_usage()/1024/1024, 4).' Mb';
print "<div>Memory: {$memory}</div>";
$totalTime= ($modx->getMicroTime() - $modx->startTime);
$queryTime= $modx->queryTime;
$queryTime= sprintf("%2.4f s", $queryTime);
$queries= isset ($modx->executedQueries) ? $modx->executedQueries : 0;
$totalTime= sprintf("%2.4f s", $totalTime);
@dubrod
dubrod / MODX Nav Switch
Last active December 13, 2015 19:29
Switch MODX Nav from <ul> to <select> when mobile device detected.
Change Nav UL to Select when Mobile.
System Settings: Turn off resource and snippet caching. cacheable default is none. no pages can be cached.
1. add mobile_device_detect.php to the root folder
2. make sure jquery is called at the top of every page
@jareware
jareware / SCSS.md
Last active April 23, 2024 22:13
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@splittingred
splittingred / gist:4689218
Last active April 30, 2019 09:39
Example of modRest, a REST Client, in MODX 2.3.
$config = array(
'baseUrl' => rtrim('http://mywebsite.com/rest/api/','/'),
'format' => 'json', // json or xml, the format to request
'suppressSuffix' => false, // if false, will append .json or .xml to the URI requested
'username' => 'myuser', // if set, will use cURL auth to authenticate user
'password' => 'mypass',
'curlOptions' => array(
'timeout' => 30, // cURL timeout
'otherCurlOption' => 1,
@Mark-H
Mark-H / benchmark.php
Created December 7, 2012 17:41
MODX Performance Benchmark Snippet
<?php
// Use this line to prevent people from hammering your server.
if (!isset($_GET['super_secret']) || ($_GET['super_secret'] != 'secretpassword')) return 'Not authorized';
// Call this snippet uncached in a resource with template "empty":
// content: "[[!benchmark]]"
// Make sure to tag the resource as uncachable
// The intro
echo '<body style="font-family: sans-serif;">';
@goldsky
goldsky / connector.php
Last active November 25, 2020 20:30
Ajax's connector file using MODX's main index.php
<?php
/**
* Ajax Connector
*
* @package mypackage
*/
$validActions = array(
'web/data/delete',
'web/data/edit'
<?php
$file = $modx->getOption('base_path') . 'facebook.php';
if (file_exists($file)) {
require_once $file;
}