Skip to content

Instantly share code, notes, and snippets.

@barretts
barretts / get_AMI_last_used_date.ps1
Created February 28, 2024 21:57
get all AMIs in a region and collect their last used date information valid from 2017 on
$amiInfo = aws ec2 describe-images --owners self --query 'Images[*].{ImageId:ImageId, CreationDate:CreationDate, Name:Name}' --output json | ConvertFrom-Json
$amiResults = @()
# $count = $amiInfo.Length;
# Write-Host "getting data for $count AMIs"
foreach ($ami in $amiInfo) {
$amiId = $ami.ImageId
$creationDate = $ami.CreationDate
@barretts
barretts / CallWhenDone.ps1
Created September 16, 2021 18:38
trigger webhook when command is finished
function CallWhenDoneFunc {
$mergedCmd = $args -join " "
Invoke-Expression $mergedCmd
# use content in payload for discord instead of text
$hookUrl = "https://hooks.slack.com/services/yoururlgoeshere"
$content = "Finished $mergedCmd"
$payload = [PSCustomObject]@{
text = $content
}
@barretts
barretts / Delete_roletouser_Duplicates.sql
Last active August 18, 2020 19:29
mysql fetch loop rows delete duplicates without primary keys
DELIMITER ;;
DROP PROCEDURE IF EXISTS Delete_roletouser_Duplicates;;
CREATE PROCEDURE Delete_roletouser_Duplicates()
BEGIN
DECLARE lmt INT DEFAULT 0;
DECLARE done INT DEFAULT 0;
DECLARE _role_id CHAR(36);
#!/usr/bin/python3
# Usage
# 0 * * * * /home/badguy90/bin/change_detection.py
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import difflib
import hashlib
@barretts
barretts / caveman-debugging-steps.md
Last active May 3, 2019 19:27
Caveman Debugging Complex Systems

Guide to Caveman Debugging Complex Systems

  • Generally state the issue you want to debug
  • Specifically identify the answer you seek from the debugging
  • List all possible points of failure in the system
  • Identify the minimum components required to debug the issue
  • Remove all possible points of failure not part of the minimum component list
  • Test the issue on this minimum setup. Does it work or not?

If the sytem does not work in the minimum setup you should begin replacing components with others that are known to work.

  • Start by switching out the component in question in this issue with one that works
@barretts
barretts / checklist.md
Last active February 20, 2019 21:36
step by step issue checklist

Yellow warnings are errors, don't ignore them.

You may at any point in the checklist need to backtrack when making code corrections and adjustments.

With all steps write down questions and notes as they arise.

Don't assume the code runs. Test it and be sure it runs.

Gather Intel

  • read the issue
  • re-read the issue making sure you understand every line, note any questions
  • create a list of the features required by this issue (fields, elements, page content)
  • if you have any outstanding questions reach out to clarify your concerns adjusting your list as necessary
@barretts
barretts / blue-dev-cycle.md
Last active September 26, 2018 17:07
Blue Dev cycle

Grab a new issue (ex: #2468) from HuBoard's Next Actions column self assign it and move it to the Development column

Make branch based of the issue number proceeded by x-: git checkout -b x-2468

Finish the issue

Run unit tests: bundle exec rake test:unit

Run interaction tests from Visual Studio

@barretts
barretts / setup-iis.ps1
Created May 17, 2018 16:18
Powershell script to install IIS
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServer -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-CommonHttpFeatures -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-StaticContent -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-DefaultDocument -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-DirectoryBrowsing -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpErrors -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpRedirect -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationDevelopment -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASP -All
Install nodemon
npm install -g nodemon
Copy this file to your $HOME folder
https://gist.github.com/styson/7d56bafc9d1b7fe1ff1d3dd907b7bf0c
run this command from your bash cmd window
@barretts
barretts / Golf Course.less
Created July 11, 2017 16:48
Golf Course Dovetail Agent theme
@import "../agent/a5-theme";
/**
* ____ _ __ ____
* / ___| ___ | |/ _| / ___|___ _ _ _ __ ___ ___
* | | _ / _ \| | |_ | | / _ \| | | | '__/ __|/ _ \
* | |_| | (_) | | _| | |__| (_) | |_| | | \__ \ __/
* \____|\___/|_|_| \____\___/ \__,_|_| |___/\___|
*
*/