Skip to content

Instantly share code, notes, and snippets.

@xserveraws
xserveraws / getRowCounts.sh
Last active October 13, 2020 00:30 — forked from martinhbramwell/getRowCounts.sh
A bash script to compare row counts of tables in two databases on separate machines
#!/bin/bash
#
DROP_ROWCOUNTS="\"DROP TABLE IF EXISTS rowcounts;\""
MAKE_ROWCOUNTS="\"CREATE TABLE rowcounts
(
name_server character varying(64) NOT NULL
, name_table character varying(64) NOT NULL
, count integer
);\""
#
@xserveraws
xserveraws / index.html
Created October 11, 2020 08:32 — forked from tnhu/index.html
JavaScript Beautifier
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="en-us" dir="ltr" class="ie ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en-us" dir="ltr" class="ie ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en-us" dir="ltr" class="ie ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en-us" dir="ltr" class="ie ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en-us" dir="ltr"> <!--<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Online javascript beautifier</title>
<style type="text/css">
@xserveraws
xserveraws / setup.sh
Created August 25, 2020 09:14 — forked from annttu/setup.sh
Debian PXE install
#!/bin/bash
# Setup Debian PXEinstall environment
export MYIP=10.66.6.1 # TODO: Setup this
export MYINTERFACE=$(netstat -ie | grep -B1 "$MYIP" | head -n1 | awk '{print $1}')
if [ -z "$MYINTERFACE" ]
then
echo "Setup ip $MYIP first"
@xserveraws
xserveraws / post-mortem.md
Created August 24, 2020 15:29 — forked from joewiz/post-mortem.md
Recovery from nginx "Too many open files" error on Amazon AWS Linux

On Tue Oct 27, 2015, history.state.gov began buckling under load, intermittently issuing 500 errors. Nginx's error log was sprinkled with the following errors:

2015/10/27 21:48:36 [crit] 2475#0: accept4() failed (24: Too many open files) 2015/10/27 21:48:36 [alert] 2475#0: *7163915 socket() failed (24: Too many open files) while connecting to upstream...

An article at http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ provided directions that mostly worked. Below are the steps we followed. The steps that diverged from the article's directions are marked with an *.

    • Instead of using su to run ulimit on the nginx account, use ps aux | grep nginx to locate nginx's process IDs. Then query each process's file handle limits using cat /proc/pid/limits (where pid is the process id retrieved from ps). (Note: sudo may be necessary on your system for the cat command here, depending on your system.)
  1. Added fs.file-max = 70000 to /etc/sysctl.conf
  2. Added `nginx soft nofile 1
@xserveraws
xserveraws / rsync_parallel.sh
Created August 11, 2020 07:24 — forked from rcoup/rsync_parallel.sh
Parallel-ise an rsync transfer when you want multiple concurrent transfers happening,
#!/bin/bash
set -e
# Usage:
# rsync_parallel.sh [--parallel=N] [rsync args...]
#
# Options:
# --parallel=N Use N parallel processes for transfer. Defaults to 10.
#
# Notes:
@xserveraws
xserveraws / letsencrypt-hostname.sh
Created August 8, 2020 11:24 — forked from agarzon/letsencrypt-hostname.sh
Secure plesk clean installation with hostname certificate by Let's Encrypt
#!/bin/bash -e
### Copyright 1999-2015. Parallels IP Holdings GmbH. All Rights Reserved.
### Secure plesk clean installation with hostname certificate by Let's Encrypt
export PYTHONWARNINGS="ignore:Non-standard path"
LE_HOME=${LE_HOME:-"/usr/local/psa/var/modules/letsencrypt"}
HOSTNAME=$(hostname)
# Use staging server for testing
# --server https://acme-staging.api.letsencrypt.org/directory
@xserveraws
xserveraws / install.md
Created August 1, 2020 06:19 — forked from prochor666/install.md
Mount Google drive under Debian Linux (Jessie and later)
  1. Make sure mysql-client is installed. If not, then :
    sudo apt install mysql-client
	or
    sudo apt-get install mysql-client
  1. Open php.ini

; PHP's default character set is set to UTF-8.

@xserveraws
xserveraws / PKGBUILD
Created July 30, 2020 18:55 — forked from sevu/PKGBUILD
MariaDB optimized build script for Archlinux
# Maintainer: Michael Herzberg
# Maintainer: Severin Glöckner <[email protected]>
# Contributor: Bartłomiej Piotrowski <[email protected]>
# Contributor: Christian Hesse <[email protected]>
pkgbase=mariadb-10.3
pkgname=('mariadb-libs-10.3' 'mariadb-clients-10.3' 'mytop-10.3' 'mariadb-10.3')
pkgver=10.3.12
pkgrel=2
arch=('x86_64')