Skip to content

Instantly share code, notes, and snippets.

@flickerfly
flickerfly / darkify_slack.css
Last active May 28, 2019 16:18 — forked from ryanpcmcquen/darkify_slack.sh
Darkify your Slack.
body{
background:#222;
color:#e6e6e6
}
a{
color:#949494
}
a:link,a:visited{
color:#949494
}
@flickerfly
flickerfly / mysqlaudit_log.json
Last active May 30, 2018 23:03
ElasticSearch ingest pipeline for mysql audit
{
"mysqlaudit_log": {
"description": "Ingest pipeline for MySQL Audit Log Format",
"processors": [
{
"grok": {
"field": "message",
"patterns": [
"^%{YEAR:year}%{MONTHNUM:month}%{MONTHDAY:day}%{SPACE}%{TIME:time},%{GREEDYDATA:host},%{WORD:username},%{GREEDYDATA:client_hostname},%{INT:connection_id},%{INT:query_id},%{MYSQLAUDIT_EVENT_TYPE_RW:event_type},%{WORD:database_name},%{WORD:table}",
"^%{YEAR:year}%{MONTHNUM:month}%{MONTHDAY:day}%{SPACE}%{TIME:time},%{GREEDYDATA:host},%{WORD:username},%{GREEDYDATA:client_hostname},%{INT:connection_id},%{INT:query_id},%{MYSQLAUDIT_EVENT_TYPE_QUERY:event_type},%{GREEDYDATA:database_name},'%{GREEDYDATA:query}',%{INT:return_code}",
@flickerfly
flickerfly / zimbra
Created October 28, 2013 18:53
Zimbra ufw application profile
[Zimbra]
title=Zimbra Collaboration Server
description=Open source server for email, contacts, calendar, and more.
ports=25,80,110,143,443,465,993,995,7071/tcp
final=800
counter=0
while [ $counter -le $final ]; do
printf "\r %75s/%4s" $counter $final
sleep 1
((counter++));
done
@flickerfly
flickerfly / upgrade-postgres-9.3-to-9.5.md
Created January 16, 2017 17:38 — forked from johanndt/upgrade-postgres-9.3-to-9.5.md
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
@flickerfly
flickerfly / Get-DCbyName.ps1
Created November 30, 2016 19:35
List Names of Domain Controllers
# http://use-powershell.blogspot.com/2013/04/find-all-domain-controllers-in-domain.html
Get-ADDomainController -Filter * |Select-Object name
@flickerfly
flickerfly / list-scripts-sending-mail.sh
Last active November 14, 2016 21:34
Show the PHP scripts sending email currently in the queue of a postfix server
#!/bin/bash
# This works only if postfix is running. It is complete, but when dealing with large queues due to spam loads,etc., it can take a long time
#mailq |cut -f 1 -d " "|egrep -v "^\(|^$|^-|\*" |xargs postcat -q |grep "X-PHP-Originating-Script"|sort|uniq
# This will work when postfix is not running. It may run faster, but it may also get stuck due to long argument lists.
postcat /var/spool/postfix/maildrop/* |grep "X-PHP-Originating-Script"|sort|uniq
postcat /var/spool/postfix/*/* |grep "X-PHP-Originating-Script"|sort|uniq
postcat /var/spool/postfix/*/*/* |grep "X-PHP-Originating-Script"|sort|uniq
@flickerfly
flickerfly / mysql_uptime.sh
Created October 19, 2016 19:34
Output uptime of mysql in clean and human-readable format
#/bin/sh
# Prints the uptime of mysql
# Optional: Takes one argument for the servername, default is localhost
# Set $host
if [ $1 ]; then
host=$1
else
host="localhost"
### VARIABLES ### \
SERVER=$(hostname)
MYSQL_CHECK=$(mysql -e "SHOW VARIABLES LIKE '%version%';" || echo 1)
SLAVE_STATUS=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G"|grep -v row)
LAST_ERRNO=$(echo "${SLAVE_STATUS}" | grep "Last_Errno:" | awk '{ print $2 }' )
SECONDS_BEHIND_MASTER=$(echo "${SLAVE_STATUS}" | grep "Seconds_Behind_Master:" | awk '{ print $2 }' )
IO_IS_RUNNING=$(echo "${SLAVE_STATUS}" | grep "Slave_IO_Running:" | awk '{ print $2 }' )
SQL_IS_RUNNING=$(echo "${SLAVE_STATUS}" | grep "Slave_SQL_Running:" | awk '{ print $2 }' )
SLAVE_IO_STATE=$(echo "${SLAVE_STATUS}" | grep "Slave_IO_State:" | awk -F':' '{gsub(/^[ \t]+/,"",$2);gsub(/[ \t]+$/,"",$2); print $2 }' )
ERRORS=()
@flickerfly
flickerfly / OpenVPN_New_User
Created December 9, 2013 15:16
Create a new user and assemble the required files to setup the VPN connection on the client side. First argument on the command line is the username.
#!/bin/sh
user=$1
vpnconf="/etc/openvpn"
rsa="$vpnconf/easy-rsa"
cd $rsa
source vars
./build-key $user
mkdir ~/$user.vpnfiles