Skip to content

Instantly share code, notes, and snippets.

View cuonghuynh's full-sized avatar
🏠
Working from home

Cuong Huynh cuonghuynh

🏠
Working from home
View GitHub Profile
@cuonghuynh
cuonghuynh / gist:34c9e544bd43eac2dbb4ca92464fa839
Created September 12, 2018 05:19
Get memory usage in MB
echo (memory_get_usage() / 1024 / 1024, 2) . ' MB' . PHP_EOL;
@cuonghuynh
cuonghuynh / ArrayCollection.php
Created September 11, 2018 04:09
ArrayCollection
/**
* Class ArrayCollection
*
* @package Shopmacher\Base\FrontendBundle\Model
*/
class ArrayCollection implements CollectionInterface
{
/**
* @var array
*/
@cuonghuynh
cuonghuynh / gist:f2debb764521933aeec0c1fd99b065f5
Created September 10, 2018 11:29
Webpack compile, Module not found: Error: Cannot resolve module 'pace'
# Fix it!
# in webpack/config.js
resolve: {
alias: {
pace: 'pace-js'
}
}
# in page.js
@cuonghuynh
cuonghuynh / gist:9634f31aab49bb9c9af924d150c7b794
Last active September 7, 2018 09:43
Repository and Manager
Repository has only responsibility to QUERY (R) one or all entites by a specific set criteria
Manager contains business code to create, update, delete entities (CUD). It ships the repository inside.
@cuonghuynh
cuonghuynh / gist:3e405d2fd205e6c71d610cfcf025027f
Created September 7, 2018 09:37
Why we should write test to coverage our code as much as posible
Unit-test: You will figure out missing logic, wrong types returned or params ... things which you can not think when programming the business code
Behat: It's really a supervisor for your website, which make sure all fuctions work well after adding new features.
@cuonghuynh
cuonghuynh / gist:7b36633bcc3b7c4153d86fe3084925f0
Created September 7, 2018 03:11
How to find out what 's 503 service unavailable causing with log message AH01067: Failed to read FastCGI header
Normally 503 service unavailable errors come from the server run out of memory.
Case: It occurs only on a some pages
==> Try to find the code which take the most memory (pdf, importing, ...)
Case: Whole site down
==> Check memory now by some tools such as: top, htop...
Restart php-fpm
@cuonghuynh
cuonghuynh / gist:b23b9aacec63ad65591cd06a4ebed190
Created September 6, 2018 03:44
Vagrant was unable to mount VirtualBox shared folders. This is usually because the filesystem "vboxsf" is not available. This filesystem is made available via the VirtualBox Guest Additions and kernel module.
Install vagrant-vbguest plugin
> vagrant plugin install vagrant-vbguest
@cuonghuynh
cuonghuynh / gist:9192033be6d6ec62cb103b743dc49921
Created September 5, 2018 09:44
Restart php-fpm in php7.0
>/etc/init.d/php7.0-fpm restart
@cuonghuynh
cuonghuynh / gist:3eeb53ca8c9df537235207604c273f53
Created September 5, 2018 08:07
Composer: how to know a package by what other package is required
> composer depends [package-name]
@cuonghuynh
cuonghuynh / gist:dcbce40be59a538d3a12fe6d9efe0769
Created September 5, 2018 06:51
Git discard your changes not staged on local by command
# check status
> git status
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: hello.html
# discard changes
> git checkout hello.html