Skip to content

Instantly share code, notes, and snippets.

@khangvm53
khangvm53 / youtube_id_regex.php
Created April 23, 2022 10:22 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
<?php
//$attribute = 'a:2:{s:8:"pa_color";a:6:{s:4:"name";s:8:"pa_color";s:5:"value";s:0:"";s:8:"position";s:1:"2";s:10:"is_visible";s:1:"1";s:12:"is_variation";s:1:"1";s:11:"is_taxonomy";s:1:"1";}s:7:"pa_size";a:6:{s:4:"name";s:7:"pa_size";s:5:"value";s:0:"";s:8:"position";s:1:"3";s:10:"is_visible";s:1:"1";s:12:"is_variation";s:1:"1";s:11:"is_taxonomy";s:1:"1";}}';
//echo '<pre>';
//var_dump(unserialize ($attribute));
//echo '</pre>';
define('IMPORT_BASE_URL', 'http://www.ndkstore.com/?post_type=product&p=');
@khangvm53
khangvm53 / regex password
Created December 10, 2018 01:55
regex password
Minimum eight characters, at least one letter and one number:
"^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$"
Minimum eight characters, at least one letter, one number and one special character:
"^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$"
Minimum eight characters, at least one uppercase letter, one lowercase letter and one number:
"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$"
#!/usr/local/bin/bash
# version 1.0
# usage: ./backup.sh domain.com
#Config
BACKUPCONFIG="backup-config.txt"; #domain sourcepath dbhost dbname dbuser dbpass
BACKUPPATH="/home/infact-m6/backup";
BACKUPSERVER="infact-m3.sakura.ne.jp";
BACKUPSERVER_USERNAME="infact-m3";
#!/bin/bash
# usage: ./backup.sh domain.com
#Config
BACKUPPATH="/home/backup"; # store backups here
HOSTPATH="/home"; # path where hosted domains are
# set database settings.
DBUSER="root"
<?php
include("includes/config.inc.php");
#Language
$objSite->languageSession();
#echo "<pre>"; print_r($objSmarty); echo "</pre>";exit;
if( ($_SERVER['HTTP_X_FORWARDED_HOST'] || $_SERVER['SERVER_ADDR'] == '31.210.53.104') && (($_SERVER['HTTP_HOST'] != 'enkolayweb.com' && $_SERVER['HTTP_HOST'] != 'www.enkolayweb.com' && $_SERVER['HTTP_HOST'] != 'http://enkolayweb.com' ) || $_SERVER['HTTP_X_FORWARDED_HOST'] ) )
{
if($_SERVER['HTTP_X_FORWARDED_HOST'])
@khangvm53
khangvm53 / Varnish-for-Wordpress-Cookies-are-blocked-or-not-supported.md
Last active July 27, 2016 04:37
Varnish for Wordpress - Cookies are blocked or not supported
  • Find beresp.http.Set-Cookie and change it like the below
# Only allow cookies to be set if we're in admin area
	if (beresp.http.Set-Cookie && bereq.url !~ "/wp-(login|admin)") {
        	unset beresp.http.Set-Cookie;
    	}
  • The way forward cookie in varnish
@khangvm53
khangvm53 / Install-varnish-with-nginx-in-Centos-7.md
Last active March 24, 2023 04:31
Install varnish with nginx in Centos 7

Install nginx, varnish

yum install varnish
yum install nginx

Config nginx listen on port 8081

server {
        listen 8081;
        server_name www.example.com;
@khangvm53
khangvm53 / currency.php
Created March 28, 2016 05:45
currency code and simbols
$currency_symbols = array(
'AED(&#1583;.&#1573;)', // ?
'AFN(&#65;&#102;)',
'ALL(&#76;&#101;&#107;)',
'ANG(&#402;)',
'AOA(&#75;&#122;)', // ?
'ARS(&#36;)',
'AUD(&#36;)',
'AWG(&#402;)',
'AZN(&#1084;&#1072;&#1085;)',
@khangvm53
khangvm53 / subcategory.php
Last active March 16, 2016 08:10
joomla query get subcategory
<?php
// Get Params
$app = JFactory::getApplication();
$params = $app->getMenu()->getActive()->params; // get the active item
$category_ids = array($params->get('category_id'));
getSubCategories( array($params->get('category_id')), $category_ids, 4 );
var_dump($category_ids);
function getSubCategories($ids, &$catIDs, $level){