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