Supercharging My Workflow with GPT-4: A Love Story

@kjuulh

2023-04-07

Introduction

This post is about my current workflow with gpt4 and gpt3.5. I've written this to show how I use it, and why I think it is the future.

I was perviously a skeptic about gpt, and what it would mean for developers, engineers, and just though workers in general. However, after having actually tried to use it. In the beginning gpt3.5 (chatgpt), and because I was so impressed and the fact that it enhanced my workflow that much I decided to purchase gpt4 (chatgpt plus) .

My primary work is building tools and infrastructure. Kind of a mix between a fixer and a hacker. That means that I usually switch between a lot of languages and systems, some of which I don't have a deep expertise in.

Workflow

The next few sections will be a few situations where I've used chatgpt.

The blank page problem

Give it a very basic draft or summary of what I want to create.

Example prompts could be:

Script

User> Please create a script to extract docker image layers. You should download the image, extract it to a tmp folder and further extract the layers into a shared directory lets call it layers

GPT> <code>

User> <further corrections>

It doesn't give the right answer immediately but close enough that I can either nudge it in the right direction or fix the minor mistakes myself, which is what I did in this case, because it was so close.

This was the final result:

#!/bin/bash
set -euo pipefail

# Parse command line arguments
while [[ $# -gt 0 ]]; do
    key="$1"
    case "$key" in
        --image)
            IMAGE_NAME="$2"
            shift
            shift
            ;;
        *)
            echo "Error: Unknown option: $key"
            echo "Usage: $0 --image IMAGE_NAME"
            exit 1
            ;;
    esac
done

# Define the path to the temporary directory where the files will be extracted
DESTINATION="/tmp/docker_images/${IMAGE_NAME}"
MANIFEST="${DESTINATION}/manifest.json"

# Define a function to download and extract the Docker image layers
function extract_docker_image {
    # Save the Docker image as a tar file
    echo "Saving Docker image as a tar file..." >&2
    docker save "$1" -o "${DESTINATION}/${IMAGE_NAME}.tar"

    # Extract the Docker image layers to the destination directory
    echo "Extracting Docker image layers..." >&2
    mkdir -p "${DESTINATION}/layers"
    tar -xf "${DESTINATION}/${IMAGE_NAME}.tar" -C "${DESTINATION}/"

    # Rename the layer directories to their respective layer IDs
    LAYERS=$(jq -r '.[0].Layers[]' "${MANIFEST}")

    # Extract each layer
    for LAYER in ${LAYERS}; do
      BLOB="${LAYER}"
      # Extract the layer tar file to the destination directory
      echo "Extracting layer ${LAYER}..." >&2
      mkdir -p "${DESTINATION}/$(dirname ${BLOB})"
      tar -xf "${DESTINATION}/${BLOB}" -C "${DESTINATION}/layers"
      echo "Layer ${LAYER} extracted" >&2
    done
}

# Ensure that the user has provided the Docker image name using the --image flag
if [ -z "$IMAGE_NAME" ]; then
    echo "Error: Docker image name not provided." >&2
    echo "Usage: $0 --image IMAGE_NAME" >&2
    exit 1
fi

# Create the destination directory if it doesn't already exist
rm -rf "${DESTINATION}"
mkdir -p "${DESTINATION}"

# Call the function to download and extract the Docker image layers
extract_docker_image "$IMAGE_NAME"

Blog post

Next I've asked it to generate a skeleton of a blog post for me.

User> Please generate a draft of a blogpost about why platform engineering is the next era of infrastructure development. Only write the sections so that I can fill it out myself

GPT> <article>

See my last post for the headings.

I then went ahead and wrote the post, finally I asked it to proof read the entire article.

Rust cli

I gave it a few pointers to generate a cli, this was probably the most wonky example, as clap has had major revisions since 2021. However, I just pasted most major revisions and it corrected it itself.

User> Please generate a cli app for releasing software based on semantic versioning, include commands such as release, validate and bump, all which should use semantic versioning, please use rust and the clap library

GPT> <code>

User> Please use these clap revisions and update the code to use these instead: <clap revisions>

