Skip to content

Instantly share code, notes, and snippets.

View anhducbkhn's full-sized avatar

anhduc.bkhn anhducbkhn

View GitHub Profile
<?php
/**
* QR Code + Logo Generator
*
* http://labs.nticompassinc.com
*/
$data = isset($_GET['data']) ? $_GET['data'] : 'http://labs.nticompassinc.com';
$size = isset($_GET['size']) ? $_GET['size'] : '200x200';
$logo = isset($_GET['logo']) ? $_GET['logo'] : FALSE;
# Automatically instal the latest nginx
wget -O - http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
#Make a backup copy of your current sources.list file
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
#Now copy the following repositories to the end of ` /etc/apt/sources.list`
echo "deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx" | sudo tee -a /etc/apt/sources.list
@anhducbkhn
anhducbkhn / gist:d136f5a53950eac1a6e6
Created January 18, 2016 06:39 — forked from vxnick/gist:380904
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component, PropTypes } from 'react';
import {
AppRegistry,
StyleSheet,
import React, { Component, PropTypes } from 'react';
import { View, Text, TouchableHighlight } from 'react-native';
export default class MyScene extends Component
{
static propTypes = {
title: PropTypes.string.isRequired,
onForward: PropTypes.func.isRequired,
onBack: PropTypes.func.isRequired,
}
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
<?php
$serverName = 'localhost';
$userName = 'root';
$password = 'a';
$dbName = 'test';
$conn = new mysqli($serverName, $userName, $password, $dbName);
if ($conn->connect_error) {
die ('Connection failed' . $conn->connect_error);
@anhducbkhn
anhducbkhn / gist:fddaea578e3163fe4e6df4e042b6524d
Last active June 20, 2017 09:49
Force user to redirect to cart page in woocommerce
add_action('template_redirect', 'redirect_to_cart_page');
function redirect_to_cart_page()
{
if (is_checkout() and !is_user_logged_in()) {
$carts = WC()->cart->get_cart();
if (!empty($carts)) {
foreach ( $carts as $cart)
@anhducbkhn
anhducbkhn / gist:3e14b47103c4cc48086fd2562d776117
Created June 26, 2017 08:31
Configure SSH Key Authentication on a linux server
# Client, generate a ssh key pair if needed
ssh-keygen
# Copy public key to server
ssh-copy-id username@IP
# Disable the Password for Root Login on server
sudo nano /etc/ssh/sshd_config
--> PermitRootLogin without-password
reload ssh
@anhducbkhn
anhducbkhn / gist:c91cd56d2ccc7b45fc3aca0b4bf108b3
Last active August 1, 2017 10:32
Install nginx passenger on ubuntu 16.04
Create user deploy
sudo useradd deploy
sudo usermod -a -G sudo deploy
Login as deploy user
su deploy
Install RVM
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB