Saturday, September 29, 2018

‘Ghost Man’ Captured On CCTV Saves Little Girl’s Life

Ghost Man Saves Teen

This video footage you are about to see will get you deliberate on everything you know about life. Very soon you will start to analyze if it is genuine or just a product of someone […]

The post ‘Ghost Man’ Captured On CCTV Saves Little Girl’s Life appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Friday, September 28, 2018

Error'd: Full Price not Allowed

"When registering for KubeCon and CloudNativeCon, it's like they're saying: Pay full price? Oh no, we insist you use a discount code. No really. It's mandatory," writes Andy B.

 

Henry S. wrote, "I think this message should perhaps read Luxury Service Unavailable."

 

"At first glance, you may read the instruction to be 'check your dog file', but that is presently not the case," writes Daryl D.

 

Rich P. wrote, "Lite-On (a LED manufacturer located in Taiwan) seems to have given up on differentiating the countries across the Pacific..."

 

"Sorry glassdoor, I would be happy to leave a salary report for undefined, but my current contracts with null and NaN forbid me from doing so," writes Jeffrey King.

 

"You know, although my name is Bruce, my friends all call me undefined," Bruce R. wrote.

 

[Advertisement] Ensure your software is built only once and then deployed consistently across environments, by packaging your applications and components. Learn how today!


To read the full article, please visit The Daily WTF

Eight-Year-Old Enters Dance-Off And Immediately Wins The Crowd Over

Eight Year Old Dance Off

Dancing has numerous advantages to numerous frameworks in your body like your circulatory framework, your skeletal framework, your solid framework and your general emotional wellness! During a dance party on the Carnival Sunshine, DJ DevineSongz […]

The post Eight-Year-Old Enters Dance-Off And Immediately Wins The Crowd Over appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Thursday, September 27, 2018

CodeSOD: Off by Dumb Error

“We’re bringing on my nephew, he’s super smart with computers, so you make sure he is successful!”

That was the long and short of how Reagan got introduced to the new hire, Dewey. Dewey’s keyboard only really needed three keys: CTRL, C, and V. They couldn’t write a line of code to save their life. Once, when trying to fumble through a FizzBuzz as a simple practice exercise, Dewey took to Google to find a solution. Because Dewey couldn’t quite understand how Google worked, instead of copy/pasting out of StackOverflow, they went to r/ProgrammerHumor and copied code out of a meme image instead.

Reagan couldn’t even just try and shove Dewey off on a hunt for a left-handed packet shifter in the supply closet, because Dewey’s patron was watching source control, and wanted to see Dewey’s brilliant commits showing up. Even if Reagan didn’t give Dewey any tasks, Dewey’s uncle did.

That’s how Dewey got stumped trying to fetch data from a database. They simply needed to read one column and present it as a series of HTML list items, using PHP.

This was their approach.

$sql = "SELECT information FROM table"; 
//yes, that is actually what Dewey named things in the DB
$result = $conn->query($sql);
$list = $result->fetch_assoc();
$i = 1;
$run = true;
while ( $list == true && $run != false ) {
  if ( $list[$i] <= count($list) ) {
    echo '<li>' . $list[$i] . '</li>';
    $i++;
  } else {
    $last = array_pop(array_reverse($list));
    echo '<li>' . $last . '</li>';
    $run = false;
  }
}

Presumably, this is one of the cases where Dewey didn’t copy and paste code, because I don’t think anyone could come up with code like that on purpose.

The fundamental misunderstanding of loops, lists, conditions, arrays, and databases is just stunning. Somehow, Dewey couldn’t grasp that arrays started at zero, but blundered into a solution where they could reverse and pop the array instead.

Needless to say, Dewey never actually had any code get past the review stage. Shortly after this, Dewey got quietly shuffled to some other part of the organization, and Reagan never heard from them again.

