Let’s talk about ChatGPT

Comments Off on Let’s talk about ChatGPT
AI

Because, why not? I thought it would be cute to see if I could get it to write an article about my experience setting up my own pfSense router (and being a software developer, it was a bit of an animal for me). With a rough descriptive prompt, including to use my style of writing, it came up with a short article that sounded like a transcript from a TikTok video. Yeah, awful.

I tried to refine it by telling it to use the style found on russjudge.com (this site), but the result wasn’t much better. When it opened up with “Hey everyone, it’s your boy Russ Judge, and today I want to talk to you…”, I knew I was in trouble. The article sounded like a hyperactive narcissist on ten cans of Red Bull. It made me think that ChatGPT must be part of the Gen Z generation.

The reality that I’ve found about ChatGPT is that it is a terrific tool. I’m not sure about it’s English writing skills, but I’ve been using it a lot to help me in my job as a software developer–and no, it didn’t help me with this article (I’d be too scared to try). As a programmer who works regularly with at least 4 different programming languages, including Javascript, PHP, C#, and SQL, each with their own nuances of syntax, it’s not possible to keep in my head every little detail of all the languages. I regularly google for solutions to small problems, sometimes re-googling for the same problem three days later. So, I’ve started going first to the free version ChatGPT and posting my queries there-with amazing results. In some cases, I’ve just given a basic description of what I want and had it write an entire program. There’s usually some back-and-forth to refine the program for what I need, but in five minutes I can get a fully working program that would have taken me over an hour to write, including all the googling I would have had to do.

A simple example was that I wanted to create a BASH script (for which I am rather inexperienced in) that would get the quote of the day from the “They Said So Quotes API” (https://quotes.rest), and the update the message of the day file (/etc/motd) on my Linux servers. That was pretty much the extent of the prompt I gave to ChatGPT. It quickly spit out working code–except that the quote it got was blank. I’m also not very familiar with how to use grep, so I couldn’t easily tell what was wrong with the code. I told ChatGPT that the code was wrong–that returned blank, so it tried again. After the third iteration, it finally came up with fully working code, which I’ve included below (along with some additional tweaks of my own).

As a work tool, ChatGPT is invaluable. I’m even considering paying the $20 a month for a subscription to the premium version. I’ve heard many fears that it will replace people in their jobs, but I see it as a way to take the grunt work off of me, where I can focus on the logic of what I want done, and then refine what ChatGPT spits out to better suit my needs. In my opinion, it gives me the freedom to focus more on the details of the tasks, as opposed to the syntax of the code.

Another time I had a Javascript program that was something around 500 lines long. There was a syntax error somewhere in that mess, but I couldn’t find it. My editor probably highlighted it, but it was lost in the sea of code. I asked ChatGPT, “What is wrong with this code:” and copy and pasted the code in. Instantly, ChatGPT pointed out a colon I had placed instead of a semi-colon, which saved me a good hour of numbingly staring at my screen to find the thing.

I talked to one of my friends who works at a local community college, and he told me that some computer programming professors are prohibiting the use of ChatGPT in their class. Although I can see that point when you are trying to teach beginners the basics of programming, once the coding gets more sophisticated, I see ChatGPT as a way to more quickly learn the skills needed to get in a programming career. In my use of ChatGPT, I learned from ChatGPT far more quickly than if I had to spend time googling for the answer, scouring through the tech forums like Stackoverflow and such. Where this scouring would take me 30 minutes to an hour to find an answer for, ChatGPT does in under 5. The learning curve in using ChatGPT is learning how to phrase your prompt to get the best results.

So, what are your thoughts? Even though my experience with its use of writing articles was a bust, I think Hollywood could learn a thing or two from it. Heck, I say fire all the Hollywood writers and just use ChatGPT. Can’t possibly get any worse doing that.

Anyway, here’s the code I mentioned:

#!/usr/bin/bash
#Author: ChatGPT and Russ Judge
# Below is my code--this makes sure it was executed with BASH, so that
#  the ANSI coding works.
if [ -z "$BASH" ]
then
    exec bash $0
    exit
else
    # This part is from ChatGPT:
    # Fetch the quote of the day from the website
    response=$(curl -s https://quotes.rest/qod?language=en)

    #These are the failed lines from ChatGPT.
    #quote=$(echo "$response" | grep -o '"quote":"[^"]*"' | cut -d '"' -f 4)
    #quote=$(echo "$response" | grep -oP '(?<="quote":")[^"]*')
    #quote=$(echo "$response" | sed -n 's/.*"quote":"\([^"]*\)".*/\1/p')

    # This is where it started working, from ChatGPT. I had to install "jq", though.
    quote=$(echo "$response" | jq -r '.contents.quotes[0].quote')

    #I added this line--I never told ChatGPT to code for getting the author of the quote.
    author=$(echo "$response" | jq -r '.contents.quotes[0].author')

    #I also added this conditional--I found in my testing that the
    # "quote" could be null if the website was queried more than
	#  10 times in an hour.
    if [ "$quote" == "null" ]
    then
        echo "Bad response retrieving quote of the day."
    else
        #Below is both me and ChatGPT together.  It originally just
        # dumped the quote into the /etc/motd file.  I added a little
        # flurish with ANSI coding--for the heck of it.
        # Modify the motd file with the quote of the day
        echo -ne "
\e[0;32;40m==========================================================\e[0;37;40m

\e[1;37;40m        Russ's Server: $HOSTNAME\e[0;37;40m

\e[0;32;40m==========================================================\e[0;37;40m


$quote
                          -$author

==========================================================

" > /etc/motd
    fi
fi