Skip to content

Instantly share code, notes, and snippets.

View mattclements's full-sized avatar

Matt Clements mattclements

View GitHub Profile
@mattclements
mattclements / function.php
Last active October 29, 2024 22:04
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@mattclements
mattclements / .htaccess
Created August 10, 2012 20:55
Sample HTAccess File
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
ErrorDocument 400 /error_pages/400.php
ErrorDocument 401 /error_pages/401.php
ErrorDocument 403 /error_pages/403.php
ErrorDocument 404 /error_pages/404.php
ErrorDocument 410 /error_pages/410.php
@mattclements
mattclements / functions.php
Created November 10, 2014 20:43
Completely Disable Wordpress Comments (add to functions.php)
<?php
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}
@mattclements
mattclements / vhost.conf
Last active April 14, 2018 17:58
Apache VHOST File
ServerName [% vhost.servername %]
[% IF vhost.serveralias_array.size -%]
[% FOREACH alias IN vhost.serveralias_array -%]
ServerAlias [% alias %]
[% IF alias == 'www.' _ vhost.servername -%]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
[% END -%]
@mattclements
mattclements / pflogsumm.pl
Created June 9, 2012 20:46
Postfix Log Summary
#!/usr/bin/perl -w
eval 'exec perl -S $0 "$@"'
if 0;
=head1 NAME
pflogsumm.pl - Produce Postfix MTA logfile summary
Copyright (C) 1998-2010 by James S. Seymour, Release 1.1.3.
@mattclements
mattclements / app.js
Created January 8, 2017 09:37
Doorbell
function send_pushover_notification() {
var push = require( 'pushover-notifications' );
var p = new push( {
user: "xxxx",
token: "xxxx"
});
var msg = {
@mattclements
mattclements / dns_checker.php
Last active September 10, 2016 07:20
DNS Migration Checker
<?php
/**
* Script in order to compare a set of DNS Records from the current DNS supplier, to a new Name Server
* A standard array of records are setup, and can be enabled/disabled as required, and altered
* Then set a domain, and new Name Server to check against, and run the script in CLI PHP
* ./dns_checker.php
*
* This will create a HTML file in your current folder with details of the checks.
*
* N.B. You must have Net_DNS2 PEAR module installed 'pear install Net_DNS2'
@mattclements
mattclements / gist:8163509
Created December 28, 2013 20:01 — forked from mwaterfall/gist:953657
Runtime iOS Version Checking
/*
* System Versioning Preprocessor Macros
*/
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
@mattclements
mattclements / setup-urls.php
Last active December 30, 2015 17:49
Magento - Setup Product URL's after Import
<?php
require 'app/Mage.php';
Mage::app();
$amount = 0;
$model = Mage::getModel('catalog/product');
$products = $model->getCollection();
foreach ($products as $product) {
$model->load($product->getId());
$product->setUrlKey($model->getName())->save();
set_time_limit();
$_SESSION['UniqueRefMaxLength']