Skip to content

Instantly share code, notes, and snippets.

View codescribblr's full-sized avatar

Jonathan Wadsworth codescribblr

View GitHub Profile
@codescribblr
codescribblr / enqueue.php
Last active April 29, 2022 13:16 — forked from ricardobrg/enqueue.php
Enqueue scripts in WordPress with defer or async
<?php
// This code is based in Mathew Horne blog post: https://matthewhorne.me/defer-async-wordpress-scripts/
//function to add async attribute
function add_async_attribute( $tag, $handle ) {
$scripts_to_async = array( 'my-js-handle-async', 'another-handle-async' );
//check if this script is in the array
if ( in_array( $handle, $scripts_to_async ) ) {
//return with async
return str_replace( ' src', ' async="async" src', $tag );
@codescribblr
codescribblr / fabfile.py
Created February 20, 2020 14:40
Example fabfile for Django deployment
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2012 Zuza Software Foundation
#
# This file is part of Pootle.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or

Lsyncd Technical Session

So what is lsyncd?

Lsyncd is a tool used to keep a source directory in sync with other local or remote directories. It is a solution suited keeping directories in sync by batch processing changes over to the synced directories.

When would we use lsyncd?

So the generic use case is to keep a source directory in sync with one or more local and remote directories.

@codescribblr
codescribblr / Nginx Wordpress Load Balanced Config.txt
Last active June 16, 2018 00:07
Nginx Wordpress Load Balanced Config
This setup assumes that there is a valid ssl setup on both servers (same certificate on both).
It also assumes that there is a 3rd server setup to handle mysql all by itself.
The web01 server is the main server. It will handle all the files and wordpress updates. The only writes to the db will be done from this server.
All requests to wp-admin will be handled by this one server.
Web02 is simply a carbon copy (via lsyncd).
db01 is a mysql only server that handles the db remotely.
The load balancer from Digital Ocean serves traffic to both/all servers. It forwards all traffic from port 80 and 443 to the same ports on the 2 web machines.
@codescribblr
codescribblr / README.MD
Last active January 27, 2019 15:02
Setup Webmin & Virtualmin on Ubuntu 16.04 LTS

ssh root@your_server_ip

adduser ubuntu Enter New Password Enter 6x

usermod -aG sudo ubuntu

ON LOCAL MACHINE

ssh-copy-id ubuntu@your_server_ip

@codescribblr
codescribblr / ubuntu-server-setup-16.04.md
Last active June 6, 2018 14:26 — forked from marcuslilja/ubuntu-server-setup-16.04.md
Server setup for Ubuntu 16.04 on Digital Ocean

Server setup for Ubuntu 16.04 on Digital Ocean

The setup installs the following software:

  • Nginx
  • MySQL
  • PHP
  • Node
  • Composer
@codescribblr
codescribblr / functions.php
Last active June 29, 2017 01:47
Theme overrides for Bridge WooCommerce theme.
/**
*Reduce the strength requirement on the woocommerce password.
*
* Strength Settings
* 3 = Strong (default)
* 2 = Medium
* 1 = Weak
* 0 = Very Weak / Anything
*/
add_filter( 'woocommerce_min_password_strength', 'jrwdev_reduce_woocommerce_min_strength_requirement' );
@codescribblr
codescribblr / php-html-css-js-minifier.php
Created March 11, 2017 14:58 — forked from taufik-nurrohman/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
// Based on <https://github.com/mecha-cms/extend.minify>
define('MINIFY_STRING', '"(?:[^"\\\]|\\\.)*"|\'(?:[^\'\\\]|\\\.)*\'');
define('MINIFY_COMMENT_CSS', '/\*[\s\S]*?\*/');
define('MINIFY_COMMENT_HTML', '<!\-{2}[\s\S]*?\-{2}>');
define('MINIFY_COMMENT_JS', '//[^\n]*');
define('MINIFY_PATTERN_JS', '\b/[^\n]+?/[gimuy]*\b');
define('MINIFY_HTML', '<[!/]?[a-zA-Z\d:.-]+[\s\S]*?>');
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Which Browser?</title>
</head>
<body>
<p>You are using <span id="browser"></span> <span id="version"></span> on <span id="os"></span></p>
<script type="text/javascript" src="browserdetect.js"></script>
<script type="text/javascript">
@codescribblr
codescribblr / maintenance.html
Last active October 18, 2016 18:47
Maintenance Landing Page
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Maintenance Underway!</title>
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
html{background:#f9f9f9}
body{background:#fff; color:#333; font-family:sans-serif; margin:2em auto; padding:1em 2em 2em; -webkit-border-radius:3px; border-radius:3px; border:1px solid #dfdfdf; max-width:750px; text-align:center;}
#error-page{margin-top:50px}