Skip to content

Instantly share code, notes, and snippets.

View mtvbrianking's full-sized avatar

Brian Matovu mtvbrianking

View GitHub Profile
@mtvbrianking
mtvbrianking / setup-apache-virtual-hosts.md
Last active December 4, 2021 09:13
Apache Virtual Host

sudo vi /etc/apache2/sites-available/wpapers.local.conf

<VirtualHost *:80>
    ServerName wpapers.local
    ServerAlias www.wpapers.local
    ServerAdmin info@wpapers.local

    DocumentRoot "/var/www/html/wpapers/public"
    <Directory "/var/www/html/wpapers/public">
@mtvbrianking
mtvbrianking / XMLDomDocument.php
Last active July 3, 2018 18:50
Validate XML against XSD - Using DomDocument
<?php
/**
* Class XMLDomDocument
* Usage:
* ```
* $doc = new XMLDomDocument();
* $doc->validate($xml, $xsd);
* ```
* @link ValidatingXML https://medium.com/@Sirolad/validating-xml-against-xsd-in-php-5607f725955a
@mtvbrianking
mtvbrianking / XMLDomReader.php
Created July 3, 2018 18:52
Validate XML against XSD - Using XML Reader
<?php
/**
* Class XmlDomReader
*/
class XMLDomReader
{
/**
* XML Reader
@mtvbrianking
mtvbrianking / JsonXMLElement.php
Last active September 12, 2018 05:10
Convert XML to Array
<?php
/**
* Class JsonXMLElement
* @link https://hakre.wordpress.com/2013/07/09/simplexml-and-json-encode-in-php-part-i/
*/
class JsonXMLElement extends SimpleXMLElement implements JsonSerializable
{
/**
@mtvbrianking
mtvbrianking / JsonSimpleXMLElementDecorator.php
Last active July 14, 2018 07:39
Convert XML to Array - Using a decorator
<?php
/**
* Class JsonSimpleXMLElementDecorator
*
* @link https://hakre.wordpress.com/2013/07/09/simplexml-and-json-encode-in-php-part-i/
*
* Implement JsonSerializable for SimpleXMLElement as a Decorator
*/
class JsonSimpleXMLElementDecorator implements JsonSerializable
@mtvbrianking
mtvbrianking / dustjs-demo.html
Last active August 3, 2018 20:48
DustJS demo
<!DOCTYPE html>
<html>
<head>
<title>DustJS</title>
<!-- http://www.dustjs.com/docs/api/ -->
<!-- http://www.dustjs.com/guides/rendering/ -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<style type="text/css">
body {
margin: 50px;
@mtvbrianking
mtvbrianking / dustjs-helper.js
Last active August 3, 2018 22:19
Custom dustjs helpers
// https://github.com/linkedin/dustjs-helpers
// https://github.com/rodw/common-dustjs-helpers
dust.helpers.slug = function (chunk, context, bodies, params) {
//replace all special characters | symbols with a space
params.value = params.value.replace(/[`~!@#$%^&*()_\-+=\[\]{};:'"\\|\/,.<>?\s]/g, ' ').toLowerCase();
// trim spaces at start and end of string
params.value = params.value.replace(/^\s+|\s+$/gm, '');
// replace space with dash/hyphen
params.value = params.value.replace(/\s+/g, '-');
@mtvbrianking
mtvbrianking / array-group-by-adv.php
Last active August 7, 2018 20:35
Group database records
<?php
$resources = array(
[
'parent_id' => 1,
'parent' => 'Account',
'module_id' => 11,
'module' => 'User',
'enabled' => true,
],
@mtvbrianking
mtvbrianking / array-group-by-adv-ii.php
Last active August 31, 2018 17:40
Group database records - depth 3
<?php
$resources = array(
[
'parent_id' => 1,
'parent' => 'Account',
'module_id' => 11,
'module' => 'User',
'function_id' => 111,
'function' => 'View',
'enabled' => true,
@mtvbrianking
mtvbrianking / update-maria-db.md
Last active August 25, 2018 16:00
Update Maria DB - Xampp

Xampp upgrade MariaDB

Shutdown Xampp (Apache, and MySQl)

...$cd /c/xampp

Download desired version of MariaDB

/c/xampp$ wget http://ftp.hosteurope.de/mirror/archive.mariadb.org//mariadb-10.2.10/winx64-packages/mariadb-10.2.10-winx64.zip