Skip to content

Instantly share code, notes, and snippets.

View anhtuank7c's full-sized avatar

Tuan Nguyen anhtuank7c

View GitHub Profile
@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
<Router createReducer={reducerCreate}>
<Scene key="auth">
<Scene
key="sign_in"
component={SignIn}
app={app}
initial={needSignIn}
title="Sign in"
@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 ([email protected])
## 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
@anhtuank7c
anhtuank7c / install_nginx_php7.sh
Last active March 8, 2017 09:45
Install nginx, openssl, google pagespeed, php7.0, mysql 5.7, phpmyadmin, cakephp 3.x on ubuntu 14.04 with default account "ubuntu". If your server don't have ubuntu account, please replace ubuntu by your account. Download this script to your server then "chmod +x install_nginx_php7.sh". Execute script by "./install_nginx_php7.sh"
#!/bin/bash
## Author: Anh Tuan Nguyen ([email protected])
## Created: 08/08/2016
## Install nginx, openssl, php7.0, mysql 5.7, phpmyadmin, cakephp 3.x
# update, upgrade to latest source
sudo apt-get update -y
sudo apt-get upgrade -y
# GOOGLE PAGE SPEED
@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 ([email protected])
## 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 / Install php 5.6 ubuntu 16
Created June 7, 2016 02:21
Install php 5.6 ubuntu 16
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6
you can install more php5.6 module
sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-intl php5.6-intl php5.6-mbstring php-apcu php-uuid php5.6-cgi php5.6-cli php5.6-gd php5.6-ldap php5.6-sqlite3 php-uploadprogress
@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 / 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 / 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 / .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>