Skip to content

Instantly share code, notes, and snippets.

View wamith's full-sized avatar

Wamith wamith

View GitHub Profile
@wamith
wamith / mariadb_docker_local.sh
Last active September 13, 2020 02:57
Local Mariadb database using docker
!#/bin/bash
mkdir -p ~/var/lib/mariadb
docker pull mariadb
docker run --name mariadb-local -p 3306 -v ~/var/lib/mariadb:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password -d mariadb
/* UK Postcode Pattern
* < Outward Code > < Inward Code>
* <AREA><DISTRICT> <SECTOR><UNIT>
* AREA = 1 or 2 chars
* DISTRICT = (one or 2 digits) or (digit then letter)
* Space (optional)
* SECTOR = digit
* UNIT = 2 chars
*
* $postcode_regex = '/^([A-Z]{1,2})([0-9]{1,2}|[0-9][A-Z])\s?([0-9])([A-Z]{2})$/i';
@wamith
wamith / ssh_autocomplete.txt
Created April 18, 2019 05:26
autocomplete for ssh and scp
# add this to .bashrc or .profile
# auto complete for ssh and scp
complete -o default -o nospace -W "$(grep -e 'Host[^N]' ~/.ssh/config | awk '{print substr($0, index($0,$2))}' ORS=' ')" scp sftp ssh
@wamith
wamith / mysql_expired_password.txt
Last active April 18, 2019 05:29
Fix MySQL expired password issue
# expired MySQL password
systemctl stop mysqld
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
systemctl start mysqld
# login to the console and change the password
mysql -u root
UPDATE mysql.user SET authentication_string = PASSWORD('password123') WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
-- set passwords to never expire (optional)
@wamith
wamith / mkdir_99.sh
Created April 18, 2019 05:17
creating folders 00 to 99
echo "creating folders 00 to 99"
mkdir $(seq -w 00 99)
@wamith
wamith / mysql8_centos7.txt
Last active April 18, 2019 05:10
Install MySQL 8 on CentOS 7
yum -y update
yum -y install yum-utils bc
# start from a clean install
# centos 7 may have some mariadb libs which cause clashes
yum remove -y maria*
yum clean
# install mysql
@wamith
wamith / mysql57 install.txt
Created November 5, 2016 22:08
Installing mysql 5.7 on centos 6
Installing mysql 5.7 on centos 6
1. download yum repo
wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
2. install yum repo
yum -y localinstall mysql57-community-release-el6-7.noarch.rpm
3. verify yum repo
yum repolist enabled | grep "mysql.*-community.*"
@wamith
wamith / AWS PHP Install
Last active November 5, 2016 22:04
Install Apache, Mysql and PHP on a new AWS instance
#!/bin/bash
#update the server
echo "updating server, this might take some time ..."
sudo yum update -y
#install apache, php and mysql
echo "installing apache, php and mysql .."
sudo yum install -y httpd24 php56 mysql56-server php56-pdo php56-mysqlnd