Skip to content

Instantly share code, notes, and snippets.

View ajtrichards's full-sized avatar
🏠
Working from home

Alex Richards ajtrichards

🏠
Working from home
  • South Wales
View GitHub Profile
@ajtrichards
ajtrichards / gist:cfab61de1b570340bb55ae8b24fff258
Created May 21, 2021 14:39
AWS S3 - Delete files from a bucket with a prefix
aws s3 rm s3://BUCKET_NAME --recursive --exclude "*" --include "FILE_PREFIX-W*"
<?php
$builder = MyModel::where('active', 1);
$query = str_replace(array('?'), array('\'%s\''), $builder->toSql());
$query = vsprintf($query, $query->getBindings());
dd($query);
@ajtrichards
ajtrichards / scan-list-of-aws-ips.sh
Created February 15, 2022 19:40
Get a list of the public facing IP's from an AWS region and then, using NMAP, run a port scan.
aws ec2 describe-network-interfaces --query NetworkInterfaces\[\].Association.PublicIp | jq -r '.[]' | xargs -I{} nmap -v -A -sV {}
@ajtrichards
ajtrichards / exchange-o365-set-calendar-permissions.ps1
Created August 16, 2022 11:16
Powershell command to find all users in the Office365 installation and update the calendar permission to show Limited Details.
pwsh -Command 'Install-Module -Name PSWSMan'
pwsh -Command 'Install-Module -Name ExchangeOnlineManagement'
sudo pwsh -Command 'Install-WSMan'
Connect-ExchangeOnline -UserPrincipalName YOUR_EMAIL_ADDRESS
foreach($user in Get-Mailbox -RecipientTypeDetails UserMailbox) {
$cal = $user.alias+":\calendar"
write-host $cal
@ajtrichards
ajtrichards / github-cleanup-workflows.sh
Created July 24, 2024 06:16
GitHub - Cleanup GitHub Actions Workflow's that are no longer in use or were used for testing
run_ids=$(gh run list --limit 500 --repo=name/name --workflow=name.yml --json databaseId | jq -r '.[].databaseId')
for run_id in $run_ids; do
gh run delete $run_id --repo name/name
done
@ajtrichards
ajtrichards / slack-set-user-status.sh
Created February 13, 2025 11:57
Set's a users status in Slack.
curl -X POST "https://slack.com/api/users.profile.set" \
-H "Authorization: Bearer xoxp-USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"user": "USER_ID",
"profile": {
"status_text": "Off Sick",
"status_emoji": ":face_with_thermometer:",
"status_expiration": 0
}