Skip to content

Instantly share code, notes, and snippets.

View tuanpht's full-sized avatar
💭
200 OK!

Pham Tuan tuanpht

💭
200 OK!
View GitHub Profile
@tuanpht
tuanpht / .php_cs
Created June 18, 2018 07:10
PHP-CS-Fixer configuration for PHPCS Framgia standard
<?php
$finder = PhpCsFixer\Finder::create()
// ->in(__DIR__ . '/config')
// ->in(__DIR__ . '/tests')
->in(__DIR__ . '/app');
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
@tuanpht
tuanpht / react-hoc-authorization.js
Last active April 26, 2018 10:16
React HOC authentication, authorization
// Ref: https://hackernoon.com/role-based-authorization-in-react-c70bb7641db4
// Demo: https://codesandbox.io/s/n1n5jl374p
import React, { Fragment } from 'react';
import { render } from 'react-dom';
import { BrowserRouter as Router, Route } from 'react-router-dom';
function getCurrentUser() {
// return null; // Not login
return {
@tuanpht
tuanpht / class-custom-walker-page-dropdown.php
Last active October 17, 2017 04:37
Custom wp_dropdown_pages walker class
<?php
class Custom_Walker_PageDropdown extends Walker_PageDropdown {
/**
* Starts the element output.
* @param array|string $args {
*
* @type int|string|callable $selected Value of the option that should be selected.
* Default 0.
@tuanpht
tuanpht / config.diff
Created April 5, 2017 03:08 — forked from westonruter/config.diff
Using colordiff for my svn diff command (set in ~/.subversion/config)
@@ -28,7 +28,7 @@
### Set diff-cmd to the absolute path of your 'diff' program.
### This will override the compile-time default, which is to use
### Subversion's internal diff implementation.
-# diff-cmd = diff_program (diff, gdiff, etc.)
+diff-cmd = colordiff
### Set diff3-cmd to the absolute path of your 'diff3' program.
### This will override the compile-time default, which is to use
### Subversion's internal diff3 implementation.
@tuanpht
tuanpht / phpcs-subl.md
Last active October 17, 2017 04:37
Using PHPCS with Sublime Text
<?php
$text = $argv[1];
$postdata = http_build_query([
'q' => $text,
]);
$opts = [
'http' => [
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
@tuanpht
tuanpht / angularjs-providers-explained.md
Last active August 26, 2016 07:21 — forked from demisx/angularjs-providers-explained.md
AngularJS Providers: Constant/Value/Service/Factory/Decorator/Provider
Provider Singleton Instantiable Configurable
Constant Yes No No
Value Yes No No
Service Yes No No
Factory Yes Yes No
Decorator Yes No? No
Provider Yes Yes Yes

Constant