Wednesday, April 24, 2019

CodeSOD: A Linking Approach

Web development has gone in a bizarre circle since the early 2000s. Whet ASP.NET launched, its “big sell” was Web Forms, which allowed developers to use a desktop model for handling interactive applications. The basic logic you used for building a desktop forms application would work for a web app, because at the time, everyone was a desktop developer.

Fast forward to today, where we bundle our applications up in web browsers and use web metaphors to build desktop applications, because everyone’s a web developer. This may be proof that developers can only ever learn a single way of doing things, and that two options is one too many.

Which brings us to some code Petr Tomanek recently inherited. The original developer, Josiah, started their career around the early 2000s. They were big advocates of the data row approach to data access. In code, they’d forget that they’d already run a query, and run it three more times just to be sure to get the data. Their approach to UI wasn’t even quite up to Web Forms standards, and was more, “mash together my personal library of snippets and Stack Overflow copy/paste”. The current incarnation of the application used the more modern ASP.NET MVC, but you wouldn’t know it to look at most of the code.

But Josiah would at least try to use the new features. For example, when they wanted the URL of a screen in the MVC application, they knew that the ActionLink method was how you created links in your view. There was also a Url.Action method which would construct just the URL. But that’s two different ways to do something, and that’s one too many. Josiah did this:

html.ActionLink(model.NextButtonText, model.RouteActionName, model.RouteControllerName, model.RouteValues, null).ToString().Split('"')[1];

The ActionLink method returns the full <a href=…>…</a>. Then we split on ", and grab the first element.

At least Josiah was consistent, and used this hammer everywhere they needed a URL.

