Happy Spring! Some folks are closing out the first quarter of 2023, and others are wrapping up their taxes. But many are talking about ChatGPT. I’ve got a lot of opinions myself, but in this issue, I’m going to share a few ways you can use it right now to do some tasks faster, along with some warnings to keep in mind. I’m also excited to share a tool I’ve been using to copy files securely between computers with different operating systems without installing servers or worrying about permissions.
ChatGTP is on many people’s minds. To some, it’s the greatest invention in years. To others, it’s a terrifying tool that’s already eliminating jobs. I’ve seen it solve some problems well, and I’ve seen it write the most useless, surface-level nonsense I’ve seen in ages.
I’ve got my concerns about ChatGPT and other AI tools, especially since this tool seems to be at the “peak of inflated expectations” on Gartner’s hype cycle. Still, I will save a lot of time and space here because the reality is that these various AI tools exist, and we have to contend with them, so it’s worth looking at leveraging them like you would any other tool. It’s a good bet that your peers already are.
Here are three use cases where I’ve seen people use ChatGPT. I’ve been trying them for the last month, and I’d encourage you to explore them as well.
I’m not great at Python. I can read it and understand it, but it’s not something I’ve spent a lot of time with over my career. I’ve found that ChatGPT is reasonably good at translating small bits of code from one language to another.
For example, I fed the following code to ChatGPT while writing this newsletter. It’s Go code that defines a basic HTTP server that returns a JSON response:
import (
"encoding/json"
"net/http"
)
type messageResponse struct {
Message string `json:"message"`
}
func indexHandler(w http.ResponseWriter, r *http.Request) {
response := messageResponse{Message: "Hello from the service"}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(response)
}
func Run() {
http.HandleFunc("/", indexHandler)
http.ListenAndServe(":9292", nil)
}
I asked ChatGPT how this might look in Python with Flask.
It translated the code and gave me a working example:
from flask import Flask, jsonify
app = Flask(__name__)
class MessageResponse:
def __init__(self, message):
self.message = message
@app.route('/')
def index_handler():
# Create the response
response = MessageResponse("Hello from the service")
# Return the response as JSON
return jsonify(message=response.message)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=9292)
It’s not exactly how an experienced Python developer would write this, but it’s enough to give me an idea of where to start. I can now ask it additional questions about the implementation, and even ask it why it chose the approach it did.
When you’re not sure how to approach a problem in one language that you know how to solve in another, this can be one way to make some quick progress that you can refine as you learn more.
ChatGPT isn’t at the point where it will write everything for you. In fact, it will often confidently make things up once you get past surface-level things, so you still have to bring a lot of understanding to the table. But you can use it to start understanding a new problem.
Let’s say you heard a manager at work talk about the RACI framework. You could go to Google to figure this out, but I’d go to ChatGPT with this prompt:
Explain the pros and cons of the RACI framework to someone new to the topic.
Unlike search engines, you use natural language to ask questions, which means you ask for what you want and tell ChatGPT who the audience is for that response.
The response you’ll get will look something like this:
The RACI framework is a tool used in project management to clarify and define roles and responsibilities within a team. The acronym RACI stands for Responsible, Accountable, Consulted, and Informed. Here are the pros and cons of the RACI framework:
You’ll then get a list of pros and cons. It’s surface-level information you could get from a search engine, but you got it quickly without sifting through results and clicking through. And while it’s surface-level, you now have additional information you can use as a springboard. For example, one of the RACI framework drawbacks ChatGPT suggested was this:
Can create confusion: If roles and responsibilities are not clearly defined or if there is a lack of understanding of the RACI framework, it can create confusion and misunderstandings.
So a follow-up prompt might be:
You said that this framework can create confusion and misunderstandings if roles and responsibilities are not clearly defined. What are three specific things I can do to ensure I define roles?
You’ll get some additional suggestions that might give you further ideas. One of the responses I got said this:
For example, instead of assigning a broad responsibility like “marketing strategy,” break it down into specific tasks like “developing marketing campaign themes,” “creating social media content,” or “designing promotional materials.” This way, it is clear who is responsible for each specific task.
Continue probing and asking questions in different ways to keep digging into a topic, and then use other resources to verify it. Use it as an accelerator. The key here is to use the same rule you’d apply to anything else on the Internet: don’t believe everything you read. Verify it. But with ChatGPT, you can move a lot faster than you would with other methods.
ChatGPT can recognize patterns and pieces of code. Try asking it to explain a regular expression.
Can you explain this regex?
/^[a-zA-Z0-9.!#$%&’+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)$/
The response breaks down the regular expression piece by piece.
You might argue that this one’s easy because it’s a well-known regular expression. That’s true, but a quick Google search doesn’t give me a detailed breakdown. I’d need to use a site like regex101 instead. And honestly, a lot of code you’ll encounter is common. Code is a tool to ship working software, and the entire industry has been copying and pasting common code snippets for ages. What’s common for one person is completely foreign to another.
But what was transformative for me was when I recently used ChatGPT to help me figure out why a particular command wasn’t working in my shell. It quickly pointed out my very obvious mistake. My Google searches weren’t helping because I assumed the error was with something else. I gave ChatGPT the command and told it what was happening, and it told me exactly what I’d done wrong. And once I saw the answer, I was a little embarrassed that I hadn’t figured it out myself.
You can probably think of other use cases too, but it’s important to remember that this is an evolving tool that sometimes gives wrong answers in overly confident ways. But humans do that too, and often as confidently as ChatGPT does.
You should think of ChatGPT as another tool like Google, Grammarly, or Stack Overflow; use it and apply your judgment on top of it. People will use ChatGPT to get things done faster, and you should explore it more to see if you can too.
croc
Transferring files and text between computers, especially if those computers run different operating systems, requires that you run some sort of client/server setup. You can use network shares, SFTP, rsync, and other tools to transfer files, but croc lets you do this with only a single command line program that you install on both computers. These computers don’t need to be in the same location for this to work since croc
can use relays to route the traffic, and the data you send is end-to-end encrypted.
You can install croc
using your package manager or by downloading the binary for your system from the releases page and placing the croc
binary on your system `PATH.
To send a single file with croc
, specify the send
argument and the file you want to send. To send the file index.html
, you’d use this command:
croc send index.html
When you issue the command, you’ll get code you can use, along with instructions you can use to retrieve the file on another machine:
Sending 'index.html' (278 B)
Code is: 1337-one-two-three
On the other computer run
croc 1337-one-two-three
Once you’ve received the file on another machine, croc
executes automatically on the source machine.
You can send multiple files with croc
. You can specify them one by one like this:
croc send index.html style.css
You can use a wildcard:
croc send *.html
And you can even send an entire folder:
croc send images
Each time, croc
gives you a unique code to send to the recipient so they can grab the file. And if you don’t want to use an auto-generated code, you can specify your own with the --code
flag:
croc --code bph-website send *.html
Finally, if you just need to send some text to another machine, you can do that with the --text
option. To send the super-secret password of 12345
to another machine, use the following command:
croc send --text "12345"
Like before, croc
gives you a code to share:
Sending 'text' (5 B)
Code is: 1234-five-six-seven
On the other computer run
croc 1234-five-six-seven
To receive the text on another machine, you use croc
followed by the code, just like you would if you used a file. The text payload displays on the screen instead. You can redirect that output to a file if you’d like using standard shell redirection.
I’ve been using this to transfer configuration files between macOS and Windows machines, and it’s worked well. I’ve been using Remote Desktop connections between machines to send and receive the files, and it’s been a lot faster than setting up clients and servers.
Give it a try.
Thanks for reading this issue. Tools like ChatGPT are definitely going to impact how we all work, just like better IDEs and other accelerators have. One of the biggest challenges in this industry is that new things come along and change how we work. We have to adapt the way we work and the way we think about things. Hopefully, I’ve given you some things to think about over the next month, but here are a few more:
croc
command uses public relays to connect recipients to senders. Look at the croc README file to see how to use your own self-hosted relay for extra security.As always, thanks for reading. I appreciate you coming along with me on this experiment. See you next month!
-bph
I'd love to talk with you about this newsletter on Mastodon, Twitter, or LinkedIn. Let's connect!
Please support this newsletter and my work by encouraging others to subscribe or by buying a friend a copy of Exercises for Programmers, Small, Sharp Software Tools, or any of my other books.