Skip to content

Instantly share code, notes, and snippets.

@cinco
cinco / manjaro-recovery.bash
Last active February 10, 2020 01:22
manjaro/archlinux recovery boot
#!/bin/bash
# can you boot with USB install manjro ( USB boot not the disk )
# open a terminal
manjaro-chroot -a ( select 1 if one line ) &&
pacman -Syy ( check ip on ) &&
cat /etc/fstab ( check UUID) &&
grub-mkconfig -o /boot/grub/grub.cfg ( generate grub config ) &&
mkinitcpio -P ( create all img kernel ) &&
update-grub &&
exit( always for quit chroot)
@cinco
cinco / sync-projects
Created February 4, 2020 21:14 — forked from nathanbrauer/sync-projects
Gitlab: Clone / Pull all projects in a group
#!/usr/bin/env bash
# Documentation
# https://docs.gitlab.com/ce/api/projects.html#list-projects
if [[ `whoami` == "root" ]]; then
echo "DO NOT run this program as root! Quitting."
exit 1
fi
@cinco
cinco / gist:569d29e2d9630fde68d1c40d43bb201b
Created January 27, 2020 17:17
provisioner terraform para expansão de disco LVM
provisioner "remote-exec" {
connection {
host = "var.ip[count.index]"
user = "login"
password = "senha"
}
inline = [
"echo senha | sudo -S growpart /dev/sda 2",
"sudo growpart /dev/sda 5",
"sudo pvresize /dev/sda5",
@cinco
cinco / terraform-install.sh
Last active January 26, 2020 18:57 — forked from danisla/terraform-install.sh
Terraform latest version install script (modified to zsh and exclude alpha versions)
#!/bin/bash
function terraform-install() {
[[ -f ${HOME}/bin/terraform ]] && echo "`${HOME}/bin/terraform version` already installed at ${HOME}/bin/terraform" && return 0
LATEST_URL=$(curl -sL https://releases.hashicorp.com/terraform/index.json | jq -r '.versions[].builds[].url' | egrep 'terraform_[0-9]\.[0-9]{1,2}\.[0-9]{1,2}_linux.*amd64' | sort -V | tail -1)
curl ${LATEST_URL} > /tmp/terraform.zip
mkdir -p ${HOME}/bin
(cd ${HOME}/bin && unzip /tmp/terraform.zip)
if [[ -z $(grep 'export PATH=${HOME}/bin:${PATH}' ~/.bashrc) ]]; then
echo 'export PATH=${HOME}/bin:${PATH}' >> ~/.zshrc
@cinco
cinco / gist:ab5f66d30d320fe043fa5a15fa5a64bf
Created January 15, 2020 12:35
instala ansible apt ppa
#!/bin/bash
sudo apt install -y software-properties-common
sudo apt-add-repository -y ppa:ansible/ansible
sudo apt update -y
sudo apt install -y ansible
openssl s_client -starttls smtp -showcerts -connect 0.0.0.0:25
@cinco
cinco / install-terraform-packer-os-x.sh
Created January 9, 2020 13:40 — forked from Adron/install-terraform-packer-os-x.sh
Install Terraform & Packer on Linux
#!/usr/bin/env bash
# Script prerequisite > install jq > https://stedolan.github.io
# ********************************************************************************************
# UPDATE: Check out Robert's repo here https://github.com/robertpeteuil/terraform-installer
# Robert's repo is more built out and has more options around the installation process.
# Cheers! -Adron
# ********************************************************************************************
cd ~
#!/bin/bash
for ((i = 22 ; i <= 66 ; i++)); do
wp user delete $i --yes
done
@cinco
cinco / gist:ffb57a9b9fec5d5663d588b50cf8f9c3
Created September 22, 2019 02:19
encrypt password SHA512 with python
python -c 'import crypt; print(crypt.crypt("suasenha", crypt.mksalt(crypt.METHOD_SHA512)))'
Overview
Content rot has a tendency to creep up on you as a website or application ages. The last thing your visitors want when they reach your site, after clicking a link to it, is to be face planted with a 404 error. To make matters worse, too many 404s will have an impact on your search engine site rankings.
We can battle 404s with redirect rules written in our Nginx configurations. The rules can either suggest to the web browser, search engine and anything that the content has permanently moved, or we suggest the content has only moved temporarily. Either way, you have a chance to guide the user to the new location of your content in a transparent manner.
Permanent Vs. Temporary
Two type of redirects exist. As you probably figured out from the heading, we can do either a permanent redirect (301) or a temporary redirect (302), depending on what our needs are. A permanent redirect tells user agents, including search engines, to update their indexes to replace the link with the new location, whereas tempo