Skip to content

Instantly share code, notes, and snippets.

Josh Hartman joshhartman

Block or report user

Report or block joshhartman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@joshhartman
joshhartman / .htaccess
Created Dec 6, 2018
Simple Let's Encrypt AutoSSL Rewrite Rule
View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^\.well-known - [L]
</IfModule>
@joshhartman
joshhartman / .htaccess
Last active Nov 16, 2018
Redirect to HTTPS
View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
@joshhartman
joshhartman / gist:2c0f3b2f81a3e8d5a1853dd54333206e
Created Jul 28, 2018
cPanel AutoSSL Let's Encrypt mod_rewrite rules to add immediately before each RewriteRule line in your .htaccess
View gist:2c0f3b2f81a3e8d5a1853dd54333206e
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
Leverage browser caching and GZip compression (Apache)
View .htaccess
## 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"
View unzip.php
<?php
$zip = new ZipArchive;
if ($zip->open('archive.zip') === TRUE) {
$zip->extractTo('.');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
View sql-restore.php
<?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 Aug 26, 2016
Extract ZIP file to current directory
View unzip.php
<?php
$zip = new ZipArchive;
if ($zip->open('test.zip') === TRUE) {
$zip->extractTo('.');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
@joshhartman
joshhartman / accordion.html
Created May 23, 2016
Ridiculously simple accordion without the jQuery UI library
View accordion.html
<!-- Source: http://uniondesign.ca/simple-accordion-without-jquery-ui/ -->
<!-- JS -->
<script type="text/javascript">
$(document).ready(function($) {
$('#accordion').find('.accordion-toggle').click(function(){
//Expand or collapse this panel
$(this).next().slideToggle('fast');
@joshhartman
joshhartman / exim.conf
Last active May 14, 2016
Exim Configuration for Gmail SMTP Relay (CentOS 6)
View exim.conf
######################################################################
# 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 Aug 31, 2018
Facebook Feed PHP Function
View facebook_feed.php
<?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 = ''){
You can’t perform that action at this time.