Skip to content

Instantly share code, notes, and snippets.

View mtvbrianking's full-sized avatar

Brian Matovu mtvbrianking

View GitHub Profile
@mtvbrianking
mtvbrianking / array-of-objects-search.js
Last active May 27, 2021 06:34
Javascript array of objects search
"use strict";
var users = [
{
id: 1,
alias: "jdoe",
name: "John Doe"
},
{
id: 2,
@mtvbrianking
mtvbrianking / index.html
Created September 29, 2020 09:42
JavaScript Windows and iFrames
<!DOCTYPE html>
<html>
<head>
<title>Parent Window</title>
</head>
<body>
<label>Avatar</label>
<br/>
<input type="text" name="avatar" readonly>
<br/>
@mtvbrianking
mtvbrianking / build-nested-tree.php
Last active October 6, 2020 12:18
Build nested tree from flat array.
<?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 July 6, 2020 04:26
Create dynamic charts using ChartJS
<!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
Last active June 17, 2025 00:27
Install Redis on Xampp - Windows

Redis

Linux

jdoe@home-pc:~# apt-get install redis-server
jdoe@home-pc:~# systemctl enable [email protected]
jdoe@home-pc:~# apt-get update
jdoe@home-pc:~# apt-cache pkgnames | grep php7.4
jdoe@home-pc:~# apt install php7.4-redis
@mtvbrianking
mtvbrianking / gitlab-ci.yml
Created March 28, 2020 17:47
Gitlab pages deploy swagger docs
# 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 March 16, 2020 11:14
Swagger editor local setup
@mtvbrianking
mtvbrianking / xampp_php7_xdebug.md
Last active December 10, 2020 16:21 — forked from odan/xampp_php7_xdebug.md
Installing Xdebug for XAMPP
@mtvbrianking
mtvbrianking / modules granted to a facility.md
Last active December 31, 2019 09:16
Laravel explicit joins

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 December 25, 2019 21:37
Translate model to table fields
<?php
$tableModelMap = [
'orders' => null,
'customers' => 'customer',
];
$modelFields = [
'id',
'customer.id',