Thursday, March 14, 2019

CodeSOD: Ancient Grudges

Ignoring current events, England and the rest of Europe have had a number of historical conflicts which have left a number of grudges littered across the landscape.

Andro V lives in Norway, but is remotely collaborating with an English developer. That English developer wants their peers to know that Sweyn I and Thorkell the Tall’s invasions of southern England will never be forgotten.

/// <summary>
/// A counter that is to be read in reverse and computed in a Viking way. It usually is followed by a buffer which must be parsed in reverse order.
/// </summary>
public static int Read3F1(this BinaryReader reader, bool reverse = false)
{
    const float VIKINGS_INVADES_ENGLAND = 1009.0f;
    int counter = (reverse ? reader.ReadInt32Rev() :          
      reader.ReadInt32());
    // Debug.Assert(counter % 0x3f1 == 0, "Wrong data for 3f1 counter: 0x" + counter.ToString("X8"));
    counter = (int)Math.Round((counter / VIKINGS_INVADES_ENGLAND) - 1.0f); // The VIKINGs magic computation
    return counter;
}

The year 1009 involved a lot of Viking invasions of southern England. But, like all old grudges, it arises from an even earlier grudge, as in 1002, English king Aethelred the Unready massacred all the Danes living in England. Of course, that was in response to a few years of raids prior, and, well… it’s ancient grudges and blood fueds all the way down.