[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

Fearless squirrel chases friendly cat

Well here’s something you don’t see everyday! Dare we say a friendship in the making?

The post Fearless squirrel chases friendly cat appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Tuesday, April 23, 2019

Suffer Not The Virus To Live

Computer virus illustration

Not so long ago in 2015, Carl C. was asked to give a talk to an amateur radio club. The venue was a local church that rented out their meeting hall to various community groups, businesses, and even the odd academic session. The space boasted a multimedia setup with several video screens, making it a great place at which to present.

Carl prepared his talk, and a PowerPoint slide deck to go with. On the day of the presentation, he arrived at the meeting hall with plenty of time to spare. Alone in silence, he headed toward the front of the room and surveyed the technical setup. Thankfully, it was straightforward: there was a table set up in front of the projector screen, with a VGA connector resting directly on it. Carl unpacked his laptop, retrieved the HDMI-to-VGA adapter he'd brought along, and began plugging everything together.

"NOOO!"

Carl jumped, then glanced up wide-eyed like a deer in headlights. It wasn't a truck bearing down on him, but rather a flustered gentleman hugging a laptop to his chest.

"I'm the IT guru here," he introduced himself breathlessly, hurrying around the table to all but elbow Carl aside. "We don't allow outside computers to be connected to our system. That's how viruses spread! You'll have to run your presentation from our computer." He connected his own laptop to the AV system in lieu of Carl's.

"Uh ..." Carl blurted.

"Yes?" The guru fixed him with a withering stare.

I'm not joining your network, Carl thought. There's no such thing as VGA viruses! But the stare was so intense that the objections died before they left his throat.

"How, uh ... how do I get my presentation on there?" he asked instead, gesturing to the guru's laptop.

"Can you copy it to a USB stick?" the guru asked. "That's the best way."

Right. No one's ever gotten a virus from a random USB stick. Biting his lip to short-circuit a laugh, Carl dug through the side pockets on his laptop bag. "I think I've got one with me."

[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

Blind Pit Bull Sweetly Cuddles Kitty Best Friend

Who here believes that is impossible for cats and dogs to develop a friendship, please raise your hand. Well, we are here to prove you wrong, and we think that this video will change your mind for sure. This blind pit bull loves to cuddle with his best friend Griffin, and it’s the most adorable […]

The post Blind Pit Bull Sweetly Cuddles Kitty Best Friend appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Monday, April 22, 2019

CodeSOD: Be True to Yourself

Ben M recently inherited some code from some Highly Paid Consultants. These consultants needed to be able to set some flags to control the behavior of the application, and for whatever reason, these flags needed to be strings. It probably wasn't a good reason, but there was some reason. The consultants wrote the module which set the flags, and guaranteed that the flags were only ever "true" or "false".

To parse those flags back into boolean values, they did it the true Highly Paid Consultant way: they used a generic "string to boolean" solution they copied from Stack Overflow instead of Boolean.Parse, the built-in C# method for turning "true" into a boolean value.

private bool ConvertBoolean(string value, bool defaultValue = false) { bool returnValue = defaultValue; if (value == null) { return returnValue; } if ("y".Equals(value, StringComparison.OrdinalIgnoreCase) || "yes".Equals(value, StringComparison.OrdinalIgnoreCase) || "true".Equals(value, StringComparison.OrdinalIgnoreCase) || "1".Equals(value, StringComparison.OrdinalIgnoreCase) || "on".Equals(value, StringComparison.OrdinalIgnoreCase)) { returnValue = true; } else if ("n".Equals(value, StringComparison.OrdinalIgnoreCase) || "no".Equals(value, StringComparison.OrdinalIgnoreCase) || "false".Equals(value, StringComparison.OrdinalIgnoreCase) || "0".Equals(value, StringComparison.OrdinalIgnoreCase) || "off".Equals(value, StringComparison.OrdinalIgnoreCase)) { returnValue = false; } return returnValue; }
 

Finally, this tells us the true value of FILE_NOT_FOUND, which is to say, whatever we passed in for our defaultValue, because that's what happens if this code doesn't understand how to parse the string.

[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

Aussie Puppy Totally Gives Up On Walk, Throws Temper Tantrum

Dogs are one of the famous pets that are raised by a lot of people all over the world. Who says dogs are only raised by adults out there? These days, dog masters that you can find all throughout the globe become younger and younger. Gone were the days that only adults can own pet […]

The post Aussie Puppy Totally Gives Up On Walk, Throws Temper Tantrum appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Sunday, April 21, 2019

Jealous Corgis Hilariously Battle For Human’s Affection

If you haven’t noticed already, animals especially dog always try to get our attention and affection. No matter what we do, for them, it’s always a good time for hugs and kisses. Our affection and attention for them it’s the most important thing in the world. But, don’t get us wrong, for us also is […]

The post Jealous Corgis Hilariously Battle For Human’s Affection appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Saturday, April 20, 2019

Parrot Beatboxes To Doggy Best Friend

Even though some people still believe that animals are not capable of having feelings and having friends, so we think that with this heart-breathtakingly and adorable video will show everyone that animals can be best friends with humans and other animals too. Adorable animal friends are always there for each other as companions, no matter […]

The post Parrot Beatboxes To Doggy Best Friend appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Friday, April 19, 2019

Error'd: On Second Thought, I'll Just Go Back to Bed

Gordon S. wrote, "In seeing how someone botched the deployment of Windows on the flight boards, I sure hope that's ALL that admin was allowed to work on."

 

"This is the login page for the French health insurance system. The red text says 'The Ameli portal will be unavailable from the 01/02/2003 to the 04/05/2006'," Joelle wrote, "Three years of maintenance downtime may seem a bit excessive, but at least they've chosen a time slot that will not affect many users."

 

Eric writes, "Somehow I don't think giving your card number as **Bunch_of_numbers** will work here."

 

"Charlotte Airport is here to remind us all that it's the computers, not the airplanes, that crash," David B. writes.

 

"I can see it now - a long time ago, someone named Craig hurt the BBC's web servers and now, it works tirelessly to ignore me," wrote Craig K.

 

"Was it helpful? Umm...was it anything?" Ian 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

Persian Cat Plays With Balloons Like A Dog

Edith the Persian cat plays with balloons just like a doggy would! How cool is that?

The post Persian Cat Plays With Balloons Like A Dog appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Thursday, April 18, 2019

CodeSOD: Waaaaaiiiiit for it…

There are many moments where our multi-threaded code needs to gurantee only one code path is executing at a time. That’s why we have locks, semaphores, mutexes, and so on. But those are all pretty complicated. Vincent H recently was reviewing someone’s code, and they found a far more elegant solution, which simply uses booleans.

For example, you could whip up a wait loop with a simple block like this:

  while (Busy)
  {
      // wait for it..
  }

When Busy becomes false, thanks to another thread changing its value, this loop will exit. Of course, sharing values between threads introduces its own possible issues, so in context, we’ll write a method that looks more like this:

public static List<T> GetMyList<T>(this List<T> list, bool Busy, string FilePath, string FileName)
{
  var myfilepath = FilePath + FileName;
  while (Busy)
  {
      // wait for it..
  }
  …
}

By passing Busy as a parameter (a by-value parameter, in this case), we guarantee that no other running threads will change the value of it while we’re waiting for it to change. This is a great solution to mutexes, because it guarantees that if you call this method while you’re Busy doing something else, this just enters an infinite loop from which it never exits, guaranteeing that you never accidentally do something you shouldn’t do.

[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

Hospitable Talking Parrot Enjoys Imaginary Dinner

Einstein is enjoying himself on the screen porch and pretends he is drinking water as he holds an imaginary cup with his foot. He then makes a drinking sound as he takes an imaginary sip. Inviting you to dine he says, ” Come here sweet!” He then asks, ” Want some?” He tells you how […]

The post Hospitable Talking Parrot Enjoys Imaginary Dinner appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Wednesday, April 17, 2019

Dog Proves To Be The Best Gym Buddy Ever

Check out how this dude uses his dog to aid him in his workout. Hilarious! Working out daily can be beneficial to your health. Regular exercise can boost your energy level, improve your mood, control your weight, make you sleep better at night and lower your risk for such medical conditions as hypertension and cardiovascular […]

The post Dog Proves To Be The Best Gym Buddy Ever appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

The Ballad of Bart

Alvin had the fortune of working with an exceptional talent while he was employed at Virtucon. Bart knew how to do everything from desktop support to software development to database administration to IT security. Not only was he proficient in all of them, he also knew them better than those with many years of experience.

Bart had been with Virtucon since the early days, racking up nearly 20 years of tenure. During this time, he 'mastered' everything and asserted himself to the point that no changes could happen without his approval. His changes were auto-approved because of course any idea he had was a good one. This led to myriad problems for fellow IT people like Alvin, who were hired after Bart.

"Be wary of Bart," Alvin was warned by his coworker Bob, who was Bart's junior by a couple years. "He has a long history of buffoonery, yet has somehow ascended to the #3 position in IT." Alvin sipped on a generous mug of coffee while Bob regaled with the Ballad of Bart. From the time he was just a helpdesk intern that put his shoulder through a core switch after tripping while carrying boxes, Bart was wrecking things.

When Bart worked his way up to server support, he 'fixed' an Exchange issue by restoring a backup into production without warning because "It worked when the backup was taken." When he was assigned a web server problem, he spent a few days troubleshooting it without asking for any help. When he finally gave in, he told Bob that he couldn't figure out a frustrating IIS HTTPS binding issue. Bob explained to him that something else had to be the problem because the server was running Apache 2.4 on Ubuntu 16.04 LTS.

When Bart added software development to his repertoire, he clearly didn't understand how code changes worked. Or code repositories for that matter. He always wanted to be the one to fix problems, so he would stick his nose in code that it didn't belong.

Bart once tried to make fee schedule changes to accounting software by opening its PowerBuilder libraries in Notepad++. He proceeded to print out the .PBL and use a pencil to scribble out every value from the old schedule and wrote in the new ones. He then scanned his penciled changes in as a PDF and emailed it to Bob to implement.

Frustrated, Bob spent an entire day showing Bart how their GitHub repositories worked. He seemed to understand, so Bob went on his way. While Bob hoped Bart wouldn't actually produce any more code, perhaps it would save their printer some toner if he did. The next day, all the developers were complaining to Bob that they couldn't access GitHub. It turns out Bart saw GitHub as a threatening malicious code breeding ground so he had a network admin block it on the firewall. He then sent an email to development staff explaining this and that they were supposed to now use 'BartHub', a file share he set up on his own computer.

Bob and the developers managed to distract Bart by pointing out how the DBA team needed help. The first thing he did was try to create an SSRS report using a series of text boxes in a grid to make a matrix. The DBA's had a good laugh at that until Bart started to commit worse atrocities.

One day an entire metrics database suddenly became a bunch of null values, which is not very helpful for metrics. Bart threw a fit because the data he was working on was gone. He demanded whomever messed up the data be hunted down. He suggested that missing historical data could be found by performing 'key triggers', whatever those were. He emphasized his point by making hand motions like he was scrambling a Rubik's cube. They ignored him and a lead DBA ran a profiler trace to find that the unconstrained null updates came from... Bart's workstation.

Alvin had long since imbibed his coffee when Bob finished his story. Bob turned back to his workstation to check his email, "Oh, would you look at that. I guess we have some changes up top!" The email stated that the current VP of IT was announcing his retirement after 30 years at Virtucon. The CTO would be taking on that new role at the end of the month.

The transition plan began and the CTO was groomed to take over. That plan was shredded a week before it was to take place because the CTO suddenly found himself unemployed. The finance department was investigating his use of the company credit card and found thousands of dollars in personal charges, so he was unceremoniously terminated. Turmoil gripped the office as an entire department waited to find out who their new leader would be.

Everyone except Bart put in a good word for Bob to become the next VP of IT. At minimum, they should hire someone from the outside. Pretty much anyone but Bart was the popular suggestion.

Bart predictably put in a good word for himself and talked a big game about all of his expertise. He added security expert to his resume by talking about disabling his home WIFI’s SSID broadcast and changing the default password. Then there was the previously-unmentioned experience as an IT Project Manager where he apparently led several teams at Schmoeing.

That Friday, that dreaded email with the subject New VP of IT came out. Being the most tenured person remaining while having "great leadership qualities," Bart got the promotion and Bob didn't. Many job search sites probably thought they were getting a DDoS attack over the weekend while everyone in Virtucon IT looked to abandon ship. Bart's reign of terror lasted 18 months before Virtucon realized they made a grave mistake. Bob, Alvin, and many others weren't around to see the way it all ended.

[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

Tuesday, April 16, 2019

Impatient puppy struggles to sit for treats

Axell the Australian shepherd is showing his hunting skills. He will not wait patiently for his owner to hand him delicious treats, little Axel is ready to fight for them!

The post Impatient puppy struggles to sit for treats appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Representative Line: Tern Your View

We all just love ternaries around here. So much. A powerful form of code golf, they can clarify and they can confound, but usually it’s just confounding.

Christopher sends us this example, saying, “This is an accurate indicator of the rest of the code.”

not_mobile = viewport().width > 400 ? true : false;

Representative indeed, and there’s a lot packed into this beyond the ternary abuse. First off, our standard for being not_mobile, which I assume is “not a mobile device” for displaying this site, is a screen that’s 400 pixels wide. Which is fine, until someone turns their 2007 iPhone into landscape mode, which is 480px wide. I assume this site has a banner “Best Viewed using a Palm Pilot”.

Of course, the root WTF is trying to set responsive breakpoints in JavaScript, when CSS has a rich set of features to handle that. Then again, they’re apparently using a custom viewport object, which implies that perhaps the viewport element wasn’t fully supported when they wrote it, so maybe it’s just an old site?

Which brings us back around to the ternary abuse. Maybe the code is just plain bad.

[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

Monday, April 15, 2019

CodeSOD: Typing for Types

Today, any sort of data access layer we build is going to be rooted in some sort of object-oriented design. It might be a full ORM, it might be an object-store database, it might be one of any number of kinds of database mapping tool.

What we usually don't do anymore is get a resultset with no type information, where we have to invoke the proper "GetXXX" method to fetch data out of what behaves more-or-less like a dictionary. Oh, we might have to do this, but we'll almost always bury it under a layer of abstraction to hide the ugly details.

I bring this up because once upon a time, this was pretty standard stuff. Result sets and data readers were just how you talked to databases. It's old fashioned, but not wrong.

Russell F recently had to add some new fields to some code written in that style. This was wrong.

public WorkOrderCustomer(SqlDataReader dr) { WorkOrderCustomer_Num = Convert.ToInt32(dr["WorkOrderCustomer_Num"].ToString()); WorkOrder_Num = Convert.ToInt32(dr["WorkOrder_Num"].ToString()); CustomerStatusFlag_Num = Convert.ToByte(dr["CustomerStatusFlag_Num"].ToString()); Cust_FirstName = DBNull.Value.Equals(dr["Cust_FirstName"]) ? (string)null : Convert.ToString(dr["Cust_FirstName"].ToString()); Cust_LastName = DBNull.Value.Equals(dr["Cust_LastName"]) ? (string)null : Convert.ToString(dr["Cust_LastName"].ToString()); Cust_Phone = DBNull.Value.Equals(dr["Cust_Phone"]) ? (string)null : Convert.ToString(dr["Cust_Phone"].ToString()); Cust_PhoneCarrier_Num = DBNull.Value.Equals(dr["Cust_PhoneCarrier_Num"]) ? (short?)null : Convert.ToInt16(dr["Cust_PhoneCarrier_Num"].ToString()); Cust_Email = DBNull.Value.Equals(dr["Cust_Email"]) ? (string)null : Convert.ToString(dr["Cust_Email"].ToString()); Account_Num = DBNull.Value.Equals(dr["Account_Num"]) ? (int?)null : Convert.ToInt32(dr["Account_Num"].ToString()); ChargeCode_Num = DBNull.Value.Equals(dr["ChargeCode_Num"]) ? (short?)null : Convert.ToInt16(dr["ChargeCode_Num"].ToString()); CompanyName = DBNull.Value.Equals(dr["CompanyName"]) ? (string)null : Convert.ToString(dr["CompanyName"].ToString()); CompanyAddress = DBNull.Value.Equals(dr["CompanyAddress"]) ? (string)null : Convert.ToString(dr["CompanyAddress"].ToString()); CompanyCity = DBNull.Value.Equals(dr["CompanyCity"]) ? (string)null : Convert.ToString(dr["CompanyCity"].ToString()); CompanyState = DBNull.Value.Equals(dr["CompanyState"]) ? (string)null : Convert.ToString(dr["CompanyState"].ToString()); CompanyZipcode = DBNull.Value.Equals(dr["CompanyZipcode"]) ? (string)null : Convert.ToString(dr["CompanyZipcode"].ToString()); CompanyPhone = DBNull.Value.Equals(dr["CompanyPhone"]) ? (string)null : Convert.ToString(dr["CompanyPhone"].ToString()); DriverName = DBNull.Value.Equals(dr["DriverName"]) ? (string)null : Convert.ToString(dr["DriverName"].ToString()); LeasingCompany = DBNull.Value.Equals(dr["LeasingCompany"]) ? (string)null : Convert.ToString(dr["LeasingCompany"].ToString()); Fleet_Num = DBNull.Value.Equals(dr["Fleet_Num"]) ? (string)null : Convert.ToString(dr["Fleet_Num"].ToString()); Unit_Num = DBNull.Value.Equals(dr["Unit_Num"]) ? (string)null : Convert.ToString(dr["Unit_Num"].ToString()); ShipToDealerAccount_Num = DBNull.Value.Equals(dr["ShipToDealerAccount_Num"]) ? (string)null : Convert.ToString(dr["ShipToDealerAccount_Num"].ToString()); DeliveryReceipt_Num = DBNull.Value.Equals(dr["DeliveryReceipt_Num"]) ? (string)null : Convert.ToString(dr["DeliveryReceipt_Num"].ToString()); CompanyVendor_Num = DBNull.Value.Equals(dr["CompanyVendor_Num"]) ? (int?)null : Convert.ToInt32(dr["CompanyVendor_Num"].ToString()); Is_CDP_Account = DBNull.Value.Equals(dr["Is_CDP_Account"]) ? (bool?)null : Convert.ToBoolean(dr["Is_CDP_Account"].ToString()); IsNationalAccount = DBNull.Value.Equals(dr["IsNationalAccount"]) ? (bool?)null : Convert.ToBoolean(dr["IsNationalAccount"].ToString()); HasZZPermit = DBNull.Value.Equals(dr["HasZZPermit"]) ? (bool?)null : Convert.ToBoolean(dr["HasZZPermit"].ToString()); Cust_Address = dr["Cust_Address"] as string; Cust_City = dr["Cust_City"] as string; Cust_State = dr["Cust_State"] as string; Cust_Zip = dr["Cust_Zip"] as string; CustTempMaster_Num = dr["CustTempMaster_Num"] as int?; }
 

dr["fieldname"] is the simplest way to access a value in the dataset. It has the disadvantage of returning data as object, which means you're going to need to do a type conversion. This code demonstrates two different ways to do the type conversion. The last five lines, added by Russell, use the as string syntax. That's a relatively new addition to the C# language which does "safe" conversions- if the typecast isn't possible, it just returns null.

Of course, since you do know the types of the DB columns, you could also use a more traditional cast syntax, like CustNum = (Int32)dr["CustNum"]. That would have worked in every version of C#.

But that's not what the original developer did. They grabbed every field, converted it to a string, and then used a Convert method to parse it back into the expected data type.

That's the sort of code that makes you sigh and step away from your desk for a few minutes, because it's just so exhausting to see.

[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

Horse Befriends Rabbits In Incredible Footage

Some people believe that animals are not capable of having feelings and having friends, so we think that with this heart-breathtakingly and adorable video will show everyone that animals can be best friends with humans and other animals too. Adorable animal friends are always there for each other as companions, no matter what. Sure, they […]

The post Horse Befriends Rabbits In Incredible Footage appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Sunday, April 14, 2019

Flooded Streets of Downtown Pullman

The video is from a flash flood due to heavy rains in Pullman Washington. I took this video shortly after driving through the same intersection. The flood caused damage to local businesses.

The post Flooded Streets of Downtown Pullman appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Saturday, April 13, 2019

Bulldog Puppy Shows Robot Vacuum Who’s Boss

Everyone keep calm but there is a monster in the house. Luckily Lily is here to take care of it!

The post Bulldog Puppy Shows Robot Vacuum Who’s Boss appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Friday, April 12, 2019

Error'd: Are You Not Satisfied?

"Does this mean that Toyota believes that hybrid owners are fundamentally unhappy with their cars?" writes Thom.

 

Brian K. wrote, "When I clicked on a link on our intranet for a PowerPoint presentation, clearly Microsoft thought that perfectly valid server certificates are suspicious and asked me to confirm."

 

"Make? Model? Year? Bah...who needs them? ALL FALSE!" Walt S. writes.

 

Alex B. wrote, "My friend and I were at a mall in Los Angeles and he happened to use an old parking ticket from 6 months ago proving that the machine never forgets!"

 

"The lesson to learn here is 'Pick and language and just STICK with it!!'"Job writes.

 

Timothy wrote, "I didn't catch the name tag, but with a name like $driverName$, you could say he had his career path set from birth."

 

[Advertisement] Continuously monitor your servers for configuration changes, and report when there's configuration drift. Get started with Otter today!


To read the full article, please visit The Daily WTF

Dog ponders if she wants more belly scratches

After a few scratches, this pup really had to think over if she wanted more! How funny is that?

The post Dog ponders if she wants more belly scratches appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Thursday, April 11, 2019

CodeSOD: Oooooooooooooo no

Kids these days have their flexboxes and their ems and their position absolutes. In the olden days of HTML, we arranged everything with table tags and we liked it. Well, some of us did. Mike was recently doing part of a redesign, and when the background color of the page was changed, a bunch of garbage text appeared in various input forms. How could changing the CSS background color cause garbage text to appear?

<b>Billing Address Information</b>
<p class="style3">Billing Address 1:<font color=white>0ooo0.....</font><input type="text" name="BillStreet1"></p>
<p class="style3">Billing Address 2:<font color=white>o00000...</font><input type="text" name="BillStreet2"></p>
<p class="style3">Billing City:<font color=white>00o00..0.o...0..</font><input type="text" name="BillCity"></p>

It certainly gives new meaning to the term “whitespace”. The mix of characters implies that either the person responsible deeply understood how proportional fonts work in terms of sizing, or they absolutely didn’t. They almost certainly didn’t. Then again, this kept all the fields aligned on all the browsers anyone had tested with, so maybe they did?

[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

These Two Distant Cousins Have Such An Amazing Bond

Check out in this video two distant cousins with such an amazing bond. The dogs we all know and love to keep as our loyal pets are the distant cousin of wolves. They come from the same genus “canis”, with dogs belonging to the subspecies “familiaris”. Even to the untrained eye, a wolf looks far […]

The post These Two Distant Cousins Have Such An Amazing Bond appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Wednesday, April 10, 2019

CodeSOD: It Just Won't Stop

Kara's ongoing quest to tame her codebase continues. First it was serialization, then more strings, then some serial communication.

Today, it's threads.

The original developer was a physicist and an extremely smart person. They never learned too much about databases, but they knew their way around XML, so they had a simple solution to storing data: any time you wanted to save something, rewrite an entire XML file onto disk.

Now, in this case, the "something" being saved is data collected from a piece of scientific equipment. That data is collected by sending commands to the device, changing its state, and asking it for information about readings in that new state.

Since this is a complex, long-running process, the developer used threads. Since it's complex and long running, it needs to be stoppable. And this is how they chose to stop it:

System.Threading.Thread RunThread; enum StopReason { Completed, Aborted, Error } void StopRun(StopReason why) { try { if (RunThread != null) { RunThread.Abort(); } } catch (ThreadAbortException ex) { } finally { if (Thread.CurrentThread != RunThread) { RunThread.Join(); } OnRunStopped(why); } }
 

You'll note the catch block in there, the catch with absolutely no body. Fun fact: C# lets you omit the catch and do a simple try/finally pair.

Of course, the exception only is an issue because they're calling Abort. In .NET, an aborted thread has no chance to do any cleanup or shutdown. It just ends.

If you were, say, a piece of software that was interacting with a scientific instrument and writing data directly to an XML file, aborting the thread could leave both the instrument and the XML file in unknown, incoherent states.

Which is exactly what happened. Kara changed the stop behavior to actually stop the thread, gracefully.

[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

Split Second Decision Saves Man From Oncoming Car

Check out in this video how Split Second Decision Saves Man From Oncoming Car. The scene occurred on April 1, 2019 in Isle of Skye, Scotland. From the man: “I was traveling alone on my way home from work, going around a corner with a restricted view when I was suddenly faced with an oncoming […]

The post Split Second Decision Saves Man From Oncoming Car appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Tuesday, April 9, 2019

Adorable puppy discovers squeaky ball for the first time

Check out in this video how adorable puppy discovers squeaky ball for the first time. This is the first time Luka, a German Shorthaired Pointer, meets a squeaky ball. She was only 8-weeks-old at the time and it kick started a life long love of squeaky toys.

The post Adorable puppy discovers squeaky ball for the first time appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

CodeSOD: Count Me Out

“My program needs to send some emails,” the developer thought to themselves. The then thought about how this could go wrong, probably thinking that, boy, they’ve got an external server, and boy, spam is a problem, and that server might get upset if you’re sending too many messages at once, or too quickly. That’s a thing which could happen, right?

That’s at least a plausible line of thought for the code Juana found, which looks something like this:

         public function processQueue($method)
                {
                        $counter = 0;
                        while (($result_item = $this->_getProcessableItem($method)) !== null) {

                                // .....
                                // Here we process the item, e.g. sending some email.
                                // .....
                        
                                if (++$counter % 10 == 0)
                                        sleep(2);
                                else if (++$counter > 100)
                                        break;
                        }
                }

So, this method grabs items out of a _getProcessableItem method, and as long as there are items in the queue to process, it does something to them, including sending an email. And then there are the if statements.

If you’re just skimming the code, it’s easy to miss the error. We check ++$counter to see if it’s divisible by ten, and if it is, sleep for two seconds. Why two? Why sleep at all? That information isn’t here, either in comment or commit message form. We just do.

Or do we? Because we also check if ++$counter > 100… which also increments the counter. That check works, but because it’s there, our mod–10 check doesn’t. Counting is hard, and since this loop essentially counts by two, ++$counter % 10 is always going to fail.

[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

Monday, April 8, 2019

This Guy Gives a New Meaning to ‘Bullseye’

Check out this video of a boy who pulls off a one-in-a-lifetime ping-pong trick shot! Similar videos might be a dime a dozen online, but behind each one stands dedication, tireless practices and the thrill of never quite knowing which attempt will be the winning one! The boy’s stunned reaction is something you cannot fake! […]

The post This Guy Gives a New Meaning to ‘Bullseye’ appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

CodeSOD: Zoning Out

Matthew D was recently helping a friend plan a trip to Europe from the US. After shopping around a bit, they found a rather affordable airline based out of Poland that fit both their budget and their destination, and started booking a flight.

It was going well until it came time for them to enter their passport information. The site complained that the expiry date was invalid. Since that complaint was happening without a page reload, Matthew was pretty sure it was a buggy bit of client-side validation, so he pulled up the dev tools and poked around.

var validExpiryDate = function(val, fieldNode, ruleValue){ var idField=fieldNode.attr("id").split("_"); var idPax=idField[idField.length-2]; var nDoc=idField[idField.length-1]; var type_document = A.one('#_retrievepnr_WAR_lotairwaysportlet_change-type-document_'+idPax+'_'+nDoc); if (type_document!=null && type_document.val() == "") { return true; } if (val.length <= 8) { var day_value = A.one('#_retrievepnr_WAR_lotairwaysportlet_change-expiry-day_'+idPax+'_'+nDoc).val(); var month_value = A.one('#_retrievepnr_WAR_lotairwaysportlet_change-expiry-month_'+idPax+'_'+nDoc).val(); var year_value = A.one('#_retrievepnr_WAR_lotairwaysportlet_change-expiry-year_'+idPax+'_'+nDoc).val(); if ((day_value == "" && (month_value != "" || year_value != "")) || (month_value == "" && (day_value != "" || year_value != "")) || (year_value == "" && (day_value != "" || month_value != ""))) { return false; } else if (day_value == "" && month_value == "" && year_value == "") { return false; } if (day_value.length < 2) { day_value = '0' + day_value; } if (month_value.length < 2) { month_value = '0' + month_value; } var date_select = new Date(Date.parse(year_value + "-" + month_value + "-" + day_value + "T00:00:00Z")); var day_select1 = date_select.getDate(); var month_select1 = date_select.getMonth() + 1; var year_select1 = date_select.getFullYear(); if (day_select1.length < 2) { day_select1 = '0' + day_select1; } if (month_select1.length < 2) { month_select1 = '0' + month_select1; } if (day_value != day_select1 || month_value != month_select1 || year_value != year_select1) { return false; } var ageDifMs = Date.now() - date_select.getTime(); var ageDate = new Date(ageDifMs); var age = Math.abs(ageDate.getUTCFullYear() - 1970); var isNotExpired = Date.now() < date_select.getTime(); if (isNotExpired) { return true; } else { return false; } } else { return false; } }
 

There's a lot of ugly in this code, with how it's grabbing DOM elements, how it's handling the validation and padding of the date input fields. It's hard to tell from just looking at the code, but the purpose is to make sure that the expiration date is a valid date in the future.

Someone once heard that comparing against timezones was dangerous, so they decided to coerce the date into the same timezone:

var date_select = new Date(Date.parse(year_value + "-" + month_value + "-" + day_value + "T00:00:00Z"));
 

That puts it all at UTC+0. Even there, that raises a curious boundary condition: if my passport expires on, say, 4/30/19 but was issued in UTC+5, is it still valid on 4/29/19 at 10PM in a location at UTC+0? I'm sure there are rules about that, and I'm sure the developer wasn't actually thinking about those rules at all.

And that's why, at the very end, their method of checking is simply Date.now() < date_select.getTime(). date_select contains a date in UTC+0. Date.now() will always contain a date in your local TZ.

Now, in most cases, that's probably not a serious problem, and the "key" not expired check- var isNotExpired = Date.now() < date_select.getTime(); will work most of the time.

The problem, and the real WTF, is that before doing that check, they also do this check:

if (day_value != day_select1 || month_value != month_select1 || year_value != year_select1) { return false; }
 

Here, they compare: if the value that came in from the form fields don't match the values in our time-zone converted date, their expiry is invalid.

Which, if you happen to be say, in UTC-8 and you're booking your flight in the evening, it's already the next day in UTC+0, so this won't pass. In fact, if you're in any TZ other than UTC+0, and you try and book your flight at the wrong time, it won't pass.

Of course, since this airline is based out of Poland, their home base is UTC+1, so this bug would almost *never* trigger there. Almost never.

[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