Skip to content

Instantly share code, notes, and snippets.

View mtvbrianking's full-sized avatar

Brian Matovu mtvbrianking

View GitHub Profile
@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 / 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 / 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

@mtvbrianking
mtvbrianking / nested-panels.html
Created August 31, 2018 14:12
Bootstrap nested panels (accordion)
<!DOCTYPE html>
<html lang='en' class=''>
<head>
<meta charset='UTF-8'>
<meta name="robots" content="noindex">
<link rel='stylesheet' href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css'>
</head>
<body>
@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 / 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 / laravel-passport-via-js.md
Last active September 15, 2018 20:37
Laravel Passport OAuth2 consume own API via Javascript

PHP Curl

curl -X GET \
  http://localhost:8000/api/user \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImY3OTllMTZiODAzZjk4ZmU4MGQyZWYzYWFhM2IwODdmZGYwNjZjNmU1MzU2OWMzZjJjMmQ2ZDMzZGZkZmM1M2NjZmFiZTM4MmExMDZlZTczIn0.eyJhdWQiOiIxIiwianRpIjoiZjc5OWUxNmI4MDNmOThmZTgwZDJlZjNhYWEzYjA4N2ZkZjA2NmM2ZTUzNTY5YzNmMmMyZDZkMzNkZmRmYzUzY2NmYWJlMzgyYTEwNmVlNzMiLCJpYXQiOjE1MzcwMTY2MDcsIm5iZiI6MTUzNzAxNjYwNywiZXhwIjoxNTY4NTUyNjA2LCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.Dy1WJQAHuOJgTEZ0SEJUd09_nO27IW7WpahhaFPDB7gOS5xqps3Cg3lWi663HuZ_8Ik4iXZ5zoLnoFc-0IQAEk86ZZ29EVOdhYN1LUBe4v8kyBc8JgJ5dMamY2dAtwCg_qL4ptxv0gyoZfV2Ot9lxEI9ZbP4vYHGef9o9RKorug8H3J9dm6pIHP6Bd33pO6AaLsxBNedDOAN20oAyhRRbAaeGoFwFyIp208M2Bpnc_Pku1xZUJjXZ-NVBNmpTB69llMti3qjBAHPPFo1br3-2NhGpGwzoYf1ClYrAiBxT58HZAtVIhQJB76fBtqarnObqoitVrTcxlLmUcNnnlTUUKoaupoFkpK-GzjZu-3-ZcJuijK8ZWl2FvhPm_JSRrmNZDtn3D7QMokBz8j-3VwlRB3r6ssJhGj-WzogwyBLTjP_08i2sAKxJStnAYk8SjH5DrUPyxRXiJqcfyUGs2qPZk28uZ38g2y7DsA9XQi-u8KlahRuCbhcGyHmOCQ