Code or Die Welcome to my kitchen

Yak shaving tips, Infosec, Astronomy, Gardening

This is my blog. Proud guardian of a square number of cats and one (1) dog, 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

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.

Expose Your Ignorance

Exposing your ignorance while learning a new discipline takes courage, humility and vulnerability. In fact I strive to do this in my posts; it is this blog’s raison d’être.

Having the courage to say “I don’t know,” or “I don’t understand this” is absolutely necessary to grow in one’s learning. As the saying goes, ‘no pain, no gain,’ and growing more often than not involves some measure of pain.

To elaborate more on this important point, I find the more I learn, the more I find I really know diddly-squat. Diddly-squat is a quaint American-English Southern colloquialism for jack-shit. The Classical Greek philosopher Socrates had it right, to paraphrase Plato’s interpretation of his words: ‘the more I know, the more I know nothing.’1

The part in Plato’s Apology of Socrates2 which really rings true to me from beyond the centuries is where Socrates, after having visited the politicians and poets, found them all wanting in knowledge. He then visited the craftsmen.

Socrates found that the craftsmen had knowledge of their own craft, but that they subsequently believed themselves to know much more than they actually did.3

This particular statement recalled a blog post I had read a few months back, written several years ago but still relevant. I happily managed to dig it back up, ‘How Developers Stop Learning: Rise of the Expert Beginner’ by Erik Dietrich.4

In it Erik describes the advanced beginner: someone who has surmounted the initial difficulties of learning a craft and is now able to tackle more complex rigorous problems. The familiar idea here is of progressing from beginner to intermediate, and ultimately to expert and master level of experience.

However, after achieving the advanced beginner phase, the expert beginner risks getting caught in a loop of their own making. They voluntarily or subconsciously cease to improve, in his words,

“because of a belief that expert status has been reached and thus further improvement is not possible.”

To bring it this home to my post, the expert beginner does not routinely expose their own ignorance, either because they are simply unaware of it or are too afraid of the consequences. Another possibility is they are under the Dunning–Kruger5 cognitive bias, mistakenly assessing their ability as much higher than it really is.

This was the concept in Erik’s article which I recalled when revisiting Socratic Ignorance. In order to progress in learning, you must routinely step back to recognize you are ignorant on most things; in fact what you know is minuscule compared to the big picture. Once this humbling fact is accepted, one’s mind is able to continue to seek out the fuel necessary to burn brighter.

On the side of the mentor, once the student through sufficient willpower, courage, and trust has exposed their ignorance on a subject, then effective teaching and learning cycles can occur.

Remember to be brave and expose your ignorance. Your path to learning depends on it.

Thanks for reading.