Okay, finally, we’re going to talk about something other than errors. This is the story of how I destroyed $25,000 of company property and got a pat on the back for my efforts.
Or at least, I haven’t been fired.
It’s not clear to me how to describe the code. Maybe this?
It’s hard to portray “I deleted 1,700 lines of code.” But that’s what I did: I deleted 1,700 lines of code.
Continue Reading
Last time we talked about errors. And though I’m loath to think about anything for longer than a week at a time, errors are so core to our existence as developers that I feel we must talk about them.
(obviously, they’re core to your existence, my code has no bugs and therefore never errors)
In particular, I want to tell you the story about this error:
Error Code: -1074114855 For context, these days at work I’m playing a bit of customer support for a customer using a beta product in Japan.
Continue Reading
The astute reader may have noticed, I pulled a fast one in the last blog post. Last week, we replaced this code:
if (regex_match(portIterator->second, boost::regex("0*([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]);"))) { ... } with this:
const int port_no = std::stoi(portIterator->second); if (port_no <= 65535) { ... } and we sort of left it at that, and moved on to other things.
But these code pieces actually aren’t equivalent, for two reasons. First, stoi will accept a negative number, so the condition should be: port_no >= 0 && port_no <= 65535.
Continue Reading
Dear Candace,
You have sent me three links.
The first, https://www.bitchute.com/video/nFMwCaApptoe/, is a link to an English conspiracy theorist.
The second, https://www.bitchute.com/video/xwSVyw5jbdzH/, is a link to an American antivaxxer.
And the third, https://rumble.com/vbortj-covid-vaccine-changes-dna-and-has-aborted-fetal-tissue.html, came with a condemnation that I’m not thoroughly watching your videos, I’m just dismissing them. You say I’m not researching, I’m just talking down the info you have posted.
But here’s the thing. I’ve already done my research.
Continue Reading
if (regex_match(portIterator->second, boost::regex("0*([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]);"))) { ... } if you look at it hard enough, you can tell what the regex does. But, if you’re not familiar, it comes with the comment:
// check the RPC port number which is an unsigned 16-bit integer. The value ranges from 0-65535 (also, I highly recommend the website regex101.com, if you don’t have it already bookmarked)
Obviously, regex isn’t anybody’s first choice to see if a number is an integer.
Continue Reading
It’s a point that I have, and will continue to, drive home on this blog: In professional software engineering, code readability is paramount. Its importance is second to none.
When you’re evaluating a language, especially, it’s important to consider more than just whether the programming language is turing complete (or, more generally, whether it can do all the things you need it to). You should also consider how conducive the language is to being read or reviewed.
Continue Reading
So I was working on some driver code for a device the other day, and came across this interesting bug. The device has a clock rate that a user can specify, they can choose from one of several options (call them 10MHz, 11MHz, 40MHz, and 44MHz). The user can also pre-configure a “multiplier” option on their device (by loading a different FPGA bitfile), which has two options: x1 and x4. As you might’ve guessed, the 10MHz and 11MHz selections only work when the multiplier is set to x1, and the 40MHz and 44MHz options only work when the multiplier is set to x4.
Continue Reading
I’m going to break from my usual style (again) and go for a more ranty style with more blatent product placement.
If you like this kind of content, remember to smash that like button and catch me live over on Twitch. (I’m just kidding, I don’t blog or program live on Twitch, although maybe I should?)
Anyway. C/C++ includes. Love them, hate them, but we’ve all seen (and written) code like this:
Continue Reading
} + closeDir(dirPtr); } Today’s post is slightly unusual - we won’t talk about code, or coding conventions, or about how much more clever Rust is than C++ (which is a lot), today we’re going to talk about Process. And source control. This snippet of code is small, and ultimately not particularly important, but it highlights a not often talked about process in software engineering.
So the codebase I’m working in now has a dependency on a “SDK” provided by one of our vendors.
Continue Reading
So several months ago, I had to write this (C++) function:
std::vector<uint8_t> extract_bitstream(const std::string& original_bitstream) { std::string encoded_bitstream(original_bitstream); // Strip the whitespace encoded_bitstream.erase(std::remove_if(encoded_bitstream.begin(), encoded_bitstream.end(), [](char c) { return std::isspace(c); }), encoded_bitstream.end()); // Decode the result namespace bai = boost::archive::iterators; using base64_dec = bai::transform_width<bai::binary_from_base64<char*>, 8, 6>; std::vector<uint8_t> bitstream(base64_dec(encoded_bitstream.data()), base64_dec(encoded_bitstream.data() + encoded_bitstream.length())); // Remove null bytes that were formed from the padding const size_t pad_count = std::count(encoded_bitstream.begin(), encoded_bitstream.end(), '='); bitstream.erase(bitstream.end() - pad_count, bitstream.
Continue Reading