Skip to content

Instantly share code, notes, and snippets.

@igez
igez / .htaccess
Last active November 1, 2016 05:56
Wordpress default .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
var gulp = require('gulp'),
gutil = require('gulp-util'),
clean = require('gulp-clean'),
cssmin = require('gulp-cssmin'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
cache = require('gulp-angular-templatecache'),
watch = require('gulp-watch'),
@igez
igez / hourglass.js
Created September 14, 2016 07:20
Hourglass without loop
var temp = 0;
function draw(max) {
if (temp >= max * 2) return;
temp = temp + 2;
if (temp <= max && temp != max*2) ast(max - temp, '', max);
else if (temp >= max && temp != max*2) ast(temp - max, '', max);
}
function ast(col, string, max) {
if (string.length > col) {
console.log(Array((max - col)/2).join(' ') + string);
@igez
igez / install_docker.sh
Last active November 1, 2016 05:55
Install Docker Ubuntu 14.04
#!/bin/bash
sudo apt-get update && sudo apt-get -y install wget nano
wget -qO- https://get.docker.com/ | sh
sudo usermod -aG docker $(whoami)
# install docker compose
sudo apt-get -y install python-pip
@igez
igez / docker-compose.yml
Created October 8, 2016 11:13
Setup local project Apache PHP Mysql with persistent data
version: '2'
services:
db:
image: igez/mysql
volumes:
- "./.data:/var/lib/mysql"
restart: always
environment:
MYSQL_DATABASE: "test"
web:
@igez
igez / install_mailcatcher.sh
Last active November 1, 2016 05:55
Install Mailcatcher on Ubuntu 14.04
#!/bin/bash
sudo apt-get install -y curl libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
@igez
igez / docker_cleanup.sh
Last active November 1, 2016 05:55
Clean ups docker related junks
#!/bin/sh
# clean up unused docker volume
docker volume rm $(docker volume ls -qf dangling=true)
# clean up exited docker containers
docker rm -v $(docker ps -a -q -f status=exited)
# clean up dangling docker images
docker rmi $(docker images -f "dangling=true" -q)
@igez
igez / largest_table.sql
Created October 8, 2016 16:17
Find largest table MySQL
-- REF https://www.percona.com/blog/2008/02/04/finding-out-largest-tables-on-mysql-server/
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
@igez
igez / install_docker_centos.sh
Last active November 1, 2016 05:55
Install Docker & Docker Compose on Centos 7
#!/bin/bash
wget -qO- https://get.docker.com/ | sh
sudo usermod -aG docker $(whoami)
sudo systemctl enable docker.service
sudo systemctl start docker.service
sudo yum install -y epel-release
sudo yum install -y python-pip
sudo yum upgrade -y python*
sudo pip install docker-compose --force --upgrade
@igez
igez / add_swap.sh
Last active November 1, 2016 05:55
Add Swap Centos 7
#!/bin/bash
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo echo "/swapfile swap swap sw 0 0" >> /etc/fstab
sudo sysctl vm.swappiness=10