What we're demonstrating here is that it's probably smart to do most database operations in a transaction, even SELECT
statements.
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
groups: | |
- name: node_rules | |
rules: | |
- record: instance:node_cpu:avg_rate5m | |
expr: 100 - avg (irate(node_cpu_seconds_total{job="helpspot-cloud", mode="idle"}[5m])) by (instance) * 100 |
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 php | |
<?php | |
// coverage-checker.php | |
$inputFile = $argv[1]; | |
$percentage = min(100, max(0, (int) $argv[2])); | |
if (!file_exists($inputFile)) { | |
throw new InvalidArgumentException('Invalid input file provided'); | |
} |
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 | |
# Reference: | |
# https://stackoverflow.com/questions/9646353/how-to-find-sqlite-database-file-version | |
# Go to a known directory so we can cleanup files later | |
cd ~ | |
# Download | |
wget https://www.sqlite.org/2019/sqlite-autoconf-3300100.tar.gz |
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
# Thanks to https://www.growingwiththeweb.com/2018/01/slow-nvm-init.html, modified | |
# for zsh as "type -t" works in bash but not zsh | |
# Add this to your .zshrc ... | |
# Defer initialization of nvm until nvm, node or a node-dependent command is | |
# run. Ensure this block is only run once if .bashrc gets sourced multiple times | |
# by checking whether __init_nvm is a function. | |
if [ -s "$HOME/.nvm/nvm.sh" ] && [ ! "$(type -w __init_nvm | awk '{print $2}')" = function ]; then |
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 | |
# 5 minutes between alerts | |
SECONDS_BETWEEN_ALERTS=300 | |
# Track when we sent the last alert | |
LAST_ALERT=0 | |
while true; do | |
NUMBER_CONNECTIONS=$(mysql --defaults-extra-file=/data/.prod.cnf -sNe "select count(*) as connection_count from INFORMATION_SCHEMA.PROCESSLIST;") |
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
<?php | |
/************************************************************************* | |
* Get File Information | |
*/ | |
// Assuming these come from some data source in your app | |
$s3FileKey = 's3/key/path/to/file.ext'; | |
$fileName = 'file.ext'; |
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 | |
### | |
# A CMD or ENTRYPOINT script for a Dockerfile to use to start a Nginx/PHP-FPM | |
# | |
# For more details, see 🐳 https://shippingdocker.com | |
## | |
if [ ! "production" == "$APP_ENV" ] && [ ! "prod" == "$APP_ENV" ]; then | |
# Enable xdebug |