Skip to content

Instantly share code, notes, and snippets.

View gchtr's full-sized avatar

Lukas Gächter gchtr

View GitHub Profile
@marcwieland95
marcwieland95 / Oembed.php
Last active May 6, 2022 18:36
WordPress oEmbed handler to integrate video and audio players from SRG (including SRF, RSI, RTS and RTR)
wp_embed_register_handler('srg', '#https?:\/\/(?:www\.|player\.)?(srf|rsi|rts|rtr)\.ch\/.+(detail|video|audio).((?:.{8}-.{4}-.{4}-.{4}-.{12})|\d*)(?:.startTime=(\d*)|.*)#i', 'srgEmbedHandler');
function srgEmbedHandler($matches, $attr, $url, $rawattr)
{
return sprintf(
'<iframe width="560" height="315" src="https://%1$s.ch/play/embed?urn=urn:%1$s:%2$s:%3$s%4$s" allowfullscreen allow="encrypted-media"></iframe>',
esc_attr($matches[1]),
esc_attr($matches[2]) === 'audio' ? 'audio' : 'video',
esc_attr($matches[3]),
array_key_exists(4, $matches) ? esc_attr('&startTime=' . $matches[4]) : '',
@rhukster
rhukster / sphp.sh
Last active March 30, 2024 10:41
Easy Brew PHP version switching (Now moved to https://github.com/rhukster/sphp.sh)
#!/bin/bash
# Creator: Phil Cook
# Modified: Andy Miller
#
# >>> IMPORTANT: Moved to: https://github.com/rhukster/sphp.sh
# >>> Kept here for legacy purposes
#
osx_major_version=$(sw_vers -productVersion | cut -d. -f1)
osx_minor_version=$(sw_vers -productVersion | cut -d. -f2)
osx_patch_version=$(sw_vers -productVersion | cut -d. -f3)
@neverything
neverything / delete-generated-wp-images.sh
Last active March 22, 2023 15:33
Sometimes you only want the original images and not the generated sizes <name-of-image>-150x150.png. This command deletes all the files with a certain pattern in the file name. See https://silvanhagen.com/wordpress-delete-generated-images/ for more details.
# List the files
find -E . -type f -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)"
# DANGER! Delete the files
find -E . -type f -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)" -delete
# If your OS doesn't support -E (tip from https://github.com/quasel)
find . -type f -regextype posix-extended -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)"
# Improved with the help of https://github.com/markhowellsmead
@justintadlock
justintadlock / parent-theme-mod-fallback.php
Last active June 20, 2021 22:38
Get theme mods that fall back to the stored parent theme mod if child theme is active.
<?php
/**
* The purpose of this code is to show how you can use theme mods that will fall back to
* the already-set mods of the parent theme. So, when a child theme is active, the code
* checks, in the following order: 1) child theme mod, 2) parent theme mod, 3) default.
*/
function jt_get_theme_mod( $name, $default = false ) {
if ( is_child_theme() )
@neverything
neverything / comopser-wp-cli.md
Last active December 7, 2021 07:42
Install composer and wp-cli on cyon.ch hostings with SSH access.

Cyon.ch/Hostpoint - Install composer & wp-cli

SSH into your server and stay in the home directory of the user. Check if you have a bin directory in your user directory already, in case you do, omit the mkdir bin.

Use bin folder in $HOME for user scriptsr

For the commands to be loaded from the bin directory run echo "export PATH=$HOME/bin:$PATH" >> ~/.bashrc. For the new config to be used run source ~/.bashrc or close and reopen your SSH session.

Composer

@johnbillion
johnbillion / wp_mail.md
Last active June 3, 2024 13:31
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail

@paulirish
paulirish / what-forces-layout.md
Last active July 17, 2024 00:51
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
@paulirish
paulirish / bling.js
Last active July 3, 2024 20:45
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@nishantmodak
nishantmodak / nginx.conf.default
Last active May 26, 2024 19:29
Default Nginx Conf
#user nobody;
#Defines which Linux system user will own and run the Nginx server
worker_processes 1;
#Referes to single threaded process. Generally set to be equal to the number of CPUs or cores.
#error_log logs/error.log; #error_log logs/error.log notice;
#Specifies the file where server logs.