Skip to content

Instantly share code, notes, and snippets.

View StuMason's full-sized avatar
🏋️‍♂️
Testing

Stu Mason StuMason

🏋️‍♂️
Testing
  • Folkestone
View GitHub Profile
<?php
namespace App\Aws;
use Aws\Credentials\CredentialProvider;
use Aws\Credentials\Credentials;
use Aws\Signature\SignatureV4;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\App;
@StuMason
StuMason / aws_mfa.py
Created May 6, 2022 11:04
AWS MFA switching
"""
Switching between accounts where MFA is required can be a little manually intensive.
This script updates a temporary profile with a key, secret and session token (using a more stable profile - in this case 'default').
You can then use this temporary profile to switch between accounts.
i.e I have my main profile
I created a `[mfa_temp_session]` profile in my credentials which looked like this:
@StuMason
StuMason / History|2ade281f|563H.json
Last active October 31, 2022 14:32
Visual Studio Code Settings Sync Gist
{
"python.testing.unittestArgs": [
"-v",
"-s",
".",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.nosetestsEnabled": false,

Keybase proof

I hereby claim:

  • I am stumason on github.
  • I am stuissecure (https://keybase.io/stuissecure) on keybase.
  • I have a public key ASCSc6RXYvbgdOBz7fDVphqCNdn6hmnqsonQChQI0Ls-9Qo

To claim this, I am signing this object:

@StuMason
StuMason / AwsV4SignedRequestTrait.php
Last active October 12, 2018 10:26
AWS V4 Signature Request Trait - requires AWS-PHP-SDK. Below example used in a Laravel app. Returns a signed request.
<?php
namespace App\Traits;
use Psr\Http\Message\RequestInterface;
use Aws\Signature\SignatureV4;
use Aws\Credentials\CredentialProvider;
use Aws\Credentials\CredentialsInterface;
/**
@StuMason
StuMason / .zshrc
Last active August 17, 2018 13:36
s/__NAME__/stuart
# Path to your oh-my-zsh installation.
export ZSH=/Users/__NAME__/.oh-my-zsh
export XDEBUG_CONFIG="idekey=VSCODE"
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="powerlevel9k/powerlevel9k"
# Uncomment the following line if you want to change the command execution time
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs docker rmi
# remove unused volumes:
docker volume ls -qf dangling=true | xargs docker volume rm
@StuMason
StuMason / database.php
Created July 20, 2018 13:29 — forked from andyfleming/database.php
Database config for laravel/lumen
<?php
return [
'default' => 'accounts',
'migrations' => 'migrations',
'connections' => [
@StuMason
StuMason / pre-commit
Last active May 29, 2019 11:09
dd(), console.log and php-cs-fixer .git pre-commit
#!/bin/bash
# This file is stored here: ~/.githooks/pre-commit
# Makesure the file is executable: chmod +x ~/.githooks/pre-commit
# Needs: git config --global core.hooksPath ~/.githooks
# Needs phpcbf installed (this command installs globally): composer global require squizlabs/php_codesniffer
# Redirect output to stderr and allow user input
exec 1>&2
exec < /dev/tty
@StuMason
StuMason / remove.sh
Created June 1, 2018 10:21
remove.sh
#!/bin/bash
# tars then deletes the NGINX file, /var/www/directory and mysql DB for $DOMAIN passed in first argument e.g
# sudo bash remove.sh domain.co.uk
# needs /root/.my.conf set up with [client] root user and password to create DB
# MAKESURE /root/backup/ exists before running this, haha.
DOMAIN=$1
mysqldump ${DOMAIN//[^a-zA-Z_-]/_} > /root/backup/${DOMAIN}/db/${DOMAIN//[^a-zA-Z_-]/_}