Skip to content

Instantly share code, notes, and snippets.

Matt Wilcox MattWilcox

Block or report user

Report or block MattWilcox

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
View Cropping an image with centre alignment
<!DOCTYPE html>
<html>
<head>
<style>
.frame {
position: relative;
height: 0; padding-bottom: 75%; /* 4:3 cropped aspect ratio */
max-width: 1200px; /* natural image size */
overflow: hidden;
}
@MattWilcox
MattWilcox / wp-config.php
Created Mar 18, 2013
Bits to add to wp-config.php to make things sane when developing in a real development system (local > stage > live) instead of developing directly on a live server. Which is what WP is set up to do and which is ridiculous.
View wp-config.php
/* Lets not rely on paths in the database, they can be very wrong when moving between dev/stage/live environments */
/* The following two variables are backward to my thinking, but hey, what ya gonna do? */
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . ''); // This is NOT the 'wordpress admin area' home, but the site's home
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/SECRETDIRECTORY'); // This isn't the site's URL but the WordPress admin area URL
/* MySQL settings */
switch($_SERVER['SERVER_NAME']){
// Your local machine's settings
case 'mysite.local':
define('DB_NAME', 'dev_mysite');
@MattWilcox
MattWilcox / build_nginx.sh
Last active May 16, 2018
Fetch, build, and install the latest nginx with the latest OpenSSL for RaspberryPi
View build_nginx.sh
#!/usr/bin/env bash
# names of latest versions of each package
export VERSION_PCRE=pcre-8.38
export VERSION_OPENSSL=openssl-1.0.2d
export VERSION_NGINX=nginx-1.9.7
# URLs to the source directories
export SOURCE_OPENSSL=https://www.openssl.org/source/
export SOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
@MattWilcox
MattWilcox / gist:89e04beb7843b21c204a
Created Jul 18, 2014
How easy it would be to do Responsive Images in HTML and CSS if https://developer.mozilla.org/en-US/docs/Web/CSS/attr worked.
View gist:89e04beb7843b21c204a
<!doctype html>
<html>
<head>
<style>
img:after { content: attr(data-small url); }
@media screen and (min-width:400px) {
img:after { content: attr(data-medium url); }
}
@MattWilcox
MattWilcox / gist:db51054f3d9e3ea68763
Created Jul 18, 2014
Pre '<picture>' way to change crop of an image at different sizes
View gist:db51054f3d9e3ea68763
<!DOCTYPE html>
<html>
<head>
<style>
.frame {
position: relative;
height: 0; padding-bottom: 75%; /* 4:3 cropped aspect ratio */
max-width: 1200px; /* natural image size */
overflow: hidden;
}
@MattWilcox
MattWilcox / LogicPlugin.php
Created Apr 3, 2017
Using MultiAdd to create a "reorder" facility for Craft Commerce
View LogicPlugin.php
<?php
// logic/LogicPlugin.php
/**
* logic plugin for Craft CMS
*
* logic
*
* @author VCA
* @copyright Copyright (c) 2016 VCA
You can’t perform that action at this time.