Skip to content

Instantly share code, notes, and snippets.

@jpdevries
jpdevries / nosvg.js
Created December 16, 2015 04:00
PoC for a SVG "polyfill"
/*
<svg class="icon" data-png-fallback="assets/img/src/icons/black/png/icon-modx">
<title>Best CMS Ever</title>
<use xlink:href="assets/img/icons.svg#icon-modx"></use>
</svg>
*/
var hasSVG = false; //your feature detection here
(function(hasSVG){
if(!hasSVG) {
@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 / gist:7c17dce93df93ca932e2
Last active November 23, 2020 11:39
Duplicate MODX User Group from Command Line
<?php
/**
* Duplicates a MODX User Group
* USAGE:
* php duplicateusergroup.php 1 New\ Group
* php duplicateusergroup.php 1 New\ Group newuser you@you.com password
*/
$tstart = microtime(true);
set_time_limit(0);
@jpdevries
jpdevries / ie-9-fu.html
Created April 4, 2015 04:47
Tell IE 9 users to update their browser.
<!--[if IE 9]>
<script>alert('Your browser is ' + (Math.round((new Date() - new Date(2011,3,12)) / (1000 * 60 * 60 * 24)) + ' days') + 'out of date and does not properly support the Flexible Box Model. Problem is it thinks it does and will unsuccesfully attempt to. Please return in a modern browser.');</script>
<![endif]-->
@jpdevries
jpdevries / isNakedDay
Last active August 29, 2015 14:18
isNakedDay PHP Snippet for MODX Revolution
<?php
$start = date('U', mktime(-12, 0, 0, 04, $d, date('Y')));
$end = date('U', mktime(36, 0, 0, 04, $d, date('Y')));
$z = date('Z') * -1;
$now = time() + $z;
if ( $now >= $start && $now <= $end ) {
return true;
}
return false;
@jpdevries
jpdevries / eureka-media-browser.html
Last active August 29, 2015 14:17
HTML-first crack at a Flexible Media Browser
<!doctype html>
<!-- if you like markup please stop by and say hello over at http://markup.tips -->
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="HTML-first crack at a Flexible Media Browser">
<meta name="viewport" content="width=device-width, initial-scale=1">
@jpdevries
jpdevries / modernizr-fallback.html
Created March 16, 2015 16:13
Load modernizr.js from CDN with local fallback
<!-- try to load modernizr from a CDN, use h5bp-ish style fallback to load locally if needed -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script>
<script>try{Modernizr} catch(e) {document.write('<script src="./assets/js/vendor/modernizr-2.8.3.min.js"><\/script>')}</script>
@jpdevries
jpdevries / settings-table.js
Last active August 29, 2015 14:16
settings-table for modern browsers
$('.settings-table').each(function(){
var _that = $(this);
_that.find('tbody > tr:not(.setting-form)').on((!Modernizr.touch) ? 'focusin' : 'click',function(e){
$(this).toggleClass('open').siblings('.open').removeClass('open');
}).addClass('clickable');
});
@jpdevries
jpdevries / settings-table-oldie.js
Last active May 21, 2016 11:10
settings-table for old browsers
$('.settings-table').each(function(){
$(this).on('focusin click','tbody > tr:not(.setting-form)',function(e){
$(this).addClass('open').siblings('.open').removeClass('open');
});
});
@jpdevries
jpdevries / SassMeister-input.scss
Created March 8, 2015 04:57
Generated by SassMeister.com.
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
html.js {
.js-hide {
display:none;
}
}