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 / .htaccess
Created December 6, 2018 17:49
Simple Let's Encrypt AutoSSL Rewrite Rule
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^\.well-known - [L]
</IfModule>
@joshhartman
joshhartman / .htaccess
Last active November 16, 2018 18:44
Redirect to HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
@joshhartman
joshhartman / gist:2c0f3b2f81a3e8d5a1853dd54333206e
Created July 28, 2018 18:54
cPanel AutoSSL Let's Encrypt mod_rewrite rules to add immediately before each RewriteRule line in your .htaccess
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
@joshhartman
joshhartman / .htaccess
Last active May 18, 2018 17:02
Leverage browser caching and GZip compression (Apache)
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType application/pdf "access plus 1 year"
ExpiresByType application/x-shockwave-flash "access plus 1 year"
@joshhartman
joshhartman / sql-restore.php
Created August 24, 2017 23:14
SQL Restore Script
<?php
// your config
$filename = 'sql-restore.sql';
$dbHost = 'localhost';
$dbUser = 'xxx_yyy';
$dbPass = 'abc123';
$dbName = 'xxx_yyy';
$maxRuntime = 110; // less then your max script execution limit
$deadline = time()+$maxRuntime;
@joshhartman
joshhartman / unzip.php
Created August 26, 2016 16:30
Extract ZIP file to current directory
<?php
$zip = new ZipArchive;
if ($zip->open('test.zip') === TRUE) {
$zip->extractTo('.');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
@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 / 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 / facebook_feed.php
Last active August 31, 2018 22:27
Facebook Feed PHP Function
<?php
/**
* Output a facebook status feed for specified page/group/user id
*
* @param int $id id of the page/group/user
* @param int $limit limit number of statuses displayed
* @param string $access_token facebook developer application access token
*
*/
function facebook_status_feed($id, $limit = 10, $access_token = ''){