This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# As an alternative to the remembering the following syntax: | |
# true | true | true; echo ${PIPESTATUS[${#PIPESTATUS[@]}-1]} => 0 | |
# true | true | false; echo ${PIPESTATUS[${#PIPESTATUS[@]}-1]} => 1 | |
# | |
# from bash 4.2 you can also do (more simply): | |
# true | true | false; echo ${PIPESTATUS[-1]} => 1 (and also: -bash: PIPESTATUS: bad array subscript) | |
# | |
# e.g. true | true | true; lastpipestatusretval && echo worked | |
# e.g. true | true | false; ! lastpipestatusretval && echo failed | |
# + tmppipestatus=('0' '0' '0') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using a Consumer pattern vs. a constructor to populate an Enum instance. Handy if you | |
have a good number of fields and don't want long argument lists. Or if you need to do | |
some processing/method calling. | |
final fields would cause issues and would need to be done via a constructor without a callback. | |
public enum SomeEnum { | |
A((c)->{c.someField="A";}), | |
B((c)->{c.lotsMoreFields="B";}), | |
/*Syntax error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# when triggered by server patch code, will also include our sysinfo.sh script . A version of which is at https://gist.github.com/pbkwee/996a0c11f6d29281e58d3c42f869ef86 | |
if [ "$1" == "--fix-vuln" ]; then | |
# tag needed | |
echo "dss:attemptingfix:" | |
echo "dss:info: checking fix options." | |
[ ! -x /usr/bin/pkexec ] && echo "dss:info: no /usr/bin/pkexec, nothing to do." && return 0 | |
APT_GET_INSTALL_OPTIONS=' -y -o APT::Get::AllowUnauthenticated=yes -o Acquire::Check-Valid-Until=false -o Dpkg::Options::=--force-confnew -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confmiss ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "dss:hostname: $(hostname)" | |
echo "dss:date: $(date -u)" | |
echo "dss:shell: $SHELL" | |
echo "dss:dates: $(date -u +%s)" | |
echo "dss:uptimes:$([ -f /proc/uptime ] && cat /proc/uptime | awk '{print $1}')" | |
echo "dss:uptime: $(uptime)" | |
echo "dss:kernel: $(uname -a)" | |
echo "dss:bittedness: $(getconf LONG_BIT)" | |
df -m | awk '{print "dss:dfm:" $0}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Copyright Rimuhosting.com | |
function usage { | |
echo " | |
$0 Creates a backup of a Linux server. It has options to let you download that via http (else you can scp it from the source). It has options to encrypt the backup file (e.g. via openssl or zip). | |
Usage: $0 | |
--encrypt openssl (default if using --http) | zip (not so secure) | none (default if not using --http) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PDU3EVN10L2130 | |
PDU3EVN6L2130 | |
10,6 = cord length in feet (freedom units) | |
PDU3EVN10L2130 | |
PDU3EVN6L2130 | |
PDUMNH20HV | |
PDU3 = three phase, PDU = single | |
PDUV30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get install opendkim | |
/etc/opendkim.conf use settings like: | |
Domain domainname.com | |
Selector mail | |
# sign, no need to verify | |
Mode s | |
# rsa private key | |
KeyFile /etc/ssl/private/dkimproxy.key | |
Socket inet:8892@localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openssl s_client -connect $ip:110 -starttls pop3 | |
openssl s_client -connect $ip:465 | openssl x509 -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright 2018 Peter Bryant | |
# Licensed as https://www.apache.org/licenses/LICENSE-2.0 | |
[ ! -z "$1" ] && [ "$1" != "--drop" ] && cat << EOJ && exit 0 | |
Create a folders (SPAM_FOLDER=${SPAM_FOLDER:-unset} variable). Load it up with spam. | |
This script searches spam folders to find IP subnets (/24s) that have a sent a good amount of spam. | |
Output commands to move those away and to block those IP ranges. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlRootElement | |
=> | |
--add-modules java.xml.bind | |
-Djava.endorsed.dirs=/usr/local/tomcat/endorsed is not supported. Endorsed standards and standalone APIs | |
in modular form will be supported via the concept of upgradeable modules. | |
Error: Could not create the Java Virtual Machine. | |
=> | |
root@ri:/usr/local/tomcat# find . | grep endors | |
./endorsed |
NewerOlder