Skip to content

Instantly share code, notes, and snippets.

View tnqsoft's full-sized avatar

Tuấn Quỳnh Software tnqsoft

View GitHub Profile
<?php
namespace Acme\Serializer\Normalizer;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\SerializerAwareNormalizer;
@tnqsoft
tnqsoft / factory.php
Created August 11, 2017 08:02
PHP Design Pattern
<?php
//http://www.phptherightway.com/pages/Design-Patterns.html
class Automobile
{
private $vehicleMake;
private $vehicleModel;
public function __construct($make, $model)
{
@tnqsoft
tnqsoft / closure.html
Created September 5, 2017 04:29
Javascript Study
<!doctype html>
<html lang="vi">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Javascript Study - Closure</title>
</head>
<body>
@tnqsoft
tnqsoft / wordpress-nginx-config.conf
Last active November 3, 2017 04:33
Wordpress Nginx Config
# sudo vi /etc/nginx/conf.d/example.conf
upstream php {
server unix:/var/run/php-fpm/php-fpm.sock;
server 127.0.0.1:9000;
}
server {
listen 80;
server_name example.com www.example.com;
@tnqsoft
tnqsoft / GeoCalDistanceByLatLon.sql
Created November 15, 2017 08:29
Google Map get distance from latitude and longitude
DELIMITER $$
USE `fashino`$$
DROP FUNCTION IF EXISTS `GeoCalDistanceByLatLon`$$
CREATE DEFINER=`root`@`localhost` FUNCTION `GeoCalDistanceByLatLon`( TYPE ENUM('mi', 'km'), lat1 DECIMAL(10,7), lon1 DECIMAL(10,7), lat2 DECIMAL(10,7), lon2 DECIMAL(10,7) ) RETURNS DECIMAL(10,7)
BEGIN
RETURN IF(TYPE = 'km', 6371, 3959)*ACOS(SIN(lat1*PI()/180)*SIN(lat2*PI()/180)+COS(lat1*PI()/180)*COS(lat2*PI()/180)*COS((lon2*PI()/180)-(lon1*PI()/180)));
END$$
server {
listen 80;
#listen [::]:80; #Use this to enable IPv6
server_name example.com www.example.com;
root /var/www/example.com/;
access_log /var/log/nginx/example-access.log;
error_log /var/log/nginx/example-error.log;
index index.php index.html;