GPT> <code>

The code still had some issues but it was a great starting point

Proof reading and writing

ChatGPT is great a writing articles and can quickly infer what points you want to argue for. I've given it small sections and had it expand on it and proof read it. However, it is usually quite stiff and neutral in tone.

However, you can tune chatgpt to your liking, I.e.

User> From now on please act like a well known blog post writer, write in a whitty, concise and clear manner, but include humor where possible. Write OK if you understand

GPT> OK

User> please expand on this article and write it in the manner mentioned above:

<draft>

GPT> <post>

This actually makes a big difference and writes the post in a clear but personal manner, totally different than the neutral tone it held when just prompting it normally.

Generation of stuff

I've asked gpt to generate various things for me, such as yaml for these blog posts, it can infer the tags and if given an example of the yaml will automatically fill it out.

I've asked it to generate tests for various functions, which it has done to great success.

I've also just given it a cli help description and asked it to produce a readme for me.

API

I've not gotten access to the API yet, but I've already simulated what I want it to do using the web interface. That is generate a meal plan from a recipe list I've curated myself, choose them for the given day, write descriptions add recipes etc.

All these steps have been tested individually and I am just waiting for access before I can implement it in my meal planner.

Conclusion

The possibilities are endless, I feel like my development have been super charged, I can quickly generate boiler plate and syntax even given vague descriptions. ChatGPT has solved the blank page problem for me as I can quickly throw an idea out there and it generated a draft for me, which I can refine or use as an idea generator.

I've used it for development, and is preparing for integrating it into my toolstack and every day. It is an awesome tool, if this continues then the future is brigt.

ChatGPTs take

User> From now on please act as a well known tech blog writer, write in a whitty, clear and concise manner. Write OK if you understand

GPT4> OK

User> <entire post copy/pasta>

I don't remember gushing over gpt that much, but it really speaks its own praises

From Skeptic to Devoted Fan: How GPT-4 Transformed My Workflow

There I was, a once-skeptical soul, questioning the value of GPT and its potential impact on developers, engineers, and thought workers alike. But then, I dipped my toes into the refreshing waters of GPT-3.5 (ChatGPT), and I was hooked! Now a proud GPT-4 (ChatGPT Plus) owner, I'm here to share how it revolutionized my workflow.

As a jack-of-all-trades, I find myself juggling a variety of languages and systems, often with less-than-perfect expertise. But fear not, for GPT-4 has come to the rescue!

The GPT-4 Workflow Chronicles

Allow me to regale you with tales of how ChatGPT has supercharged my productivity.

Conquering the Blank Page Problem

No more staring into the abyss of a blank page! I simply provide a basic draft or summary, and ChatGPT whips up something marvelous.

Scriptwriting Made Easy

Imagine needing a script to extract Docker image layers. Instead of sweating over every detail, I give GPT-4 a quick rundown of my requirements, and voilà, a near-perfect script is born!

Blogging Like a Pro

When tasked with writing a blog post, I ask GPT-4 for a skeleton, and it promptly delivers. Then, I fill out the content, and let ChatGPT proofread the masterpiece. Simple, efficient, and delightful!

Rust CLI Adventures

Though my initial request for a Rust CLI app using the Clap library was slightly off due to outdated information, a quick update on Clap revisions had GPT-4 churning out a solid starting point.

Unleashing the Wordsmith Within

While ChatGPT is adept at generating content, it can be a bit neutral in tone. However, a simple instruction to adopt a witty, concise, and clear writing style, sprinkled with humor, makes all the difference.

Masterful Generation of Stuff

From YAML files for blog posts to function tests and even READMEs, GPT-4 has me covered. It's like having a digital personal assistant for all things code.

The API Possibilities

Though I haven't yet accessed the API, I've been testing individual steps to create a meal planner. Once I gain access, the sky's the limit!

Conclusion: A Bright Future Ahead

GPT-4 has truly supercharged my workflow, solving the blank page problem and providing endless possibilities. From development to everyday tasks, it's a game changer. If this is the future, my friends, it's going to be a wild ride.