Skip to content

Instantly share code, notes, and snippets.

View chrisdempsey's full-sized avatar

Chris Dempsey chrisdempsey

View GitHub Profile
@chrisdempsey
chrisdempsey / .htaccess
Last active August 29, 2015 14:06 — forked from opengeek/.htaccess
# Add this before your MODX Friendly URLs RewriteCond's and RewriteRule...
RewriteCond /abs/path/to/docroot/statcache%{REQUEST_URI} -f
RewriteRule ^(.*)$ /statcache/$1 [L,QSA]
@chrisdempsey
chrisdempsey / Contract Killer 3.md
Created May 25, 2016 18:25
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@chrisdempsey
chrisdempsey / in_arrayi.php
Created June 24, 2017 23:05 — forked from sepehr/in_arrayi.php
PHP: Case-insensitive in_array()
<?php
/**
* Case-insensitive in_array() wrapper.
*
* @param mixed $needle Value to seek.
* @param array $haystack Array to seek in.
*
* @return bool
*/
@chrisdempsey
chrisdempsey / sessionmanager.class.php
Created August 1, 2017 13:36
SessionManager: A script that can be used for easy control over your session variables
<?php
/**
* SessionManager
* A script that can be used for easy control over your session variables.
* Put this script in your core/components/ folder, inside a sessionman/ subdirectory.
*
* Load this one in your snippets/plugins like;
*
* $sessman = $modx->getService('session','SessionManager', $modx->getOption('sessman.core_path',null,$modx->getOption('core_path').'components/sessionman/'), $scriptProperties);
* if(!($sessman instanceof SessionManager)) { $modx->log(modX::LOG_LEVEL_ERROR, 'Session manager could not be loaded..'); return ''; }
<?php
function send_http_auth_headers(){
header('WWW-Authenticate: Basic realm="Your Website Name Restricted"');
header('HTTP/1.0 401 Unauthorized');
echo 'Please speak to an administrator for access to the this feature.';
exit;
}
add_action('template_redirect', 'maybe_add_http_auth_basic', 0);
function maybe_add_http_auth_basic(){
# Add your specific URI segment (i.e. http://example.com/segment-string/)
@chrisdempsey
chrisdempsey / wp-basic-http-authentication.php
Created May 12, 2018 23:28 — forked from jamesmorrison/wp-basic-http-authentication.php
Adding HTTP Authentication to a WordPress site
<?php
/**
* Plugin Name: WP Basic HTTP Authentication
* Plugin URI:
* Description: Adds HTTP Authentication to a WordPress site
* Author: James Morrison
* Version: 1.0.2
* Author URI: https://www.jamesmorrison.me
**/
@chrisdempsey
chrisdempsey / hosts
Created June 18, 2018 09:06
Hosts File to Block Facebook from my Machine
127.0.0.1 api.ak.facebook.com
127.0.0.1 api.connect.facebook.com
127.0.0.1 api.facebook.com
127.0.0.1 app.facebook.com
127.0.0.1 apps.facebook.com
127.0.0.1 ar-ar.facebook.com
127.0.0.1 badge.facebook.com
127.0.0.1 blog.facebook.com
127.0.0.1 connect.facebook.com
127.0.0.1 connect.facebook.net
@chrisdempsey
chrisdempsey / fa-bounce.css
Created June 10, 2020 11:45 — forked from gubi/fa-bounce.css
Pulse animation for FontAwesome icons
.fa-bounce {
display: inline-block;
position: relative;
-moz-animation: bounce 1s infinite linear;
-o-animation: bounce 1s infinite linear;
-webkit-animation: bounce 1s infinite linear;
animation: bounce 1s infinite linear;
}
@-webkit-keyframes bounce {
@chrisdempsey
chrisdempsey / cross-browser-opacity.css
Created June 11, 2020 12:41 — forked from arnoldc/cross-browser-opacity.css
css: cross browser opacity
selector {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
filter: alpha(opacity=30);
-moz-opacity: 0.3;
-khtml-opacity: 0.3;
opacity: 0.3;
}
@chrisdempsey
chrisdempsey / createImg.pthumnb.modx.php
Created January 15, 2021 00:22 — forked from NatemcM/createImg.pthumnb.modx.php
A snippet that creates a <picture></picture> element with webp & jpg sources using pThumb with different media sizes depending on layout for bootstrap
<?php
$img_src = $modx->getOption('src', $scriptProperties);
$img_alt = $modx->getOption('alt', $scriptProperties);
$img_width = $modx->getOption('width', $scriptProperties,640);
$is_lazy = $modx->getOption('lazy', $scriptProperties, false);
$img_class = $modx->getOption('class', $scriptProperties, 'img-fluid');
$colums = $modx->getOption('cols', $scriptProperties, '{"xs":12,"sm":12,"md":8,"lg":6,"xl":6}');
$img_type = $modx->getOption('type', $scriptProperties, 'jpg');
$dataAttr = '';