Skip to content

Instantly share code, notes, and snippets.

View UltraSimplified's full-sized avatar

Robin Layfield UltraSimplified

View GitHub Profile
@UltraSimplified
UltraSimplified / Restrict_access_to_WP_Site_Health.php
Last active December 2, 2020 10:00
Restrict access to WordPress Site Health notices
add_action('wp_dashboard_setup', 'restrict_site_health_dashboard_widget' );
/**
* Restrict access to Site Health Dashboard Widget
*
*/
function restrict_site_health_dashboard_widget() {
// permitted users
$permitted_users = []; // Array of permitted user ids
@UltraSimplified
UltraSimplified / relative-time.php
Last active December 3, 2021 05:33 — forked from mtttmpl/relative-time.php
Get Relative Time in PHP (e.g. '1 hour ago', 'yesterday', 'tomorrow', 'in 2 weeks')
<?php
function time2str($ts) {
if(!ctype_digit($ts)) {
$ts = strtotime($ts);
}
$diff = time() - $ts;
if($diff == 0) {
return 'now';
} elseif($diff > 0) {
$day_diff = floor($diff / 86400);
@UltraSimplified
UltraSimplified / functions.php
Last active November 24, 2022 17:27
Override the standard WordPress password messages
/*
* Change the password reset text
*
**/
function change_password_reset_text_filter( $translated_text, $untranslated_text, $domain ) {
switch( $untranslated_text ) {
case 'Enter your new password below.':
@UltraSimplified
UltraSimplified / functions.php
Created February 26, 2016 12:31
WP > Hierarchical List of Ancestors, Siblings, Children of current page
/**
* Create HTML list of pages.
*
* @package Razorback
* @subpackage Walker
* @author Michael Fields <michael@mfields.org>
* @copyright Copyright (c) 2010, Michael Fields
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* @uses Walker_Page
@UltraSimplified
UltraSimplified / .htaccess-codeigniter-gandi.net
Last active August 29, 2016 11:12
Custom .htaccess for use on Gandi.net with Codeigniter hiding index.php Varnish temporarily disabled (for development) see http://blog.ultrasimplified.com/fixing-codeigniter-paths-with-htaccess-on-gandi-net/ for more information
# temporarily disable Varnish
# to make it easier to test changes
Header add Cache-Control "max-age=1"
RewriteEngine On
# Existing files and directories remain accessible
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.* - [L]

Lesson's learnt building the Guardian

Below is a collection of my favourite responses I gathered from Guardian engineers when asked the question: What have you learnt starting from scratch and building a mobile-first next generation web platform for the Guardian?

Daithi O Crualaoich

  • Work with great people.
  • Deploy like crazy. This means the team has to control the infrastructure as well as code.
  • Design is not a service. Designers have to sit in the team.
  • Infrastructure is intrinsically unreliable. Discard and replace is the robust strategy.
  • Use your CDN for HTML too.
  • Don't always do as you are told.

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

<!-- content to be placed inside <body>…</body> -->
<div class="lozenge red">&nbsp;99</div>
<div class="lozenge green">&nbsp;45</div>
<div class="lozenge yellow">100</div>
<div class="lozenge blue">&nbsp;&nbsp;3</div>
<div class="lozenge grey">&nbsp;60</div>
<div class="lozenge red small">&nbsp;99</div>
<div class="lozenge green small">&nbsp;45</div>
<div class="lozenge yellow small">100</div>
<!-- content to be placed inside <body>…</body> -->
<div class="lozenge red">99%</div>
<div class="lozenge green">45%</div>
<div class="lozenge yellow">100</div>
<div class="lozenge blue">&nbsp;3%</div>
<div class="lozenge grey">60%</div>
<div class="lozenge red small">99%</div>
<div class="lozenge green small">45%</div>
<div class="lozenge yellow small">100</div>
@UltraSimplified
UltraSimplified / dabblet.html
Last active December 13, 2015 17:08
Lozenge trials
<!-- content to be placed inside <body>…</body> -->
<div class="lozenge red">99%</div>
<div class="lozenge green">45%</div>
<div class="lozenge yellow">100</div>
<div class="lozenge blue">&nbsp;3%</div>
<div class="lozenge grey">60%</div>
<div class="lozenge red small">99%</div>
<div class="lozenge green small">45%</div>
<div class="lozenge yellow small">100</div>