Skip to content

Instantly share code, notes, and snippets.

@joshhartman
joshhartman / gist:68bb189fc13ed604a73eb5a7a3d9cb68
Created March 5, 2020 07:48
ImageMagick -- Resize large images recursively and preserve the aspect ratio -- Windows Command Prompt
FOR /R %f IN (*.jpg) DO magick "%f" -resize 3000x3000^> -quality 85 "%f"
@joshhartman
joshhartman / randomPassword.php
Last active January 8, 2024 13:29
Human Readable Password Generator (Requires PHP 7.1+)
<?php
function randomPassword( $len = 10, $ucfirst = true, $spchar = true ){
/* Programmed by Christian Haensel
* christian@chftp.com
* http://www.chftp.com
*
* Exclusively published on weberdev.com.
* If you like my scripts, please let me know or link to me.
* You may copy, redistribute, change and alter my scripts as
* long as this information remains intact.
@joshhartman
joshhartman / gist:2289649
Created April 3, 2012 05:58
Creating XML Using SimpleXML + DOMDocument Output Formatting and SHJS Syntax Highlighting
<?php
$rss = new SimpleXMLElement('<rss version="2.0"/>');
$channel = $rss->addChild('channel');
$item = $channel->addChild('item');
$item->addChild('title')->{0} = 'Convicts flood streets of Boston';
$item->addChild('link')->{0} = 'http://www.example.com/2012/04/convicts-flood-streets-of-boston/';
$item->addChild('description')->{0} = 'Summarize news story here.';
@joshhartman
joshhartman / accordion.html
Last active August 18, 2023 06:18
Ridiculously simple accordion without the jQuery UI library
<!-- Source: http://uniondesign.ca/simple-accordion-without-jquery-ui/ -->
<!-- JS -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#accordion').find('.accordion-toggle').click(function(){
//Expand or collapse this panel
$(this).next().slideToggle('fast');
@joshhartman
joshhartman / randomPassphrase.php
Last active August 15, 2023 13:29
Memorable Passphrase Generator (Requires PHP 7.1+)
<?php
function randomPassphrase( $numwords = 3, $minlength = 16, $ucfirst = true, $spchar = true )
{
if ( $numwords < 3 ) {
$numwords = 3;
} elseif ( $numwords > 6 ) {
$numwords = 6;
}
if ( $minlength < $numwords * 4.5 ) {
$minlength = $numwords * 5;
@joshhartman
joshhartman / .htaccess
Created October 24, 2015 15:44 — forked from anonymous/.htaccess
SSL Proxy Redirect to HTTPS (compatible with Network Solutions web hosting)
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@joshhartman
joshhartman / autop.php
Created April 14, 2013 02:27
Function to automatically add paragraphs to blocks of text with line breaks, ripped from WordPress
<?php
/**
* Replaces double line-breaks with paragraph elements.
*
* A group of regex replaces used to identify text formatted with newlines and
* replace double line-breaks with HTML paragraph tags. The remaining
* line-breaks after conversion become <<br />> tags, unless $br is set to '0'
* or 'false'.
*
* @param string $pee The text which has to be formatted.
@joshhartman
joshhartman / crypt.class.php
Last active November 25, 2022 10:10
Rijndael 256-bit Encryption (CBC) Class
<?php
class Crypt {
private $key;
function __construct($key){
$this->setKey($key);
}
@joshhartman
joshhartman / exim.conf
Last active October 17, 2022 18:44
Exim Configuration for Gmail SMTP Relay (CentOS 6)
######################################################################
# Runtime configuration file for Exim #
######################################################################
# This is a default configuration file which will operate correctly in
# uncomplicated installations. Please see the manual for a complete list
# of all the runtime configuration options that can be included in a
# configuration file. There are many more than are mentioned here. The
# manual is in the file doc/spec.txt in the Exim distribution as a plain
@joshhartman
joshhartman / functions.php
Last active July 5, 2022 21:23
Disable specific WordPress shortcodes when editing with Beaver Builder
<?php
// Disable specific WordPress shortcodes when editing with Beaver Builder
function shortcode_compatibility_bb_fix() {
if ( FLBuilderModel::is_builder_active() ) {
remove_shortcode( 'gravityform' );
remove_shortcode( 'fl_builder_insert_layout' );
}
}
add_action( 'wp', 'shortcode_compatibility_bb_fix' );