Skip to content

Instantly share code, notes, and snippets.

@temperatio
temperatio / default.vcl_PREFACE.md
Created March 5, 2021 23:43 — forked from fevangelou/default.vcl_PREFACE.md
The perfect Varnish configuration for Joomla, WordPress & other CMS based websites

The perfect Varnish configuration for Joomla, WordPress & other CMS based websites

IMPORTANT: Read this before implementing one of the configuration files below (for either Varnish 3.x or 4.x+).

USE: Replace the contents of the main Varnish configuration file located in /etc/varnish/default.vcl (root server access required - obviously) with the contents of the configuration you'll use (depending on your Varnish version) from the 2 examples provided below.

IMPORTANT: The following setup assumes a 180 sec (3 minute) cache time for cacheable content that does not have the correct cache-control HTTP headers. You can safely increase this to 300 sec (or more) for less busier sites or drop it to 60 sec or even 30 sec for high traffic sites.

This configuration requires an HTTP Header and a user cookie to identify if a user is logged in a site, in order to bypass caching overall (see how it's done for Joomla & WordPress). If your CMS provides a way to add these two requirements, then you can use this configurati

@temperatio
temperatio / functions.php
Created February 10, 2021 11:24
Limit Simple history days
<?php
// Clear items that are older than a 7 days (i.e. keep only the most recent 7 days in the log)
add_filter( "simple_history/db_purge_days_interval", function( $days ) {
$days = 7;
return $days;
} );
@temperatio
temperatio / gulpfile.js
Created June 22, 2020 08:19 — forked from jasonyingling/gulpfile.js
A simple gulpfile setup for modern JavaScript and SASS
const { src, dest, watch } = require('gulp');
const sass = require('gulp-sass');
const minifyCSS = require('gulp-csso');
const babel = require('gulp-babel');
const concat = require('gulp-concat');
const browserSync = require('browser-sync').create();
function css() {
return src('./sass/*.scss', { sourcemaps: true })
.pipe(sass())
@temperatio
temperatio / wcm_change_restrict_content.php
Created June 19, 2020 15:31
[Change restricted post message] #wordpress #woocommerce #membership
<?php // only copy this if needed
/**
* Changes excerpts displayed on restricted membership content to use 120 words
* instead of WordPress default.
*
* @since 1.6.0
* @param string $content HTML content displayed for the post
* @param bool $restricted Whether the content is restricted
* @param string $message The restriction message applied, could be empty string
@temperatio
temperatio / block.js
Last active June 18, 2020 08:41 — forked from lkhedlund/block.js
Gutenberg: Custom Block Category #gutenberg #wordpress
registerBlockType( 'loomo/yoshi-cookies', {
category: 'mario-blocks', // Block category

Paprika doesn't have their API documented, so this is me reverse-engineering it from an Android device

Live Demo

https://knowing-grain.glitch.me/

Sync

HTTP BASIC auth (emoji shrug), and send a GET to:

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS `survey_001_models_from_tables` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `survey_001_models_from_tables` ;
-- -----------------------------------------------------
-- Table `survey_001_models_from_tables`.`organizations`
-- -----------------------------------------------------
#!/bin/bash
#############################################################
# Script para convertir un repositorio de git en compartido #
#############################################################
if [ "$(id -u)" != "0" ]; then
echo "Este script hay que ejecutarlo con permisos de root"
exit 1
fi
if [ "$#" -ne 1 ]; then
echo "Sólo puede haber un parametro"
@temperatio
temperatio / filebackup.sh
Created March 16, 2018 08:44
Backup a given path and upload to remote server
#!/bin/sh
# Create a db dump and upload it to another server
#
BACK_SERVER='xxx.xxx.xxx.xxx'
BACK_SERVER_PORT='22'
BACK_SERVER_USER='user'
# store current date
@temperatio
temperatio / dbbackup.sh
Last active March 16, 2018 08:45
Mysql backup and upload to remote server
#!/bin/sh
# Create a db dump and upload it to another server
#
BACK_SERVER='xxx.xxx.xxx.xxx'
BACK_SERVER_PORT='22'
BACK_SERVER_USER='user'
# Database credentials
DB_NAME='database'