Skip to content

Instantly share code, notes, and snippets.

View tnqsoft's full-sized avatar

Tuấn Quỳnh Software tnqsoft

View GitHub Profile
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;
@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$$
@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 / 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 / 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)
{
<?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 / app.module.ts
Last active August 24, 2017 07:25
Angular 4 with ng2-file-upload
import { FileUploadModule } from 'ng2-file-upload';
import { ThumbnailDirective } from './thumbnail.directive';
...
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
CommonModule,
FileUploadModule
],
@tnqsoft
tnqsoft / example.html
Last active June 29, 2024 14:09
Preview image for ng2-file-upload
<div *ngFor="let item of uploader.queue; let first = first;">
<img src="" thumbnail [image]="item?._file"/>
{{ item?.file?.name }}
{{ item?.file?.size }}
</div>
<input type="file" ng2FileSelect [uploader]="uploader" #fileInput [accept]="accept.toString()" [multiple]="multiple"/>
@tnqsoft
tnqsoft / human-file-size.pipe.ts
Created July 11, 2017 04:06
Angular 4 Human file size in English
import { Pipe, PipeTransform } from '@angular/core';
/*
* Convert bytes into largest possible unit.
* Takes an precision argument that defaults to 2.
* Usage:
* bytes | humanFileSize:precision
* Example:
* {{ 1024 | humanFileSize}}
* formats to: 1 KB
@tnqsoft
tnqsoft / long-file-name.pipe.ts
Created July 11, 2017 04:05
Angular 4 Long file name
import { Pipe, PipeTransform } from '@angular/core';
/*
* Format long file name
* Max length, default is 100
* Usage:
* filename | longFileName:maxLength
* Example:
* {{ 'demo file name long at here, this is long file name omg please try input now.txt' | longFileName:40}}
* formats to: demo file name long ...se try input now.txt