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 / 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 / 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 {}
<?php
$builder = MyModel::where('active', 1);
$query = str_replace(array('?'), array('\'%s\''), $builder->toSql());
$query = vsprintf($query, $query->getBindings());
dd($query);
@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*"
SELECT id, TIMEDIFF(ended_at, started_at) as timediff FROM ...
### Keybase proof
I hereby claim:
* I am ajtrichards on github.
* I am alexrichards (https://keybase.io/alexrichards) on keybase.
* I have a public key ASDv_Nt0itWm_BtpceiaxDWHtvVxEmNbt-THZBG5DSQDkgo
To claim this, I am signing this object:
Feb 3 19:27:50 user-api-*-* user-api WARNING [03-Feb-2018 19:27:50] WARNING: [pool www] child 958 said into stderr: "[2018-02-03 19:27:50] lumen.DEBUG: user.api.view.user.error.user-details {"action":"user.api.view.user.error.user-details","userData":{"forename":"Alex","surname":"Richards","fullname":"Alex Richards","email":"emailaddress@hidden.com","username":"emailaddress@hidden.com","enabled":true,"earn":"earn:user/users:A-UUID-4"}} []"
@ajtrichards
ajtrichards / byte_to_str.go
Last active January 22, 2018 19:47
Convert []byte to string in Golang
func BytesToString(data []byte) string {
return string(data[:])
}
@ajtrichards
ajtrichards / clean-deleted-branches.sh
Created December 25, 2017 19:24
A command to delete merged branches in GIT
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
daemon off;
pid /tmp/nginx.pid;
error_log /dev/stderr info;
worker_processes auto;
events {
worker_connections 1024;
}
http {