Skip to content

Instantly share code, notes, and snippets.

View MattWilcox's full-sized avatar

Matt Wilcox MattWilcox

View GitHub Profile
@MattWilcox
MattWilcox / gist:89e04beb7843b21c204a
Created July 18, 2014 15:18
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.
<!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 July 18, 2014 15:27
Pre '<picture>' way to change crop of an image at different sizes
<!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;
}
<!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 April 3, 2017 13:35
Using MultiAdd to create a "reorder" facility for Craft Commerce
<?php
// logic/LogicPlugin.php
/**
* logic plugin for Craft CMS
*
* logic
*
* @author VCA
* @copyright Copyright (c) 2016 VCA
@MattWilcox
MattWilcox / wp-config.php
Created March 18, 2013 14:38
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.
/* 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 / update-dns.sh
Created December 24, 2021 15:12 — forked from christr/update-dns.sh
Linode dynamic DNS updating script
#!/bin/bash
# Modified by Chris Richardson (https://github.com/christr and https://twitter.com/christr77) on 09/20/2020
# Previous versions of this script don't work because they hadn't been updated since 2012. There are now more steps involved to set this up.
# This script update is based on information found here: https://developers.linode.com/api/v4/domains-domain-id-records-record-id/#put
# You first must find out the domain ID and resource ID numbers. In order to do this follow the steps below.
# 1. Create a Linode API Key through your account profile at https://cloud.linode.com/dashboard. Give it rights to read/write to domains only.
# 2. From a shell run the following command: LINODE_API_KEY=[insert API key from step 1 here]
# 3. Run the following command to get the domain ID number for the domain you want to manage: curl -H "Authorization: Bearer $LINODE_API_KEY" https://api.linode.com/v4/domains/
@MattWilcox
MattWilcox / build_nginx.sh
Last active March 6, 2022 18:01
Fetch, build, and install the latest nginx with the latest OpenSSL for RaspberryPi
#!/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/