Code or Die Welcome to my kitchen

Yak shaving tips, Infosec, Astronomy, Gardening

This is my blog. Proud guardian of three cats and two dogs, I currently reside in San Antonio, Texas.

I'm interested in gardening, astronomy, infosec among other pursuits. About this site.

Past and current projects.. You can also browse the blog archive if you like.

Message of the Day: Under construction

Best 2018 Chicago Tech Events for Students

I’ve lived in Chicago three years so here are my favorite tech meetups and recurring events in terms of my interest and availability to students in general. Most require an RSVP.

From jQuery to Vanilla JavaScript

No disrespect to jQuery, a phenomenal and lasting tool, but I saw fit to extirpate it from my blog’s code. I set about untying it from the underpins until coming to the last remaining use case, simply opening external links in their own window/tab. The problem was recreating the ready() function to know when page content has finished loading, without requiring all the machinery of jQuery.

Existing jQuery snippet:

jQuery(function ($) {
  //Change target attribute of external links
  var domain_root = document.location.protocol + '//' + document.location.host;
  var all_links = $('a').each(function (index, element) {
    if (element.href.substr(0, domain_root.length) !== domain_root) {
      element.target = '_blank';
    }
  });
});

Replaced by Vanilla JavaScript snippet:

var domReady = function(callback) {
    document.readyState === "interactive" || document.readyState === "complete" ? callback() : document.addEventListener("DOMContentLoaded", callback);
};

domReady(function() {

  var links = document.links;

  for (var i = 0; i < links.length; i++) {
    if (links[i].hostname != window.location.hostname) {
      links[i].target = '_blank';
    }
  }
});

Now using domReady() as vanilla JS analogue to jQuery’s ready() function.

Shout out to beeker.io for providing a complete solution!

Another Word on Google Analytics

Almost a year ago I wrote a post about keeping Google Analytics (GA) data clear of perturbations such as spam and other tomfoolery. It is now time to revisit the topic, since reports have surfaced in the past weeks of just this sort of activity happening.

I checked my GA dashboard and am happy to report my filters from a year ago seem to have served to deter the very actions being reported1.

What’s really going on?

In my reports there is no sign of the dreaded new language ‘Secret.ɢoogle.com’ nor unauthorized redirects to my page. To fully understand why these “attacks,” are occurring, check out the excellent posts2 by Carlos Escalera, which explain in detail the modus operandi of our bad actor in this instance.

It appears to be some sort of bizarre guerrilla marketing tactic, which although may be causing a few headaches and require some extensive re-tooling by GA engineers, is thankfully not quite the caliber of the massive denial-of-service (DoS) attack experienced October 2016 on a major U.S. DNS provider.

To recap, nefariousness abounds, but as always being proactive with safety now can save loads of trouble in the future. Enabling filters on GA to make sure only actual traffic and legitimate referral hits get reported can help shield data from unwanted noise or worse.

The latest information points to Google working to prevent this action from being carried out on their service3, although new reports are stating the spam is being carried out now in a slightly different manner4. As so often happens the best solution is for devs to protect themselves.

In closing I’d like to point out the October 2016 attack5 which disrupted much of U.S. web service was a stark reminder of a fundamental tenant of computer science: a sufficiently large system is in constant state of partial failure. The design principle of robustness directs us to write software capable of functioning even if a large portion of the system fails. Although these two incidents are very different, they both serve to illustrate the fact we still have far to go in making the Internet a more robust system.