Skip to content

Instantly share code, notes, and snippets.

Brian Matovu mtvbrianking

Block or report user

Report or block mtvbrianking

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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
@mtvbrianking
mtvbrianking / delete-expired-files.php
Last active Dec 22, 2019
Delete files older than a certain date.
View delete-expired-files.php
<?php
/**
* Delete files older than a given age.
*
* @param string $dirPath Path to directory having the files
* @param int $maxAge In seconds
* @param string $pattern File name pattern
*
* @return array Deleted files
@mtvbrianking
mtvbrianking / objects_arrays.md
Created Dec 21, 2019 — forked from nikic/objects_arrays.md
Post explaining why objects often use less memory than arrays (in PHP)
View objects_arrays.md

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@mtvbrianking
mtvbrianking / laravel eloquent query debug.md
Last active Nov 7, 2019
Laravel debug (dump) database queries
View laravel eloquent query debug.md

Laravel debug database queries

Raw SQL

SELECT
  users.name AS staff,
  facilities.name AS facility
FROM
  users
You can’t perform that action at this time.