Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Bensmann thomasmb

View GitHub Profile
@thomasmb
thomasmb / nginx-helper-purge.php
Created Apr 10, 2020
WP Nginx helper purge cache on multiple domains
View nginx-helper-purge.php
<?php
/**
* When the site admin is hosted on a different domain, this filter can be used to
* purge the cache of the exposed site
*/
add_filter( 'rt_nginx_helper_purge_url', function( $url ){
$find = 'admin-domain.com';
$replace = 'live-domain.com';
@thomasmb
thomasmb / jquery-resize-event.js
Last active Nov 1, 2019
jQuery resizestart and resizeend events
View jquery-resize-event.js
var resizeTimer = false;
$(window).on('resize', function(e) {
if( !resizeTimer ) {
$(window).trigger('resizestart');
}
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
@thomasmb
thomasmb / gform_tabindex.php
Created Nov 9, 2017
Remove tabindex from Gravity Forms
View gform_tabindex.php
<?php
add_filter( 'gform_tabindex', '__return_false' );
@thomasmb
thomasmb / gulpfile.js
Created Aug 26, 2014
Filtering empty files in gulp
View gulpfile.js
var gulp = require('gulp'),
filter = require('gulp-filter'),
changed = require('gulp-changed'),
imagemin = require('gulp-imagemin')
var paths = {
images: './source/img/**/*'
};
// Process images
@thomasmb
thomasmb / varnish-https-cache.vcl
Created Aug 15, 2014
Sperate varnish cache for HTTPS
View varnish-https-cache.vcl
sub vcl_hash {
# … Other vcl_hash stuff
# If this is a HTTPS request, keep it in a different cache
if (req.http.X-Forwarded-Proto) {
hash_data(req.http.X-Forwarded-Proto);
}
@thomasmb
thomasmb / mysql_pwd_reset.sh
Created Aug 12, 2014
A shell script for resetting the root MySQL password
View mysql_pwd_reset.sh
# Please confirm that you want to reset the MySQL passwords
CONFIRM="n"
echo -n "Please confirm MySQL password reset. Continue? (y/N): "
read -n 1 CONFIRM_INPUT
if [ -n "$CONFIRM_INPUT" ]; then
CONFIRM=$CONFIRM_INPUT
fi
echo
View gist:b67680a04ae75bc301b7
WebFontConfig = {
google: { families: [ 'PT+Sans:400,400italic:latin', 'Ubuntu:300,400,500:latin' ] }
};
var cb = function() {
var wf = document.createElement('script');
wf.src = '//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
@thomasmb
thomasmb / form.js
Created Jul 1, 2014
Replacement for the Akismet jQuery code
View form.js
document.addEventListener("DOMContentLoaded", function(event) {
var ak_js = document.getElementById( 'ak_js' );
if( !ak_js ){
ak_js = document.createElement( 'input' );
ak_js.type = 'hidden';
ak_js.name = ak_js.id = 'ak_js';
}
else {
ak_js.parentNode.removeChild( ak_js );
@thomasmb
thomasmb / add-stylesheet-once.js
Created Oct 24, 2013
A JS function used to add a stylesheet to the HTML head tag, but only once ( in this cases it uses jQuery )
View add-stylesheet-once.js
function add_stylesheet_once( url ){
$head = $('head');
if( $head.find('link[rel="stylesheet"][href="'+url+'"]').length < 1 )
$head.append('<link rel="stylesheet" href="'+ url +'" type="text/css" />');
}
@thomasmb
thomasmb / ajax-gist-embed.js
Created Oct 24, 2013
Loading gist embeds dynamically
View ajax-gist-embed.js
// … find all gist scripts inside the ajax container
var $gists = $ajax_container.find('script[src^="https://gist.github.com/"]');
// if gist embeds are found
if( $gists.length ){
// update each gist
$gists.each(function(){
// we need to store $this for the callback
You can’t perform that action at this time.