Skip to content

Instantly share code, notes, and snippets.

View anhtuank7c's full-sized avatar
🎯
Focusing

Tuan Nguyen anhtuank7c

🎯
Focusing
View GitHub Profile
@anhtuank7c
anhtuank7c / .htaccess
Last active April 6, 2016 15:42
CakePHP: Redirect old domain to new domain using .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^old_domain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.old_domain.com [NC]
RewriteRule ^(.*)$ http://new_domain.net/$1 [L,R=301,NC]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
@anhtuank7c
anhtuank7c / .htaccess
Created April 6, 2016 15:56
.htaccess gzip compress
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
@anhtuank7c
anhtuank7c / LdapAuthenticate.php
Created April 9, 2016 17:31
LDAP authentication
<?php
namespace App\Auth;
use Cake\Auth\BaseAuthenticate;
use Cake\Network\Request;
use Cake\Network\Response;
class LdapAuthenticate extends BaseAuthenticate
{
@anhtuank7c
anhtuank7c / Install mysql server 5.7
Last active June 7, 2016 02:11
Install mysql server 5.7 on ubuntu 16
Go to http://dev.mysql.com/downloads/repo/apt/ then download the .deb file to your server
Install downloaded package: sudo dpkg -i package_name
Update Apt: sudo apt-get update
Install mysql: sudo apt-get install mysql-server
After install, going to secure it:
sudo mysql_secure_installation
@anhtuank7c
anhtuank7c / Let's Encrypt
Last active August 11, 2016 07:44
Install Let's Encrypt, create cert, automatic renew cert for Apache Ubuntu
(setup ssl self-cert first https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-14-04)
1) Install the Server Dependencies:
apt-get update
apt-get install git
2) Download the Let’s Encrypt Client:
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
3) Set Up the SSL Certificate:
@anhtuank7c
anhtuank7c / install_nginx.sh
Last active August 12, 2016 06:47
Install nginx with ngx_pagespeed on ubuntu 14.04 (blank new server), config nginx to support vhost, create demo vhost, deploy demo cakephp project. (aws ec2)
#!/bin/bash
## Author: Anh Tuan Nguyen (anhtuank7c@hotmail.com)
## Created: 08/08/2016
# update, upgrade to latest source
sudo apt-get update -y
sudo apt-get upgrade -y
# GOOGLE PAGE SPEED
sudo apt-get install -y build-essential zlib1g-dev libpcre3 libpcre3-dev unzip
@anhtuank7c
anhtuank7c / Let's Encrypt with nginx
Last active August 23, 2016 16:43
Generate ssl certs for your nginx vhost
#!/bin/bash
## Author: Anh Tuan Nguyen (anhtuank7c@hotmail.com)
## Created: 23/08/2016
## Install Let's Encrypt and generate certs for nginx
## If you want to install nginx server: https://gist.github.com/anhtuank7c/74d404b63ebb33ce17973d079b84aed1
## You will need git installed on your server
# Download lets encrypt to /opt/letsencrypt
sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
<Router createReducer={reducerCreate}>
<Scene key="auth">
<Scene
key="sign_in"
component={SignIn}
app={app}
initial={needSignIn}
title="Sign in"
@anhtuank7c
anhtuank7c / TimerReducer.js
Last active January 7, 2017 16:10
Reducer example
import {
TIME_CHANGE
} from '../actions/types';
// khai báo 1 trạng thái khởi
const INITIAL = {
hour: 0
};
// reducer này sẽ nhận trạng thái khởi tạo ở bên trên nếu như state chưa
@anhtuank7c
anhtuank7c / gist:cf0aa44aafc89595fe69ee94948e4378
Created January 24, 2017 05:04
Cách fix lỗi range names trong excel
Bước 1: Mở file excel bị lỗi duplicate named
Bước 2: Nhấn Alt + F11 và Insert > Module rồi paste code sau vào
Option Explicit
Sub RemNamedRanges()
Dim nm As Name
On Error Resume Next
For Each nm In ActiveWorkbook.Names
nm.Delete
Next