Skip to content

Instantly share code, notes, and snippets.

View thisbailiwick's full-sized avatar

Kevin Clark thisbailiwick

View GitHub Profile
Core Objective: Adopt a direct, grounded, and variable writing style. Strictly avoid the "AI-generated" markers identified by Wikipedia editors and content moderators.1. Vocabulary & Phrase BansNo "Puffery" or Vague Significance: Do not use phrases like "pivotal moment," "testament to," "underscores the importance," "rich tapestry," "landscape," "realm," or "shaping the future."No "AI Adjectives": Avoid "captivating," "intricate," "majestic," "meticulous," or "breathtaking."No Editorializing: Never start sentences with "It is important to note," "It is worth considering," or "In conclusion."2. Structural ConstraintsAvoid the "Present Participle Problem": Do not end sentences with "-ing" clauses that add vague value (e.g., "...improving efficiency" or "...highlighting its legacy"). Use a period and start a new, concrete sentence instead.Avoid Negative Parallelisms: Do not use the "Not only X, but also Y" or "It’s not just about A; it’s about B" structures. They sound like a sales pitch.Break the "Rule of Three
#!/bin/bash
# ===========================================
# Ubuntu System & Library Updater
# ===========================================
# This script updates all installed packages and libraries,
# performs a full upgrade, and removes unused dependencies.
LOG_FILE="/var/log/system-update_$(date +'%Y-%m-%d_%H-%M-%S').log"
echo "===========================================" | tee -a "$LOG_FILE"
#!/usr/bin/env php
<?php
/**
* Composer Update Checker by Date
*
* Checks all defined dependencies in composer.json for any new versions
* released after a specified date. It also checks wpackagist plugins
* to see if they have not been updated in over a year.
*

Updating via Composer

If updates are being done via composer and not run via Shift these steps can be taken.

  • Get a list of all packages which will be updated and save for later during testing so you know what packages have been changed if you need to debug.
    • Get major versions which will not have been done on production.
      • This will output all direct and transitive package updates
# output major version changes as list
composer outdated --all --format=json | jq -r '.installed[] | select((.version | sub("^[^0-9]*"; "") | split(".")[0] | tonumber) as $current_version | (.latest | sub("^[^0-9]*"; "") | split(".")[0] | tonumber > $current_version)) | "\(.version) -> \(.latest): \(.name)"'
  • Get versions of packages that will need to be updated filtered by the last release date. We do this because the last release would have updated the minor package versions. Filtering it by date allows us to specifically know what packages are going to change on production
@thisbailiwick
thisbailiwick / composer-output-direct-dependency-updates-require-shell-command-for-packages-since-date.sh
Last active June 18, 2025 15:33
Run `composer outdated` for direct dependencies only and check for updates since a specific release date. If you haven't run the major packages updates shell command then they may or may not show up here as we're only checking for updates since the last release date. Make sure you run that one first.
#!/bin/bash
require_dev_packages=$(
jq -c '(.["require-dev"] // {}) | keys' composer.json
)
composer outdated --direct --format=json | \
jq -r --argjson dev_packages "$require_dev_packages" '
.installed[]
# Only select packages that have a "latest-release-date" and are released after a specific date
@thisbailiwick
thisbailiwick / composer-output-direct-dependency-updates-require-commands.sh
Last active March 17, 2025 21:12
Output composer require packages for direct requirements only, allowing for updating all dependencies and putting in the --dev flag for packages in the dev-requirements section. This can be added to file to be run or just copied and pasted into the terminal (maybe without the `#!/bin/bash` in that case, not sure)
#!/bin/bash
# Parse require-dev section from composer.json as a JSON array, ensuring it's valid JSON
require_dev_packages=$(jq 'if .["require-dev"] then .["require-dev"] | keys else [] end' composer.json | tr -d '\n' | tr -d ' ')
# Check for outdated direct dependencies and handle accordingly
composer outdated --direct --format=json | jq -r --argjson dev_packages "$require_dev_packages" '
.installed[] |
select(
# Extract major version and compare
# output major version changes as json
composer outdated --all --format=json | jq '.installed[] | select((.version | sub("^[^0-9]*"; "") | split(".")[0] | tonumber) as $current_version | (.latest | sub("^[^0-9]*"; "") | split(".")[0] | tonumber > $current_version)) | {name, version, latest}'
# output major version changes as list
composer outdated --all --format=json | jq -r '.installed[] | select((.version | sub("^[^0-9]*"; "") | split(".")[0] | tonumber) as $current_version | (.latest | sub("^[^0-9]*"; "") | split(".")[0] | tonumber > $current_version)) | "\(.version) -> \(.latest): \(.name)"'
@thisbailiwick
thisbailiwick / composer-output-packages-with-changes-release-date-after.sh
Last active January 23, 2025 16:32
Will only ouput packages which have a release date after a specific UTC datetime
# output packages which had updates by after last release date as json
composer outdated --all --format=json | jq -r '.installed[] | select(.["latest-release-date"] != null and (.["latest-release-date"] > "2024-11-20T18:39:00+00:00"))'
# output packages which had updates by after last release date as list
composer outdated --all --format=json | jq -r '.installed[] | select(.["latest-release-date"] != null and (.["latest-release-date"] > "2024-01-16T18:39:00+00:00")) | "\(.version) -> \(.latest): \(.name)"'
# output packages which had updates and still need updates by after last release date as list
composer outdated --all --format=json | jq -r '.installed[] | select(.["latest-release-date"] != null and .["latest-release-date"] > "2025-01-16T18:39:00+00:00" and ((.version | sub("^[^0-9]*"; "") | split(".")[0] | tonumber) < (.latest | sub("^[^0-9]*"; "") | split(".")[0] | tonumber))) | "\(.version) -> \(.latest): \(.name)"'
@thisbailiwick
thisbailiwick / udpate-outdated-composer-packages.sh
Last active September 26, 2024 19:33
This will output the necssary `composer require` command to update all packages. Copy the output and run in the cli;
composer outdated --format=json | jq -r '.installed[] | "\(.name):\(.latest)"' | xargs | sed 's/^/composer require /'
SELECT
t1.table_name AS `Table`,
t1.table_schema AS `Database 1`,
ROUND(((t1.data_length + t1.index_length) / 1024 / 1024), 2) AS `Size (MB) - DB1`,
t2.table_schema AS `Database 2`,
ROUND(((t2.data_length + t2.index_length) / 1024 / 1024), 2) AS `Size (MB) - DB2`,
ROUND((
CASE
WHEN (t1.data_length + t1.index_length) >= (t2.data_length + t2.index_length)
THEN ((t1.data_length + t1.index_length) - (t2.data_length + t2.index_length))