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 / Vagrantfile
Created December 5, 2015 17:36
PHP Box Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="3;URL=https://ghth.vn/" />
<title>Đang Chuyển Hướng ...</title>
<style>
body {
font-family: Verdana, Geneva, Tahoma, sans-serif;
}
<?php
/**
* TimThumb by Ben Gillbanks and Mark Maunder
* Based on work done by Tim McDaniels and Darren Hoyt
* http://code.google.com/p/timthumb/
*
* GNU General Public License, version 2
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Examples and documentation available on the project homepage
map l nextTab
map h previousTab
@khanhicetea
khanhicetea / shortcuts.txt
Created August 23, 2016 05:06
KeePassC Shortcuts
'e' - go to main menu
'q' - close program
'CTRL+D' or 'CTRL+C' - close program at any time
'x' - save db and close program
's' - save db
'S' - save db with alternative filepath
'c' - copy password of current entry
'b' - copy username of current entry
'H' - show password of current entry
'o' - open URL of entry in standard webbrowser
@khanhicetea
khanhicetea / check.php
Last active September 24, 2016 03:47
Check valid vietnamese mobile phone number
<?php
function format_vn_phone($phone)
{
$phone = preg_replace('/[^0-9]/', '', $phone);
if (strlen($phone) > 10 && substr($phone, 0, 2) == '84') {
$phone = substr($phone, 2);
}
return substr(empty($phone) || $phone[0] == '0' ? $phone : '0'.$phone, 0, 11);
@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 / 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 / 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