[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

Baby Shows Off Talent In Adorable Baby And Daddy Duet

Baby Viral Video

How early do you think babies learn to communicate? The minute they come out of the womb, or does it happen a bit later? Or, along with those same lines, how early do you think […]

The post Baby Shows Off Talent In Adorable Baby And Daddy Duet appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Wednesday, September 26, 2018

CodeSOD: Ten Times as Unique

James works with a financial services company. As part of their security model, they send out verification codes for certain account operations, and these have to be unique.

So you know what happens. Someone wrote their own random string generator, then wrapped it up into a for loop and calls it until they get a random string which is unique:

private string GetUniqueVerificationCode()
{
    // Generate a new code up to 10 times and check for uniqueness - if it's unique jump out
    // IRL this should only hit once, it;s a random 25 char string ffs but you can never be too careful :)
    for(var tries = 0; tries < 10; tries++)
    {
        var code = RandomStringGenerator.GetRandomAlphanumericString(50);
        if(!this.userVerificationCodeRepository.CodeExists(code))
        {
             return code;
        }
    }
    throw new Exception("Unable to generate unique verification code.");
}

It’s the details, here. According to the comment, we expect 25 characters, but according to the call, it looks like it’s actually 50- GetRandomAlphanumericString(50). If, after ten tries, there isn’t a unique and random code, give up and chuck an exception- an untyped exception, making it essentially impossible to catch and respond to in a useful way.

As the comment points out- the odds of a collision are exceedingly small- at least depending on how the “random alphanumeric string” is generated. Even with case insensitive “alphanumerics”, there are quadrillions of possible strings at twenty five characters. If it’s actually fifty, well, it’s a lot.

Now, sure, maybe there’s a bias in the random generation, making collisions more likely, but that’s why we try and design our applications to avoid generating the random numbers ourselves.

James pointed out that this was silly, but the original developer misunderstood, and thought the for loop was the silly part, so now the code looks like this:

private string GetUniqueVerificationCode()
{
    var code = RandomStringGenerator.GetRandomAlphanumericString(50);
    while (this.userVerificationCodeRepository.CodeExists(code))
    {
        code = RandomStringGenerator.GetRandomAlphanumericString(50);
    }
    return code;
}

Might as well have gone all the way to a do...while. The best part is that regardless of which version of the code you use, since it’s part of a multiuser web application, there’s a race condition- the same code could be generated twice before being logged as an existing code in the database. That’s arguably more likely, depending on how the random generation is implemented.

Based on a little googling, I suspect that the GetRandomAlphanumericString was copy-pasted from StackOverflow, and I’m gonna bet it wasn’t one of the solutions that used a cryptographic source.

[Advertisement] Forget logs. Next time you're struggling to replicate error, crash and performance issues in your apps - Think Raygun! Installs in minutes. Learn more.


To read the full article, please visit The Daily WTF

Gender Reveal Football Kicked Straight Into Neighbor’s Yard

Gender Reveal Viral Video

It all started with the baby gender reveal parties on Pinterest. Expecting parent would organize a party with pink and blue everything, then throw a surprise when they were about to announce the gender of […]

The post Gender Reveal Football Kicked Straight Into Neighbor’s Yard appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Tuesday, September 25, 2018

Fishing Boat Nearly Capsizes After Humpback Whale Breaches Close By

Boat Capsizes Whale Breaches

We’ve said it once and we’ll say it again – the deep dark waters of the ocean are filled with wonders. We know so little of what is really hiding in its depths, it sometimes […]

The post Fishing Boat Nearly Capsizes After Humpback Whale Breaches Close By appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

CodeSOD: The UI Annoyance

Daniel has a bit of a story. The story starts many months ago, on the very first day of the month.

Angular 1.x has something called a filter as a key concept. This is a delightfully misleading name, as it's more meant to be used as a formatting function, but because it takes any arbitrary input and converts it to any arbitrary output, people did use it to filter, which had all sorts of delightful performance problems in practice.

Well, Daniel found this perfectly sensible formatting filter. It's well documented. It's also wrong.


/** * Given a timestamp in the format "2018-06-22T14:55:44+00:00", this filter * returns a date in human-readable format following our style guide. * Assuming the browser's timezone is EDT, the filter applied to the above string * would return "Jun 22, 2018 10:55 AM". * When applicable, this filter returns "today at" or "yesterday at" as date abbreviations in lowercase. * These can be capitalized using the "capitalize" filter above directly in an HTML file. */ ourApp.filter('ourTimestamp', ['$filter', function($filter) { return function(timestamp) { // Guard statement for when timestamp is null, undefined or empty string. if (!timestamp) { return ''; } let TODAY = new Date(); let TODAY_YEAR = TODAY.getFullYear(); let TODAY_MONTH = TODAY.getMonth(); let TODAY_DAY = TODAY.getDate(); let TIMESTAMP_FORMAT = 'MMM d, y h:mm a'; let TIME_FORMAT = 'h:mm a'; let originalTimestampDate = new Date(timestamp); let year = originalTimestampDate.getFullYear(); let month = originalTimestampDate.getMonth(); let day = originalTimestampDate.getDate(); let dateAbbreviation = null; if (year === TODAY_YEAR && month === TODAY_MONTH && day === TODAY_DAY) { dateAbbreviation = 'today at '; } else if (year === TODAY_YEAR && month === TODAY_MONTH && day === (TODAY_DAY - 1)) { dateAbbreviation = 'yesterday at '; } if (dateAbbreviation) { return dateAbbreviation + $filter('date')(timestamp, TIME_FORMAT); } else { return $filter('date')(timestamp, TIMESTAMP_FORMAT); } };
 

This code, like so much bad code, touches dates. This time, its goal is to output a more friendly date- like, if an event happened today, it simply says, "today at" or if it happened yesterday, it says "yesterday at". On the first day of the month, this fails to output "yesterday at". The bug is simple to spot:


if (year === TODAY_YEAR && month === TODAY_MONTH && day === (TODAY_DAY - 1)) { dateAbbreviation = 'yesterday at '; }
 

On September first, this only outputs "yesterday at" for September zeroth, not August 31st.

Now, that's a simple brainfart bug, and it could be fixed quite easily, and there are many libraries which could be used. But Daniel ran a git blame to see who on the development team was responsible... only to find that it was nobody on the development team.

It probably isn't much of a shock to learn that this particular application has lots of little UI annoyances. There's a product backlog a mile long with all sorts of little things that could be better, but can be lived with, for now. Because it's a mile of things that can be lived with, they keep getting pushed behind things that are more serious, necessary, or just have someone screaming more loudly about them.

Sprint after sprint, the little UI annoyances keep sitting on the backlog. There's always another problem, another fire to put out, another new feature which needs to be there. The CTO kept trying to raise the priority of the little annoyances, and the line kept getting jumped. So the CTO just took matters into their own hands and put this patch into the codebase, and pushed through to release. As the CTO, they bypassed all the regular sign-off procedures. "The test suite passes, what could be wrong?"

Of course, it has its own little UI annoyance, in that it misbehaves on the first day of the month. The test suite, on the other hand, assumes that the code will run as intended. And the test suite actually uses the current date (and calculates yesterday using date arithmetic). Which means on the first day of the month, the test fails, breaking the build.

Unfortunately for Daniel and the CTO, this bug ended up on the backlog. Since it only impacts developers one day a month, and since it's pretty much invisible to the users, it's got a very low priority. It might get fixed, someday.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!


To read the full article, please visit The Daily WTF

Monday, September 24, 2018

CodeSOD: Shell Out

Duct tape apollo17

Developers sometimes fail to appreciate how difficult a job Operations really is. In companies that don't hold with newfangled DevOps, the division of labor often comes with a division of reputation as well. After all, developers do the hard work of making software. What are Ops guys even for? They don't make software. They don't generate leads or fix your desktop PC. Why bother paying for talented senior Ops professionals?

Spend a few days with the Ops team, however, and you start to see why you should pay them a little more than your average garbageman. The Ops lifecycle is a daily grind of deployments, patching, and sticking fingers in dykes, trying to keep that expensive cesspit the devs call "software" running. Simple tasks such as spinning up new infrastructure in AWS often get pushed to the back burner behind putting out fires and making sure critical maintenance tasks that didn't get done last year don't explode into flames.

Still, companies like to cut corners. Often, Ops folks have very little programming expertise and no training budget, meaning repetitive tasks are automated using cobbled-together bits of shell script found via Google. In the Ops world, a bit of Perl or Python is worth its weight in gold.

Today's snippet, as you can probably guess, is not in Perl or Python. It is instead in a common paradigm: Bash embedded in Perl. Likely, the original script was written by a senior who knows Perl, and this chunk was written by a strapped-for-time medior who didn't:


my $secs = `cut -f1 -d. /proc/uptime`;
$data{lastboottime} = strip(`date -d "$secs seconds ago" '+%Y'-'%m'-'%d'T'%T' 2>/dev/null`);


The point of this snippet is to gather the last time the machine booted; later code sends it to a central inventory system. The bug here is that the last boot time would drift by a second or so between updates—not because the machine had rebooted, but because the code gathering it was imprecise.

For those who spend their day at a higher level of abstraction, let me explain: we start by querying /proc/uptime, which I'll let the manpage explain:

This file contains information detailing how long the system has been on since its last restart. The output of /proc/uptime is quite minimal:

350735.47 234388.90

The first number is the total number of seconds the system has been up. The second number is how much of that time the machine has spent idle, in seconds.

We then use cut to snip the output, using a period as a delimiter and taking only the first field, meaning we take the floor of the uptime in seconds and throw away the rest. We store that in a Perl variable, then feed it back into Bash in the middle of a date format string so that it reads "X seconds ago." We then parse that, rearrange it into year-month-day, throw away any errors, and trim it to put back into Perl for the rest of the script to forward on.

Some days I feel this is the real reason DevOps was invented: a bunch of devs saw the code the Ops guys were writing and cringed so hard, they found themselves volunteering to write "Whatever code you need, man. Just ask me, I'll get it done for you. Please."

[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

Friday, September 21, 2018

Escaped Python Sparks Panic on Busy Road During Rush Hour

This is the terrifying moment a rampaging python brought havoc on a busy road as drivers battled to catch it in a cardboard box. The 12ft long python brought traffic to a stop during rush […]

The post Escaped Python Sparks Panic on Busy Road During Rush Hour appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Error'd: This Movie is Rated S for Safe for SQL

"Clearly the Light Cinema decided to ban unsafe sql characters from the cinema," wrote Simon, "Let's hope no one makes a film called 'Drop Table'."

 

Michael M. wrote, "King Soopers has an amazing algorithm when deciding just what tea to show me from their extensive database."

 

"I didn't know that there was a city named after a Java conversion error in zip code 85034, but if I want to go, hey, Greyhound can take me there," Celti B. writes.

 

"Even estimates.solar's site is weighing in on the current political climate!" wrote Russ S.

 

Derrick M. writes, "For a wireless keyboard to cost this much, it had better be able to reach into space."

 

"According to Microsoft, 13/100 is the new 12%," Roberta wrote.

 

[Advertisement] Otter - Provision your servers automatically without ever needing to log-in to a command prompt. Get started today!


To read the full article, please visit The Daily WTF

Thursday, September 20, 2018

Airplane Loses Cabin Pressure Mid-Flight

‘Panic’ on Jet Airways Flight After Loss of Cabin Pressure A Jet Airways airplane bound for Jaipur on September 20 turned back to Mumbai after what the airline said was a “loss in cabin pressure.” A […]

The post Airplane Loses Cabin Pressure Mid-Flight appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

CodeSOD: Flip to a Blank Page

You have a web application, written in Spring. Some pages live at endpoints where they’re accessible to the world. Other pages require authentication, and yet others require users belong to specific roles. Fortunately for you, Spring has features and mechanisms to handle all of those details, down to making it extremely easy to return the appropriate HTTP error.

Unfortunately for you, one of the developers on your team is a Rockstar™ who is Officially Very Smart and absolutely refuses to use the tools your platform provides. When that Certified Super Genius leaves the organization, you inherit their code.

That’s what happened to Emmer. And that’s how they found this:

List<String> typeList = getTypeList (loginName);
if(CollectionUtils.size(typeList) > 0){
    return viewRepository.findBySubmsnTypeList(typeList, pr);
}
else{
      return viewRepository.findEmptyPage(pr);
}

This doesn’t look too bad, does it? It’s not great- why are roles called “types”, why are we representing them with strings, why are we checking if a user is logged in by checking which roles they have, and not whether or not they’re logged in… and why on Earth would you send the user an empty page if they’re not authenticated?

The question is: how do you generate an empty page? If “just return an empty view object” is what you thought you’d do, you’re obviously not a Rockstar™.

        @Query(value = "from viewTable where 1=0", nativeQuery = false)
        public Page<viewTable> findEmptyPage(Pageable pr);

If you want to return an empty page, you run a query against the database which is guaranteed to return absolutely no results. That guarantees that you’ll send a blank page back, because there’s no data to put on the page. Genius! This way, returning nothing requires a hop across the network and a call to the database, instead of just, y’know, returning nothing (or even better, returning an error page).

Suffice to say, when this master programmer gave their two weeks notice, Emmer and the rest of the team suggested that this programmer should spend their last two weeks on vacation.

[Advertisement] Forget logs. Next time you're struggling to replicate error, crash and performance issues in your apps - Think Raygun! Installs in minutes. Learn more.


To read the full article, please visit The Daily WTF

Wednesday, September 19, 2018

ATV Head on Collision with a Car

We have no idea how this guy not only gets up, but only receives a couple of bruises from this insane video. The ATV crashed head on with an oncoming car in Saint Petersburg, Russia […]

The post ATV Head on Collision with a Car appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Westward Ho!

Buoy in the ocean

Roman K. once helped to maintain a company website that served a large customer base mainly within the United Kingdom. Each customer was itself a business offering a range of services. The website displayed these businesses on a map so that potential customers could find them. This was done by geocoding the business' addresses to get their longitude and latitude coordinates, then creating points on the map at those locations.

Simple enough—except that over time, some of the businesses began creeping west through the Atlantic Ocean, toward the east coast of North America.

Roman had no idea where to start with troubleshooting. It was only happening with a subset of businesses, and only intermittently. He was certain the initial geocoded coordinates were correct. Those longitude and latitude values were stored in a database table of customer data with strict permissions in place. Even if he wanted to change them himself, he couldn't. Whatever the problem was, it was powerful, and oddly selective: it only ever changed longitude values. Latitude values were never touched.

Were they being hacked by their competitors? Were their customers migrating west en masse? Were goblins messing with the database every night when no one was looking?

Roman dug through reams of code and log files, searching desperately for any whiff of "longitude." He questioned his fellow developers. He blamed his fellow developers. It was all for naught, for the problem was no bug or hack. The problem was a "feature" of the database access layer. Roman discovered that the user class had a simple destructor method that saved all the currently loaded data back to the database:

function __destruct() {
     if ($this->_changed) {
          $this->database->update('customer_table', $this->_user_data, array('customer_id' => $this->_user_data['customer_id']));
     }
}

The legwork was handled by a method called update(). And just what did update() do?

public function update($table, $record, $where = '') {
     // snip
     foreach ($record as $field => $value) {
          if (isset($value[0]) && is_numeric($number) && ($value[0] == '+' || $value[0] == '-')) {
               $set[] = "`$field` = `$field` {$value[0]} ".$number;
          }
     }
}

Each time a customer logged into their account via the website and changed their data: if any of their data began with either a plus or minus sign, those values would have some mysterious value (contained in the variable $number) either added to or subtracted from them. Say a customer's business happened to be located west of the prime meridian. Their longitude would therefore be stored as a negative value, like -3. The next time that customer logged in and changed anything, the update() method would subtract $number from -3, relocating the customer to prime oceanic property. Latitude was never affected because latitude coordinates above the equator are positive. These coordinate values were simply stored as-is, with no sign in front of them.

There was no documentation for the database access layer. The developer responsible for it was long gone. As such, Roman never did learn whether there were some legitimate business reason for this "feature" to exist. He added a flag to the update() method so that customers could disable the behavior upon request. Ever since, the affected companies have remained safely anchored upon UK soil.

[Advertisement] Ensure your software is built only once and then deployed consistently across environments, by packaging your applications and components. Learn how today!


To read the full article, please visit The Daily WTF

Tuesday, September 18, 2018

Switch On Suppression

Krista noticed our article explaining that switches were replacements for ifs. She sent in a version she found in her codebase, around the same idea:

        @SuppressWarnings("incomplete-switch")
        @Transactional
        public void removeAssetFromPackage(Package pkg, Asset assetToRemove) {
                pkg.getAssets().remove(assetToRemove);
                // Delete from DB and asset store.
                removeAsset(pkg, assetToRemove);

                // If we're removing LIVE asset, also delete AsyncJobs.
                switch (assetToRemove.getType()) {
                        case LIVE:
                                asyncJobService.removeAsyncJobsForPresentation(pkg);
                                break;
                }

                // Flush package cache.
                cacheInvalidationService.invalidatePresenationCache(pkg);
        }

Once again, we use a switch instead of an if. Perhaps this was premature flexibility- there are obviously other states the getType method could return. Maybe, someday in the future, they’ll need to do other things inside that switch. Until then, it’s just the sort of thing the compiler will throw warnings about, since there’s no default case.

Oh, except, of course, they suppressed the warning up top.

A quick search in Krista’s codebase for @SuppressWarnings("incomplete-switch") finds dozens of usages of this pattern.

[Advertisement] Forget logs. Next time you're struggling to replicate error, crash and performance issues in your apps - Think Raygun! Installs in minutes. Learn more.


To read the full article, please visit The Daily WTF

Monday, September 17, 2018

83 Year Old Man Foils Armed Robbery

The armed robbery of a betting shop in Glanmire, Cork, was foiled on September 15 when 83-year-old Denis O’Connor (our hero) fought back the would-be thieves. During the incident, which took place at Bar One […]

The post 83 Year Old Man Foils Armed Robbery appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos