Skip to content

Instantly share code, notes, and snippets.

@akrasic
akrasic / bash_strict_mode.md
Created December 5, 2024 16:42 — forked from vncsna/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
BEGIN MESSAGE.
ngebahGilrxafz0 IzNcEuutjnaARm6 Ojq9KgWAxtPRxaa 1WoCHomi5MwQxFv
8UhFcTAageXpMbY kH3WpPw8XMoTCKq 6Xr2MZHgg4WrlbI BuXZMYQXA7MCsmX
mxg8LDDcXS5lQym a9db88e63txBrSo uwHXpwcy1JiEM58 kyuOVb6BTul3ELh
sw4cDOJJyE3ajkG hLBXzaKv00gjo61 b07py2IP.
END MESSAGE.
@akrasic
akrasic / csf_block_check.sh
Last active October 27, 2016 20:12
Check CSF for IP blocks
#!/bin/bash
ipfile=$1
for i in $(cat $ipfile); do
if ! csf -g $i | grep -q "No matches"; then
echo "IP $i blocked"
grep $i /etc/csf/csf.deny
echo ""
fi
# ~/.i3/config
# i3 config template
# Base16 Monokai by Wimer Hazenberg (http://www.monokai.nl)
# template by Matt Parnell, @parnmatt
set $base00 #272822
set $base01 #383830
set $base02 #49483e
set $base03 #75715e
set $base04 #a59f85
@akrasic
akrasic / nginx-ssl.conf
Last active September 16, 2015 23:41
Configuration to get an A+ on the Qualys SSL Labs test with fast performing and low overhead SSL ciphers. Works in combination with nginx 1.6.0 full and OpenSSL v1.0.1i.
# I've used the configuration below for all my nginx instances and gotten an A+ on the Qualys SSL Test
# (https://www.ssllabs.com/ssltest/index.html). It satisfies requirements for PCI Compliance and
# FIPS. Includes OCSP Stapling (http://en.wikipedia.org/wiki/OCSP_stapling) and HTTP Strict Transport
# Security (http://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security).
# - Not vulnerable to the Heartbleed attack.
# - Not vulnerable to the OpenSSL CCS vulnerability (CVE-2014-0224) with OpenSSL v1.0.1i 6 Aug 2014 & Nginx 1.6.0
# - SSL Handshake takes <80ms on most modern server hardware
# Use within the "server" scope among other directives

Installing and using Percona XtraBackup

For MySQL/MariaDB database servers on Ubuntu.

Set-up and Install

Add Percona to your repository.

Backup your sources.

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

Edit your sources.
@akrasic
akrasic / nokogiri-libxml2-centos.sh
Last active December 19, 2015 20:09
Fix nokogiri issue
#!/bin/bash
# Install libxml2 2.8.0 and reinstall nokogiri 1.6.0
#
cd /usr/src/
wget ftp://xmlsoft.org/libxml2/libxml2-2.8.0.tar.gz
tar xzfv libxml2-2.8.0.tar.gz
cd libxml2-2.8.0
./configure --prefix=/usr/local/
make
@akrasic
akrasic / prekillacct.pl
Last active December 18, 2015 09:19
prekillacct
#!/usr/bin/perl
## Fetch cPanel data
my %OPTS = @ARGV;
my $user = $OPTS{'user'};
my $domain = $OPTS{'domain'};
my $owner = $OPTS{'owner'};
my $pass = $OPTS{'pass'};