- Create
UNLOGGEDtable. This reduces the amount of data written to persistent storage by up to 2x. - Set
WITH (autovacuum_enabled=false)on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we neverDELETEorUPDATEthe table). - Insert rows with
COPY FROM STDIN. This is the fastest possible approach to insert rows into table. - Minimize the number of indexes in the table, since they slow down inserts. Usually an index
on
time timestamp with time zoneis enough. - Add
synchronous_commit = offtopostgresql.conf. - Use table inheritance for fast removal of old data:
This file contains hidden or 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
| # From "A simple unix/linux daemon in Python" by Sander Marechal | |
| # See http://stackoverflow.com/a/473702/1422096 and http://web.archive.org/web/20131017130434/http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/ | |
| # | |
| # Modified to add quit() that allows to run some code before closing the daemon | |
| # See http://stackoverflow.com/a/40423758/1422096 | |
| # | |
| # Modified for Python 3 (see also: http://web.archive.org/web/20131017130434/http://www.jejik.com/files/examples/daemon3x.py) | |
| # | |
| # Joseph Ernest, 20200507_1220 |
This file contains hidden or 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
| node { | |
| echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1' | |
| echo 'No quotes, pipeline command in single quotes' | |
| sh 'echo $BUILD_NUMBER' // 1 | |
| echo 'Double quotes are silently dropped' | |
| sh 'echo "$BUILD_NUMBER"' // 1 | |
| echo 'Even escaped with a single backslash they are dropped' | |
| sh 'echo \"$BUILD_NUMBER\"' // 1 | |
| echo 'Using two backslashes, the quotes are preserved' | |
| sh 'echo \\"$BUILD_NUMBER\\"' // "1" |
This file contains hidden or 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
| function decode-authorization-failure-message { | |
| if [ $# -ne 1 ] || [ "$1" = -h ] || [ "$1" = --help ]; then | |
| cat <<'EOT' | |
| Usage: decode-authorization-failure-message <message> | |
| Use this when Amazon gives you an "Encoded authorization failure message" and | |
| you need to turn it into something readable. | |
| EOT | |
| return 1 | |
| fi |
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
This file contains hidden or 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
| # replaces this file /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/providers/virtualbox/action/sane_defaults.rb | |
| # NOTE: if using a different Vagrant version, adjust the version field accordingly | |
| # NOTE2: only the sections with the IRVING comment have been changed from the default | |
| require "log4r" | |
| module VagrantPlugins | |
| module ProviderVirtualBox | |
| module Action | |
| class SaneDefaults |
This file contains hidden or 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 | |
| # This file must be executable to work! chmod 755! | |
| # | |
| # The LUKS key must exist as a file at /etc/.keys/${device}.key | |
| # Protect this directory: root as user/group, 400 as permissions | |
| # | |
| # Edit your autofs master file to include something like | |
| # /mnt/crypt /etc/auto.luks --timeout=600 | |
| # | |
| # Then you can access your LUKS encrypted disk with |
This file contains hidden or 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
| xstat() { | |
| for target in "${@}"; do | |
| inode=$(ls -di "${target}" | cut -d ' ' -f 1) | |
| fs=$(df "${target}" | tail -1 | awk '{print $1}') | |
| crtime=$(sudo debugfs -R 'stat <'"${inode}"'>' "${fs}" 2>/dev/null | | |
| grep -oP 'crtime.*--\s*\K.*') | |
| printf "%s\t%s\n" "${crtime}" "${target}" | |
| done | |
| } |
This file contains hidden or 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 | |
| sleep 3 | |
| IP_ADDRESS=$(hostname -I | cut -f1 -d' ') | |
| GRAYLOG2_URL="http://admin:admin@${IP_ADDRESS}:12900" | |
| GRAYLOG2_INPUT_GELF_TCP=' | |
| { | |
| "global": "true", |