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 );

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 / 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 / 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 / 0_reuse_code.js
Created February 6, 2014 19:47
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console