Skip to content

Instantly share code, notes, and snippets.

View tmugford's full-sized avatar

Tristan Mugford tmugford

View GitHub Profile
@markhowellsmead
markhowellsmead / custom_capability.php
Last active June 26, 2019 15:08
WordPress: how to use “do_not_allow” with map_meta_cap in Multisite to restrict custom capability to non-super-admins
<?php
function customCapabilityRules($caps, $cap, $user_id, $args)
{
$deny = array();
switch ($cap) {
case 'my_custom_capability':
if( is_super_admin() ){
$deny[] = 'my_custom_capability';

NativeScript LiveSync with Console Output with iOS Simulator

NativeScript LiveSync does not currently emit console output (via console.log()) via the CLI:

$ tns livesync ios --emulator —watch

There's a couple of ways to make this work. In both cases, you'll need the hash for the iOS simulator/device you're targeting:

$ instruments -s devices

@paulirish
paulirish / what-forces-layout.md
Last active July 22, 2024 06:32
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@louim
louim / uploads.yml
Last active December 23, 2022 14:20
Drop-in playbook for Trellis to push and pull uploads from the server to your local machine.
---
- name: Sync uploads between environments
hosts: web
remote_user: "{{ web_user }}"
vars:
project: "{{ wordpress_sites[site] }}"
project_root: "{{ www_root }}/{{ site }}"
tasks:
@bastianallgeier
bastianallgeier / controllers--contact.php
Created October 1, 2014 19:36
Plain contactform example for Kirby 2
<?php
return function($site, $pages, $page) {
$alert = null;
if(get('submit')) {
$data = array(
'name' => get('name'),
@mitchwongho
mitchwongho / Docker
Last active June 26, 2024 07:28
Docker 'run' command to start an interactive BaSH session
# Assuming an Ubuntu Docker image
$ docker run -it <image> /bin/bash
@ekristen
ekristen / check_docker_container.sh
Last active July 15, 2024 09:29
Bash Script for Nagios to Check Status of Docker Container
#!/bin/bash
# Author: Erik Kristensen
# Email: erik@erikkristensen.com
# License: MIT
# Nagios Usage: check_nrpe!check_docker_container!_container_id_
# Usage: ./check_docker_container.sh _container_id_
#
# Depending on your docker configuration, root might be required. If your nrpe user has rights
# to talk to the docker daemon, then root is not required. This is why root privileges are not
@betweenbrain
betweenbrain / gist:9239337
Created February 26, 2014 21:48
PHP PDO Fetch Array of Objects Indexed on Column Value
<?php
$sql = "SELECT id, name FROM `users`";
try
{
$query = $pdo->prepare($sql);
$query->execute();
}
@DWboutin
DWboutin / Merge wp_query
Created February 7, 2014 14:17
Merge 2 WP_Query()
<?php
$query1 = new WP_Query($arg1);
$query2 = new WP_Query($arg2);
$query = new WP_Query();
$query->posts = array_merge( $query1->posts, $query2->posts );
// we also need to set post count correctly so as to enable the looping
@Pephers
Pephers / heredoc-function.php
Last active September 26, 2023 17:55
How to call a PHP function inside a Heredoc.
<?php
$cb = function ($fn) {
return $fn;
};
echo <<<HEREDOC
Hello, {$cb(ucfirst('world'))}
HEREDOC;