Skip to content

Instantly share code, notes, and snippets.

@alexharv074
alexharv074 / hashdiff.sh
Created March 5, 2024 10:55
Hashdiff function
# Add this in ~/.zshrc
# Dependencies:
# Ruby
# gem install hashdiff
# gem install awesome_print
hash_diff() {
if [[ "$#" -ne 2 ]] ; then
echo "Usage: hash_diff YAML_FILE1 YAML_FILE2"
@alexharv074
alexharv074 / chat.md
Last active February 5, 2023 08:18
Chat Bash exam

ChatGPT Bash Exam

I tested ChatGPT to see if it could pass a Bash programming exam using questions of its own choosing. My assessment is that the bot scored 1/5 and failed.

Table of contents

  1. The questions
  2. Question 1
#!/usr/bin/env python3
import json
import uuid
import os
import sys
from time import strftime, localtime
from typing import Generator
d89ddb1 (from 95febfb) Merge branch 'master' of ../jenkins into alex/jenkins
A .gitignore
A .rspec
A Gemfile
A Makefile
A README.md
A TODO.md
A assets.json
A bake.sh
A cloudformation/buildbox.yml
#!/usr/bin/env python
import pprint
def merge(x,y):
return dict(x, **y)
ebs_block_device = [{
'device_name': "/dev/sdg",
'volume_size': 5,
#!/usr/bin/env ruby
require 'json'
require 'open3'
class TerraformTesting
@@terraform = "#{ENV['HOME']}/go/bin/terraform"
def eval(path, addr, mock_data)
command = "#{@@terraform} testing eval #{path} #{addr} -"
#!/usr/bin/env bash
# Code for my blog post at:
# https://alexharv074.github.io/2019/06/09/adventures-in-the-terraform-dsl-part-v-conditional-logic.html
t011=/usr/local/bin/terraform
t012=/usr/local/bin/terraform012
data() {
cat <<EOF
## Using the original template
+ sam deploy --template-file packaged.yaml --stack-name HelloWorld --capabilities CAPABILITY_IAM
Waiting for changeset to be created..
Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Invalid template property or properties [Api]
+ exit 255
## Template after correcting errors
# test.sh
#!/usr/bin/env bash
for n in aaa bbb ccc ; do
mv $n $n.bak ## Quoting not required if
done ## inputs are known.
for n in ddd/* ; do
mv "$n" "$n.bak" ## Quoting *is* required if
## Unit test code
run() {
case "$SCRIPT" in
AlexHarvey)
gsed $1 '
1{
/999/d
}