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
# | |
# Remove `line` from `array`. | |
# If `line` occurs multiple times, only a single occurrence is removed. | |
# | |
new_array=() | |
skipped=0 | |
for value in "${array[@]}"; do | |
if [ "$value" == "$line" ] && [ $skipped -eq 0 ]; then | |
skipped=1 | |
else |
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
import com.google.common.base.Preconditions | |
import java.nio.ByteBuffer | |
import static com.google.common.base.Preconditions.checkState | |
// See java.util.UUID#randomUUID | |
UUID generateV4(byte[] src) { | |
checkState src.length <= 14 |
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
pvcreate /dev/sdc | |
vgcreate vgstore /dev/sdc | |
lvcreate -l 100%VG -n biggfsbrick vgstore | |
mkfs.xfs /dev/vgstore/biggfsbrick | |
echo '/dev/vgstore/biggfsbrick /export/biggfsbrick/ xfs defaults 1 2' >>/etc/fstab | |
mkdir /export/biggfsbrick | |
mount /export/biggfsbrick | |
gluster volume create big-repl-store replica 3 transport tcp app-01:/export/biggfsbrick/repl-store app-02:/export/biggfsbrick/repl-store app-03:/export/biggfsbrick/repl-store |
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
db.adminCommand( { listDatabases: 1 } ).databases.forEach(function (otherDb) { | |
var siblingDb = db.getSiblingDB(otherDb.name); | |
siblingDb.getCollectionInfos().forEach(function (coll) { | |
print(otherDb.name + '.' + coll.name + '\t->\t' + siblingDb.getCollection(coll.name).stats().wiredTiger.uri) | |
}) | |
}) |
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
ansible swarm_dtln -b -m user -a "name=USERNAME state=absent remove=yes force=true" | |
ansible swarm_dtln -b -m replace -a 'backup=yes dest=/etc/ssh/sshd_config regexp=^(AllowUsers.*)\\b(USERNAME)\\b(.*)$ replace=\\1\\3' | |
ansible swarm_dtln -b -m replace -a 'backup=yes dest=/etc/ssh/sshd_config regexp=^(Match.*)\\b(USERNAME\,)\\b(.*)$ replace=\\1\\3' | |
ansible swarm_dtln -b -m service -a "name=sshd state=restarted" |
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
# /var/log/secure: | |
... | |
Jan 28 10:47:22 web01 sshd[17503]: Accepted publickey for <myuser> from <myip> port 56325 ssh2: RSA SHA256:<checksum> | |
... | |
# Compute fingerprints from authorized keys. | |
# Match w/ the one in `secure' log. | |
# ssh-keygen -lf ~myuser/.ssh/authorized_keys |
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
#!/usr/bin/env bash | |
export YT_COOKIE="" # Get this from browser cookies, looks like "pp71vwl46b0t6ftkmo6bt5xt" | |
export REPORT_ID="" # Report ID, get this from URI of report page. Looks like 104-110 | |
export USER="" # YouTrack username to filter by. | |
export YT_HOST="" # YouTrack host, like https://youtrack.mycompany.com. | |
#################################################################################################### |
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 | |
# | |
# Dumps JVM application stack in case CPU load exceeds allowed threshold. | |
# | |
# This script is supposed to be called regularly, e.g. cron entry: | |
# | |
# */5 * * * * /opt/apps/stack-dumps/auto-dump.sh | |
# |
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
import org.apache.commons.mail.HtmlEmail | |
import javax.management.remote.JMXConnector | |
import javax.management.remote.JMXConnectorFactory | |
import javax.management.remote.JMXServiceURL | |
// @Grab(group = 'org.apache.commons', module = 'commons-email', version = '1.3.2', transitive = true) | |
// |
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
import javax.management.MBeanServerConnection | |
import javax.management.ObjectName | |
import javax.management.remote.JMXConnector | |
import javax.management.remote.JMXConnectorFactory | |
import javax.management.remote.JMXServiceURL | |
final findBean = { MBeanServerConnection server, | |
String beanName -> | |
server.queryMBeans(null, null).find { it.name.serializedNameString.contains beanName } | |
} |
NewerOlder