Skip to content

Instantly share code, notes, and snippets.

View quangpd's full-sized avatar
💭
I may be slow to respond.

Pham Quang quangpd

💭
I may be slow to respond.
View GitHub Profile
<?php
/*
* Danh sach tat ca controller va method trong HMVC CodeIgniter
* modules/*
* application/controllers/*
*/
function structure()
{
$hmvc = array();
foreach(glob(APPPATH . 'controllers/*') as $controller)
/* Tính tuổi */
function calculateAge (birthDate, otherDate) {
birthDate = new Date(birthDate);
otherDate = new Date(otherDate);
var years = (otherDate.getFullYear() - birthDate.getFullYear());
if (otherDate.getMonth() < birthDate.getMonth() || otherDate.getMonth() == birthDate.getMonth() && otherDate.getDate() < birthDate.getDate()) {
years--;
}
return years;
}
1. Độ mạnh của mật khẩu
^(?=.*[A-Z].*[A-Z])(?=.*[!@#$&*])(?=.*[0-9].*[0-9])(?=.*[a-z].*[a-z].*[a-z]).{8}$
Kiểm tra độ mạnh của một mật khẩu thường là chủ quan nên không có câu trả lời chính xác tuyệt đối. Nhưng tôi cảm thấy đoạn regex này là một điểm khởi đầu tuyệt vời nếu bạn không muốn phải viết riêng hàm kiểm tra độ mạnh mật khẩu của bạn từ đầu.
2. Mã màu Hex
\#([a-fA-F]|[0-9]){3, 6}
Mã màu hex rất phố biến trong lĩnh vực phát triển web. Đoạn regex này có thể được sử dụng để lấy mã hex phù hợp từ chuỗi bất kỳ cho bất cứ mục đích nào.
<?php
/**
*
*/
class ToHop
{
public $a = array();
public $n;
public $k;
TAB CLOSEALLOTHERS
SET !LOOP -9999999
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_PAGE 10
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0.5
URL GOTO=http://addmefast.com/free_points/facebook_likes
TAG POS=1 TYPE=DIV ATTR=TXT:Like
TAB T=2
Sub MergeSheets()
Const NHR = 1
Dim MWS As Worksheet
Dim AWS As Worksheet
Dim FAR As Long
Dim LR As Long
Set AWS = ActiveSheet
# Upgrade your server’s php installation from 5.5.x to 5.6.x on Ubuntu 14.04 LTS
sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6 php5.6-cli php5.6-common php5.6-curl php5.6-dev php5.6-gd php5.6-intl php5.6-json php5.6-ldap php5.6-mbstring php5.6-mcrypt php5.6-memcache php5.6-memcached php5.6-mysql php5.6-pgsql php5.6-readline php5.6-sqlite php5.6-xml php5.6-xsl libzip4 php5.6-zip
sudo apt-get update && apt-get upgrade
sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php5-compat
sudo apt-get update
@quangpd
quangpd / Setup xampp multi PHP version
Created April 23, 2019 07:08
Setup xampp multi PHP version
1. Install XAMPP with the PHP Version you want to run mainly, e.g. PHP 7.2 => resides by default in Installpath\xampp\php
2. Copy other php Versions in Installpath\xampp\, eg PHP 5.4 in => Installpath\xampp\php5
If you are lazy like me, just grab the other php folder from old xampp installations, => beneficial since the used dlls are already in the right place
3 Make sure every php version on her own has a working php.ini.
use individual error logs per version:
error_log="D:\xampp\php5\logs\php_error_log"
error_log="D:\xampp\php\logs\php_error_log"
@quangpd
quangpd / unicodeTH2unicodeDS.php
Created January 20, 2020 17:31
Unicode Tổ hợp 2 Dựng sẵn
/**
* Unicode Tổ hợp 2 Dựng sẵn
* @param [type] $unicode_str [description]
* @return [type] [description]
*/
function unicodeTH2unicodeDS($unicode_str)
{
$unicode_str = preg_replace("/\x{0065}\x{0309}/u", "ẻ", $unicode_str); # ẻ
$unicode_str = preg_replace("/\x{0065}\x{0301}/u", "é", $unicode_str); # é
$unicode_str = preg_replace("/\x{0065}\x{0300}/u", "è", $unicode_str); # è