Skip to content

Instantly share code, notes, and snippets.

Brian Matovu mtvbrianking

View GitHub Profile
mtvbrianking /
Created Jan 2, 2020 — forked from odan/
Installing Xdebug for XAMPP
mtvbrianking /
Created Dec 21, 2019 — forked from nikic/
Post explaining why objects often use less memory than arrays (in PHP)

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:

View ObjectListener.php
namespace Fry;
use JsonStreamingParser\Listener;
* This implementation allows to process an object at a specific level
* when it has been fully parsed
class ObjectListener implements Listener
mtvbrianking /
Created Jun 26, 2019 — forked from nickbclifford/
How to automatically deploy code to a server using Travis CI

Auto-Deploying via Travis CI

Because Travis CI can automatically execute scripts after successfully (or unsuccessfully!) executing tests, it is an obvious choice for a deployment tool. In order to deploy to a Git repository on a remote server, the process generally is as follows:

  • Set up SSH keys
  • Add the server's copy of the repository as a Git remote
  • Push to the remote
  • SSH into the server and execute any installation/compilation/miscellaneous commands

Before even touching .travis.yml...


mtvbrianking /
Created May 8, 2019 — forked from ankurk91/
Ubuntu 18.04 - PHP development (php 7.2, MySQL 5.7, apache 2.4)
set -euo pipefail
# Ubuntu 18.04 dev Server
# Run like - bash
# Script should auto terminate on errors
echo -e "\e[96m Adding PPA \e[39m"
sudo add-apt-repository -y ppa:ondrej/apache2
View route-patterns.php
// Common Route Patterns
// Patterns
Route::pattern('id', '\d+');
Route::pattern('hash', '[a-z0-9]+');
Route::pattern('hex', '[a-f0-9]+');
Route::pattern('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
Route::pattern('base', '[a-zA-Z0-9]+');
Route::pattern('slug', '[a-z0-9-]+');
Route::pattern('username', '[a-z0-9_-]{3,16}');


When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a
mtvbrianking / .env.travis
Created Jun 15, 2018 — forked from gilbitron/.env.travis
Laravel 5 Travis CI config
View .env.travis
View Function.Array-Group-By.php
if (!function_exists('array_group_by')) {
* Groups an array by a given key.
* Groups an array into arrays by a given key, or set of keys, shared between all array members.
* Based on {@author Jake Zatecky}'s {@link array_group_by()} function.
* This variant allows $key to be closures.
View golang-create-read-write-delete-file.go
package main
import (
var path = "/Users/novalagung/Documents/temp/test.txt"
You can’t perform that action at this time.