[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!


To read the full article, please visit The Daily WTF

Golden Retrievers Love to Hug Each Other

Golden Retrievers Hug Each Other in the Water Check out this adorable video of these two Golden Retrievers hugging it out in the water! We all know how lovable and affectionate Golden Retrievers are, but did you know how much they love each other? We can’t get enough of these two as they hang out […]

The post Golden Retrievers Love to Hug Each Other appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Wednesday, March 13, 2019

Oblivious Jogger Literally Runs Into Alligator

Unassuming Jogger Runs Into Alligator Check out this hilarious video as this jogger literally runs into an alligator during his run! He was concentrating so greatly on his workout that he didn’t see the huge alligator laying in his way! We’re glad this alligator chose to hop back into the water instead of attack! Check […]

The post Oblivious Jogger Literally Runs Into Alligator appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

How It's Made

People like hot dogs until they see how it's made. Most people don't ask, because they don't want to know and keep eating hot dogs. In software, sometimes we have to ask. It's not just about solving problems, but because what scares some programmers is the knowledge that their car's software might be little more than the equivalent of driving duct-taped toothpicks down the highway at 70MPH. Our entire field is bad at what we do.

Brett worked as a system analyst for a medical research institution, MedStitute. MedStitute used proprietary software for data storage and analysis, called MedTech. Doctors and researchers like MedTech's results, but Brett his co-worker Tyree- know how it's made.

The software has no backend access, and all software development happens in a "click-to-program" GUI. The GUI looks like it was built from someone who learned to code by copy/pasting from 1990s era websites, watching ten minutes of Jurassic Park, and searching StackOverflow until something compiled. The "language" shows the same careful design philosophy. Every if must have an else. Some modules use booleans, some return an empty string to represent false values. Documentation is unclear about which situation is which. Essentially, every if statement becomes three statements.

Brett needed to launch a new study. A study depends on some basic set of statistics and groups patients based on a randomized variable. Brett looked through the list of variables he could randomize on, and the one he wanted was missing. Brett assumed he made a mistake, and went back a few screens to check the name, copying it down for reference. He went back to the list of randomizable variables. It wasn't there. He looked closer at the list. He noticed that the list of randomized variables only included data from multiple-choice fields. The field he wanted to randomize on was based on a calculated field.

Brett knew that Tyree had worked on another project that randomized on a calculated field, so he messaged Tyree on Slack. "How did you code this random variable? In Medtech it won't let you?"

"I'm on a conference call, let me call you afterward," Tyree wrote.

A few minutes later, Tyree called Brett.

"What you have to do is start with two fields. Let's call it $variable_choice, that's a multiple choice question, and $variable_calced that's your calculated field. When you want to create a variable that randomly selects based on your calculated field, you start by telling Medtech that this random variable is based on $variable_choice. Then you delete $variable_choice, and then rename $variable_calced to be $variable_choice."

"Wait, they allow you to do that, but don't allow you to randomize calculated fields any other way? And they don't check?"

"Hopefully, they don't decide to start checking before this project is over," Tyree said.

"This study is supposed to go on for ten years. This project succeeding comes down to them never treating this workaround as a bug?"

"It was the only solution I could find. Let me know if you need anything else?"

Brett wasn't completely satisfied with the hack and went back to the documentation. He found a "better" solution: he could make a read-only multiple-choice field with only one choice, the value of the calculated field, as the default answer. Unfortunately, it was possible that the user would alter the list unintentionally by answering the multiple-choice question before the calculated field was evaluated.

Ultimately, the only choice left to Brett was to take his lunch break, go to the cafeteria, and order two hot dogs.

[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!


To read the full article, please visit The Daily WTF

Tuesday, March 12, 2019

CodeSOD: The Value of Your Code

“We know that governmental data-systems aren’t generally considered ‘cutting edge’ or ‘well architected’, but we’ve brought together some top flight talent, and we’re building a RESTful architecture that guarantees your code gets nice, easy-to-consume JSON objects.”

That’s what Oralee B. was told when she was hired to work on it. The system owned pretty much the entirety of the municipal data management market, tracking birth certificates, marriage certificates, death certificates and pet licenses for nearly every city in the country. JSON is so simple, how can you screw it up?

The same way most people seem to screw it up: reinventing key/value pairs in your key/value data format.

{
    "code": "Registrations",
    "Configurations": [
        {
            "code": "Registration1",
            "Configurations": [
                {
                    "code": "IdRegistration",
                    "value": "94"
                },
                {
                    "code": "CaptionActive",
                    "value": "EF_PRE_CR"
                },
                {
                    "code": "DateEnd",
                    "value": "2019-01-01"
                },
                {
                    "code": "DateStart",
                    "value": "2019-01-01"
                },
                {
                    "code": "Units",
                    "Configurations": []
                }
            ]
        },
        {
            "code": "Registration2",
            "Configurations": [
                {
                    "code": "IdRegistration",
                    "value": "92"
                },
                {
                    "code": "CaptionActive",
                    "value": "EF_PRE"
                },
                {
                    "code": "DateEnd",
                    "value": "2019-01-01"
                },
                {
                    "code": "DateStart",
                    "value": "2019-01-01"
                },
                {
                    "code": "Units",
                    "Configurations": [
                        {
                            "Code": "Unit1",
                            "Value": null,
                            "Configurations": [
                                {
                                    "code": "IdUnit",
                                    "Value": "1",
                                    "Configurations": []
                                },
                                {
                                    "code": "CaptionUnit",
                                    "value": "Hour",
                                    "Configurations": []
                                }
                            ]
                        },
                        {
                            "Code": "Unit2",
                            "Configurations": [
                                {
                                    "code": "IdUnit",
                                    "Value": "2",
                                    "Configurations": []
                                },
                                {
                                    "code": "CaptionUnit",
                                    "value": "Entrance",
                                    "Configurations": []
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

It’s not just the reinvention of key/value pairs as code/value pairs. They’re also reinvented as Code/value and Code/Value pairs. The inconsistent capitalization tells its own story about how this JSON is generated and consumed by other clients, and at least on the generation side, it clearly rhymes with “bling congratulation”.

When Oralee asked, “Why on Earth do you do it this way?”

“Because,” her boss explained, “this is the way we do it.”

[Advertisement] ProGet supports your applications, Docker containers, and third-party packages, allowing you to enforce quality standards across all components. Download and see how!


To read the full article, please visit The Daily WTF