Monday, February 12, 2018

Bowling Disaster

When you have never thrown a bowling ball in your life, please practice first before doing so. Ugly things can happen when bowling for the first time, as this sweet, innocent lady demonstrates. As a […]

The post Bowling Disaster appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Goat Triplets In Sweaters

Is there anything cuter than these fluffy guys? Their fur prevents them from getting cold already, but their owner didn’t want to take half measures. Their knitted sweaters look adorable!

The post Goat Triplets In Sweaters appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Coded Smorgasbord: If It's Stupid and It Works

On a certain level, if code works, it can only be so wrong. For today, we have a series of code blocks that work… mostly. Despite that, each one leaves you scratching your head, wondering how, exactly this happened.


Lisa works at a web dev firm that just picked up a web app from a client. They didn’t have much knowledge about what it was or how it worked beyond, “It uses JQuery?”

Well, they’re technically correct:

if ($(document.getElementById("really_long_id_of_client_side_element")).checked) {
    $(document.getElementById("xxxx1")).css({ "background-color": "#FFFFFF", "color": "Black" });
    $(document.getElementById("xxxx2")).css({ "background-color": "#FFFFFF", "color": "Black" });
    $(document.getElementById("xxxx3")).css({ "background-color": "#FFFFFF", "color": "Black" });
    $(document.getElementById("xxxx4")).css({ "background-color": "#FFFFFF", "color": "Black" });
};

In this case, they’re ignoring the main reason people use jQuery- the ability to easily and clearly fetch DOM elements with CSS selectors. But they do use the css function as intended, giving them an object-oriented way to control styles. Then again, one probably shouldn’t set style properties directly from JS anyway, that’s what CSS classes are for. Then again, why mix #FFFFFF and Black, when you could use white or #000000

Regardless, it does in fact use JQuery.


Dave A was recently trying to debug a test in Ruby, and found this unique construct:

if status == status = 1 || status = 2 || status = 3
  @msg.stubs(:is_reply?).returns true
else
  @msg.stubs(:is_reply?).returns false
end

This is an interesting case of syntactically correct nonsense that looks incorrect. status = 1 returns a 1, a “truthy” value, thus short circuiting the || operator. In this code, if status is undefined, it returns true and sets status equal to 1. The rest of the time it returns false and sets status equal to 1.

What the developer meant to do was check if status was 1, 2 or 3, e.g. if status == 1 || status == 2…, or, to use a more Ruby idiom: if [1, 2, 3].include? status. Still, given the setup for the test, the code actually worked until Dave changed the pre-conditions.


Meanwhile, Leonardo Scur came across this JavaScript reinvention of an array:

tags = {
  "tags": {
    "0": {"id": "asdf"},
    "1": {"id": "1234"},
    "2": {"id": "etc"}
  },
  "tagsCounter": 3,
  // … below this are reimplementations of common array methods built to work on `tags`
}

This was part of a trendy front-end framework he was using, and it’s obvious that arrays indexed by integers are simply too mainstream. Strings are where it’s at.

This library is in wide use, meant to add simple tagging widgets to an AngularJS application. It also demonstrates a strange way to reinvent the array.

[Advertisement] Release! is a light card game about software and the people who make it. Play with 2-5 people, or up to 10 with two copies - only $9.95 shipped!


To read the full article, please visit The Daily WTF

Sunday, February 11, 2018

Father Sticks Up For Teen Daughter’s Dress Code

Usually as a traditional dad, you’d want your daughter to dress as conservative as you can get away with, but not this one. This father is all about femininity and expressing yourself. If only all […]

The post Father Sticks Up For Teen Daughter’s Dress Code appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos

Riding Bikes Through Giant Snow Tunnel

When there’s snow, you better have fun. How about this one, where they built a gigantic snow tunnel, to ride through with their bikes? Pretty damn cool if you ask me, I hope it was […]

The post Riding Bikes Through Giant Snow Tunnel appeared first on Viral Viral Videos.



To read the full article, please visit Viral Viral Videos