Skip to content

Instantly share code, notes, and snippets.

View khanhicetea's full-sized avatar
😎
solving human problems

KhanhIceTea khanhicetea

😎
solving human problems
View GitHub Profile
@khanhicetea
khanhicetea / gist:5a2cbfc6bfd216386a40db2197046ab0
Created October 4, 2016 12:59
Prevent virt-manager ask password (centos 6)

The password prompt was made for system security so if you do this might make it vulnerable.

Create the Group group on your machine. or you can run this "sudo groupadd -r [Group]" You can any user you want to this system group by runing "sudo usermod -a -G [Group] [User]" Now you need to create our PolicyKit policy that will allow the users of Group to run virt-manager you will create a file at this path:"/etc/polkit-1/localauthority/50-local.d/50-org.Group-libvirt-local-access.pkla" and you will put lines below in it

[Allow group [Group] libvirt management permissions]
@khanhicetea
khanhicetea / function.md
Last active July 22, 2019 10:57
Excel : get provider name of Vietnamese phone number

Replace A1 with your cell

Beatiful version

=IF(
    MID(A1,2,1)="9",
    IF(
        OR(MID(A1,3,1)="6",MID(A1,3,1)="7",MID(A1,3,1)="8"),
        "VIETTEL",
@khanhicetea
khanhicetea / install.sh
Last active April 21, 2018 08:17
Install Docker And Docker Compose Ubuntu 16.04
#! /bin/bash
export DEBIAN_FRONTEND=noninteractive
sudo apt -y update
sudo apt install apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt -y update
sudo apt purge lxc-docker
sudo apt-cache policy docker-engine
sudo apt -y install linux-image-extra-$(uname -r) linux-image-extra-virtual
@khanhicetea
khanhicetea / docker-gc.sh
Created November 6, 2016 02:59
Docker Garbage Collector
$ # Ref : https://github.com/docker/docker/pull/26108#issuecomment-243259942
$ # caveat that you get warnings on things that can't be removed
$ # remove all stopped containers
$ docker ps -aq | xargs --no-run-if-empty docker rm
$ # remove all unused volumes
$ docker volume ls -q | xargs --no-run-if-empty docker volume rm
$ # remove local volumes
$ docker volume ls | awk '/^local/ { print $2 }' | xargs --no-run-if-empty docker volume rm
@khanhicetea
khanhicetea / bootstrap.sh
Created November 20, 2016 15:41
Ubuntu 16.04 bootstrap script
#!/bin/sh
sudo sed -i "s/IPV6=yes/IPV6=no/" /etc/default/ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
sudo ufw --force enable
sudo ufw reload
sudo sed -i "s/.*PasswordAuthentication .*/PasswordAuthentication no/" /etc/ssh/sshd_config
@khanhicetea
khanhicetea / Ufw.md
Last active November 23, 2016 07:09
Devops Tips

Allow proto, from ip range, specified port

sudo ufw allow proto tcp from 10.130.0.0/16 to any port 3306
@khanhicetea
khanhicetea / lemp.sh
Last active March 15, 2017 05:10
LEMP on Ubuntu 16.04
sudo apt update
sudo apt list --upgradable
sudo apt install git vim curl software-properties-common -y
sudo apt install nginx -y
sudo apt install mysql-server-5.7 mysql-client-5.7 -y
sudo service mysql start
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install -y --force-yes php7.1-bz2 php7.1-cli php7.1-common php7.1-curl php7.1-fpm php7.1-gd php7.1-intl php7.1-json php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-opcache php7.1-readline php7.1-soap php7.1-sqlite3 php7.1-tidy php7.1-xml php7.1-xmlrpc php7.1-xsl php7.1-zip
sudo sed -i "s/;date.timezone =.*/date.timezone = UTC/" /etc/php/7.1/cli/php.ini
@khanhicetea
khanhicetea / lemp_ubuntu_1604.sh
Last active August 7, 2019 19:04
LEMP Stack on Ubuntu 16.04
#!/bin/bash
# Disable IPv6
echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
# Firewall
sudo sed -i -e 's/IPV6=yes/IPV6=no/' /etc/default/ufw
@khanhicetea
khanhicetea / kickstart.sh
Last active July 18, 2017 22:59
Docker Kickstarter on Ubuntu
#!/bin/bash
# Install required packages
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
# Add Docker repo
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
@khanhicetea
khanhicetea / main.py
Created June 15, 2017 04:45
Flash and SQLAlchemy test
from flask import Flask, request
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey
import time
app = Flask(__name__)