Unless you’ve been living under a rock, you’ve probably heard the buzz surrounding ChatGPT 🤖 and other LLMs. People worldwide are harnessing the power of these technologies to skyrocket their productivity at work and in their personal lives. As a developer, I’ve been utilizing ChatGPT for a while now, and it has truly revolutionized my productivity. Allow me to share some real-life examples of how ChatGPT has transformed my efficiency. 💪✨
Writing Complex (or Mundane) Code
When you’re developing with multiple considerations and tight timelines ⏳, delving into intricate details, especially domain-specific ones, can distract and hinder your progress. It’s crucial to maintain focus 🎧 and avoid unnecessary slowdowns. Recently, while working on a Minimum Viable Product (MVP), I encountered a situation where I needed to determine if the contents of an input file were ASCII, UTF-8, or binary. Rather than spending time researching 🔎 the disparities between Unicode and binary and creating the logic from scratch, I opted to seek assistance from ChatGPT. With a simple prompt, I effortlessly 🚀 generated the following function to accomplish the task at hand. Here’s the code provided by ChatGPT: 💡🤖
#include <iostream>
#include <cstring>
enum class EncodingType {
ASCII,
UTF8,
BINARY
};
EncodingType detectEncoding(const char* data) {
unsigned char* bytes = reinterpret_cast<const unsigned char*>(data);
// Check for BOM (Byte Order Mark) indicating UTF-8
if (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) {
return EncodingType::UTF8; // BOM detected, assume UTF-8
}
bool containsNonASCII = false;
for (size_t i = 0; i < strlen(data); ++i) {
if (bytes[i] & 0x80) {
containsNonASCII = true;
break;
}
}
if (!containsNonASCII) {
return EncodingType::ASCII; // No non-ASCII characters, assume ASCII
}
// If the data contains non-ASCII characters but not a BOM, assume it's binary
return EncodingType::BINARY;
}
int main() {
const char* asciiText = "This is a sample ASCII text.";
const char* utf8Text = u8"This is a sample UTF-8 encoded text.";
const char* binaryData = "\x41\x42\x43\x44\x45"; // Example binary data
switch (detectEncoding(asciiText)) {
case EncodingType::ASCII:
std::cout << "The data is ASCII encoded." << std::endl;
break;
case EncodingType::UTF8:
std::cout << "The data is UTF-8 encoded." << std::endl;
break;
case EncodingType::BINARY:
std::cout << "The data is binary." << std::endl;
break;
}
switch (detectEncoding(utf8Text)) {
case EncodingType::ASCII:
std::cout << "The data is ASCII encoded." << std::endl;
break;
case EncodingType::UTF8:
std::cout << "The data is UTF-8 encoded." << std::endl;
break;
case EncodingType::BINARY:
std::cout << "The data is binary." << std::endl;
break;
}
switch (detectEncoding(binaryData)) {
case EncodingType::ASCII:
std::cout << "The data is ASCII encoded." << std::endl;
break;
case EncodingType::UTF8:
std::cout << "The data is UTF-8 encoded." << std::endl;
break;
case EncodingType::BINARY:
std::cout << "The data is binary." << std::endl;
break;
}
return 0;
}
If you have a keen eye 👁️, you might notice some bugs 🐛🐜 in this code. However, it served as a great starting point for my implementation. Hours of effort saved!
In another instance, while working on the React components for the MVP, I provided ChatGPT with the complete requirements for the desired React UI functionality. Remarkably, ChatGPT effortlessly generated flawless code that perfectly aligned with my specifications. Hours of effort shaved off. ⏰💪💾
Writing Documentation
I know, us developers hate it 😡. But sometimes, writing documentation 📕is important to enhance the readability of code. Don’t worry, because you don’t have to do it anymore. Just write your code and let ChatGPT add comments to it 🥳. Here’s an example. The comments in the code below have been automatically added by ChatGPT.
// Event handler for changes in appearance settings triggered by user interactions
const onAppearanceSettingChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
// Retrieve the selected appearance option from the changed input element
const selectedOption = e.target.value;
// Check if the selected appearance type is valid
if (!isValidAppearanceType(selectedOption)) {
// Log a warning for unrecognized appearance type and exit the function
logger.warn('Unrecognized appearance selected', selectedOption);
return;
}
// Update the appearance setting in the database and handle the promise
window.dbAPI.updateSetting(DBSettingName.APPEARANCE, selectedOption).then(() => {
// Upon successful database update, update the local state
setAppearance(selectedOption);
// Trigger an event to notify other parts of the application about the appearance setting change
trigger('appearance-setting-changed', null);
});
};
Portfolio Creation — Appraisals coming up? 🤑
This is one of those tasks that developers would never undertake if it wasn’t absolutely necessary 🙈. If we can’t eliminate it altogether, the next best approach is to expedite the process, thereby reducing the time it takes. Here are some experiments 🧪 you can try to accelerate your portfolio creation process.
- Generate Project Title/Description: For each project, input the project charter and related documents, and request ChatGPT to generate a title and description for your project. Based on whether it’s a technical or business review, ask ChatGPT to incorporate relevant information as necessary.
- Generate Description of your Contributions: For each project, provide ChatGPT with your task list 📋 (from JIRA or other tools) and ask it to generate a summary of the work you have completed in that project.
- Make it Impressive: ✨ Inform ChatGPT about the reviewer who will be assessing your portfolio and inquire about the specific data or presentation aspects that might interest them. For instance, if an Engineering Manager is reviewing your work, they would be more inclined towards technical details. ChatGPT can provide you with a list of relevant metrics that you can include in the document. On the other hand, if an executive is reviewing your work, ChatGPT can suggest business metrics that should be incorporated for each project. Depending on the type of reviewer, ChatGPT can autonomously adjust the content, including the title and description itself.
- Proofreading/Editing: A true professional takes pride in their work 🧑💻. The last thing you need is for your work to be undermined by English and grammatical mistakes in your portfolio. Ask ChatGPT to review your document, proofread it, and fix 🔧 any issues to ensure its quality 👌. If you’re not using ChatGPT extensively, you’re missing out 😢 on increased productivity and the opportunity to save precious time every day.
If you are a frequent ChatGPT user, take it to the next level by pairing it with Griv. Griv allows you to access ChatGPT within your workflows. Check it out at https://grivhq.com.
Disclosure: I’m the creator of Griv.
Top comments (0)