Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Matovu mtvbrianking

View GitHub Profile
@mtvbrianking
mtvbrianking / build-nested-tree.php
Last active Jul 28, 2020
Build nested tree from flat array.
View build-nested-tree.php
<?php
$categories = [
['id' => 1, 'name' => 'TV & Home Theater', 'parent_id' => null,],
['id' => 2, 'name' => 'Tablets & E-Readers', 'parent_id' => null,],
['id' => 3, 'name' => 'Computers', 'parent_id' => null,],
['id' => 4, 'name' => 'Laptops', 'parent_id' => 3,],
['id' => 5, 'name' => 'PC Laptops', 'parent_id' => 4,],
['id' => 6, 'name' => 'Macbooks (Air/Pro)', 'parent_id' => 4,],
['id' => 7, 'name' => 'Desktops', 'parent_id' => 3,],
@mtvbrianking
mtvbrianking / dynamic-charts.js
Last active Jul 6, 2020
Create dynamic charts using ChartJS
View dynamic-charts.js
<!DOCTYPE html>
<html>
<head>
<title>Dynamic Charts</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div id="wrapper" class="row"></div>
</div>
@mtvbrianking
mtvbrianking / redis.md
Created Jun 1, 2020
Install Redis on Xampp - Windows
@mtvbrianking
mtvbrianking / gitlab-ci.yml
Created Mar 28, 2020
Gitlab pages deploy swagger docs
View gitlab-ci.yml
# https://gitlab.com/mbrian/ects-ea-docs/-/ci/lint
# This file is a template, and might need editing before it works on your project.
image: node:10-alpine
# specify the location of the Open API Specification files within your project
# and the filename of the specification that you would like to display by default
variables:
DOCS_FOLDER: "specs"
SPEC_TO_DISPLAY: "rects.yaml"
@mtvbrianking
mtvbrianking / swagger editor setup.md
Created Mar 16, 2020
Swagger editor local setup
View swagger editor setup.md
@mtvbrianking
mtvbrianking / xampp_php7_xdebug.md
Created Jan 2, 2020 — forked from odan/xampp_php7_xdebug.md
Installing Xdebug for XAMPP
View xampp_php7_xdebug.md
View modules granted to a facility.md

Raw SQL

SELECT
    modules.name AS module,
    (CASE WHEN facility_module.facility_id IS NULL 
        THEN 0
        ELSE 1
    END) AS granted
FROM
@mtvbrianking
mtvbrianking / model-to-table-fields.php
Created Dec 25, 2019
Translate model to table fields
View model-to-table-fields.php
<?php
$tableModelMap = [
'orders' => null,
'customers' => 'customer',
];
$modelFields = [
'id',
'customer.id',
@mtvbrianking
mtvbrianking / delete-expired-files-recursive.php
Created Dec 22, 2019
Delete files older than a certain date.
View delete-expired-files-recursive.php
<?php
/**
* Delete files older than a given age recursively.
*
* @link https://www.php.net/manual/en/class.recursivedirectoryiterator.php#111142 Source
*
* @param string $dir Path to directory having the files
* @param int $age In seconds
* @param string $pattern File name pattern
@mtvbrianking
mtvbrianking / directory tree.php
Last active Dec 22, 2019
Read files in directory into array.
View directory tree.php
<?php
/**
* Get files in directory.
*
* @link https://www.php.net/manual/en/class.recursivedirectoryiterator.php#111142 Source
*
* @param string $dir Directory path
*
* @throws UnexpectedValueException
You can’t perform that action at this time.