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 / vim.csv
Last active March 2, 2018 06:44
Tango Flash Cards
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 9.
ESC,normal mode
`,[motion] go to mark point
~,[command] toggle case
!,[operator] external filter
@,[command] play a macro
#,[motion] previous indent
$,[motion] end of line
%,[motion] go to match open/close symbol
^,[motion] "soft" begin of line - first char not blank space
&,[command] repeat :s (:s search and replace in current line)
@khanhicetea
khanhicetea / Dockerfile
Created November 22, 2017 02:59
Docker mysql remove ssl generator
FROM mysql:5.7
# Remove mysql_ssl_rsa_setup to ignore setup SSL certs
RUN rm -f /usr/bin/mysql_ssl_rsa_setup
@khanhicetea
khanhicetea / aws.txt
Last active February 27, 2020 12:47
[AWS, GCP, Azure IP Ranges] Nov 13 2017 updated
13.32.0.0/15
13.52.0.0/16
13.54.0.0/15
13.56.0.0/16
13.57.0.0/16
13.58.0.0/15
13.112.0.0/14
13.124.0.0/16
13.125.0.0/16
13.126.0.0/15
@khanhicetea
khanhicetea / main.go
Created August 14, 2017 05:39
Drone webhook access token generator (version 0.4.0)
package main
import (
"fmt"
"github.com/drone/drone/shared/token"
)
func main() {
repo_hash := "[SELECT `repo_hash` FROM `repos` where `repo_full_name` = <YOUR_REPO_FULLNAME>]"
repo_fullname := "<YOUR_REPO_FULLNAME>"
@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__)
@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 / 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 / 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 / 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 / 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