Skip to content

Instantly share code, notes, and snippets.

View beneverard's full-sized avatar

Ben Everard beneverard

View GitHub Profile
@beneverard
beneverard / .editorconfig
Created February 29, 2024 14:35
.editorconfig
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
@beneverard
beneverard / phpcs.xml
Created February 29, 2024 13:20
Laravel PHPCS configuration file
<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
<description>PHP Code Sniffer configuration file.</description>
<!-- inspired from this gist -->
<!-- https://gist.github.com/ulcuber/e4ad20e24e0282b48e870bc54a9c592c -->
<file>app</file>
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.17.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.17.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@beneverard
beneverard / query.sql
Created May 24, 2016 10:20
A query to list the 404 URLs captured by Redirection (WordPress plugin), ordered by most hits first. Very handy for finding common 404s and handling them with a manual redirect.
SELECT count(id) as count, url
FROM wp_redirection_404
GROUP BY url
ORDER BY count DESC;
@beneverard
beneverard / attachment_rewrite.php
Last active December 29, 2015 08:19
Rewrite attachment URLs from a local version of WordPress to a remote version.
// remove username:password if you don't need htpasswd auth
add_filter('wp_get_attachment_url', function($url) {
$upload_dir = wp_upload_dir();
$file_path = str_replace(site_url() . '/wp-content/uploads', $upload_dir['basedir'], $url);
// check to see if the file exists locally first
if ( file_exists($file_path) ) {
return $url;
@beneverard
beneverard / caching.apacheconfig
Created November 22, 2013 09:27
Shropgeek Rebellion - Web performance improvements you can make in one hour. Supplementary code, links and notes. Slides: https://speakerdeck.com/beneverard/shropgeek-rebellion-web-performance-improvements-in-one-hour
# CACHING
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType text/html "access plus 1 hour"
ExpiresByType text/richtext "access plus 1 hour"
ExpiresByType text/plain "access plus 1 hour"
<?php
$pages = new query_loop( array(
'post_type' => 'page'
));
foreach( $pages as $id => $post ) {
the_title();
// etc...
}
@beneverard
beneverard / caching.apacheconfig
Last active December 16, 2015 23:49
Points Brighton - Web performance improvements you can make in one hour. Supplementary code and links
# CACHING
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType text/html "access plus 1 hour"
ExpiresByType text/richtext "access plus 1 hour"
ExpiresByType text/plain "access plus 1 hour"
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array('slug' => 'about/meet-the-team', 'with_front'=>false),
'capability_type' => 'page',
'hierarchical' => true,
'menu_position' => null,
//****************
// $SS-ICON $FANCY
[class^="ss-"], [class*=" ss-"], .ss-icon {
&.fancy {
display: inline-block;
margin-right: 5px;
padding: 8px 8px 8px 0;
line-height: 1;
&:before {