Checking on DNS

LeafDNS

Recently I had to check on a DNS problem at work, and the support person said “the DNS isn’t even pointed at us (the hosting)”.  I asked him how he could see that, and the response I received was:

Hey Sandy,

I rely on a Chrome extension that tells me what the IP address is for the particular page I’m on. Everybody has their own way of digging into this.

You can also use a tool like http://leafdns.com/ to get a view of the DNS records for a given parent domain.

Cheers!

I checked the leafdns website and I could see the nameserver error and the IP’s pointed at the domain in question (of course not the correct ones).  Filing this here for the next time I need to diagnose / troubleshoot DNS problems.

LeafDNS

Affix a class on scroll

Code Snippet

Bootstrap’s data-spy functionality was working, but then it started getting hung-up and not loading.  This site had the possibility of caching from 3 different sources (Bootstrap CDN, hosting caching, and Cloudflare CDN) and I think it was not allowing resources to load correctly.  I eliminated the data-spy option, and went straight to executing with just JavaScript, which seemed to eliminate the erratic behavior.

//caches a jQuery object containing the header element
var bumperredcon = $(".noBumper");
//the data-spy functionality for bootstrap stopped working, prob conflict with caching. Disable dataspy, rely only on this JS to add/remove the .affix class.
var bumperwhitepart = $(".noaffix");
$(window).scroll(function() {
var scroll = $(window).scrollTop();

if (scroll >= 100) {
bumperredcon.removeClass('noBumper').addClass("navBumper");
bumperwhitepart.removeClass('noaffix').addClass("affix");
} else {
bumperredcon.removeClass("navBumper").addClass('noBumper');
bumperwhitepart.removeClass("affix").addClass('noaffix');
}
});

The bumperredcon and bumperwhitepart are just some variables I have to declare so the script can continue to look for the actual named classes to remove (and then add). So unlike CSS or other coding techniques, it’s not actually looking for #bumperredcon nor #bumperwhitepart, those do not exist in my DOM.  It’s like I had to create a “car” and that car looks around the DOM for the specified classes it is supposed to add and remove.  Additionally, I had to add “noaffix” as the default class so the car had something to look for to get to replacing.

This was a bit of a hard concept for me to understand.

Improving Google PageSpeed in WordPress

Google PageSpeed 100

I set out to improve my Google PageSpeed score to 100. Through many trial & errors, I finally dumped my current theme and used just the default 2016 WordPress theme. Technically I should create a child theme if I was going to put it into production, but I just needed some insight so I ripped into the parent theme.

The end results for making 2016 theme score 100 is:

  1. Remove the external stylesheet style.css, minify it, and place it in the head.
  2. Remove references to Genericons and specialty fonts out of the functions.php file
  3. Minify the functions.js file
  4. Add this to functions.php to move the jquery scripts to the footer:
add_action('wp_enqueue_scripts', 'rudr_move_jquery_to_footer');  
 
function rudr_move_jquery_to_footer() {  
 	// unregister the jQuery at first
        wp_deregister_script('jquery');  
 
        // register to footer (the last function argument should be true)
        wp_register_script('jquery', includes_url('/js/jquery/jquery.js'), false, null, true);  
 
        wp_enqueue_script('jquery');  
}

This last step got me past the dreaded “remove render-blocking js”.

Practicality?

While this theme is now technically scoring 100, getting a site ready for production will be a little harder. As plugins are added and dependencies appear, the score will decline, but at least I now have a basis to start from (start a new theme) and can work on the score each step of the way.

Bookmark: Function found here:

https://rudrastyh.com/wordpress/render-blocking-javascript-css.html

 

Google PageSpeed 100

Fighting SPAM Referals

Today I added code to my .htaccess file to block some well-known spammy referal services that keep showing up in my Google analytics. SEMALT is the main company, but now they are spinning off into other main websites. I am documenting this today as part of my diary, to be able to benchmark statistics and look back over time to see how actions I took affects analytics in the future.

I think this one looks like the best advice… go right to the .htaccess file.

https://wordpress.org/support/topic/how-to-block-semaltcom-from-visiting-your-wordpress-website

Get Out of Here, SEMALT

You Suck. You are filtrating my analytics data with false data.

Testing remote publishing.

Testing remote publishing. Installed the WordPress app on my Android.  Now I can publish a post write from my phone, and I am going to try using the voice recognition to “type” my text.  I just speak into the post, click publish, and I instantly have a new blog post.  And I can update with images too.

1410915042377

Knockout – Javascript Framework

I decided to learn Knockout as my first Javascript framework because the Pluralsight tutorial I started said Knockout has a less learning curve (than Ember).  Since this is my first Javascript framework, I decided Knockout was a better choice for me right now.

I started with the Knockout tutorial and cataloged the lessons to act as crutches for my own attempts to code later: http://knockout.sandynichols.net/.

Now I am using PHP to query MySQL database, put the results in JSON, pass it over to knockout.  At the end of the weekend, I left off at:

  • Able to query database in PHP
  • Put results in Json
  • Pass it to knockout
  • Display 1 row of results on screen.

I have something wrong with the way the query loops through the results and puts it in a container because I am only getting 1 row.

This blog post is to help me remember where I left off. 6/22/14.

 

Javascript Rapid Prototype Tools – learn it.

Where do I start to master javascript rapid prototype tools?  Which one do I want to learn?

  • Node.js
  • Backbone.js
  • Angular
  • Ember

Here’s a tutorial, of sorts, for Backbone.js. Author claims it will have me up and going in 30 hours:

http://javascriptissexy.com/learn-backbone-js-completely/

 

Another, with addition of MongoDB:

http://backbonetutorials.com/nodejs-restify-mongodb-mongoose/

 

But the ember.js website looks like an easy quick start, just download the code and start.

Okay, according to this comparison, it looks like Ember should be the wise choice.

http://codebrief.com/2012/01/the-top-10-javascript-mvc-frameworks-reviewed/

 

But if I listen to Pluralsight tutorials, Ember is not the easiest choice and has a steep learning curve.

 

 

 

Google Analytics API: unknown redirect URL

Some success! I now figured out  the openauth 2.0 working with the Google Analtyics API.  I spent some time trying to figure out why I had error message “unknown redirect URL”.  After finally finding the GOOGLE API PHP CLIENT library, I looked under EXAMPLES and there is all the connection code you need for any google offering.  It still took me a *few* minutes to figure out the file structure. After reading the //comments in the example file, I learned what the error meant. The redirect URL has to be the second index file it hits.  That means the first index page you encounter (this one was named simple.php) you give all the proper API credentials, and then you click the “connect me” link.  That link takes you to the inside folder (the demo folder containing all the sample code) which has it’s OWN index page.  It’s that index page that is the redirect URL.

Google Analtyics API redirect URL helpSounds really simple right now, but hindsight is 20/20.

 

fileoutsidethefolder.php  (the credentials to get in)

Folder:

  • authHelpher.php
  • coreReportingApireference.php
  • error)log
  • helloAnaltyicsApi.php
  • index.php (once you login, redirect to this file inside the folder)
  • managementAPIReference.php
  • storage.php

 

Facebook API & Instagram API

Here’s what my coworker Kandice figure out for us on the FB api.  I am thankful to get this information from her, as she spent 7 hours trying to figure it out; she showed me how to do it in 3 minutes!

In the Facebook for developers site, after you have set up your app:

  1. Must have a contact email
  2. Go to Status & Review, on the right, make public.
  3. Go to Tools, Access Token; Grant permission to your app (its the first link)
  4. In the search box up top, search for “like box”; this box will give you recent posts and some stuff.  Make sure the URL is the clients FB URL.

I don’t remember it being this hard the last time I worked with some FB iframe stuff!

I found this article for working with the Instagram API, so I am archiving it here because I think I will need it soon!

http://www.developerdrive.com/2014/02/how-to-use-the-instagram-api/

 

Start with Zend PHP Framework

So I almost immediately ditched Symphony and Composer and moved to something I new at least a little: Zend PHP framework.

I was able to get the framework up and running, and in a short amount of time I got CRUD working.  I can create, read, update, and read records from my database.  I was able to get this working with authentication, so I moved even the read functionalities to the secure part of the website because the data contains an email field for website owners.

So this means the skeleton part of just housing and maintaining records is complete for now.

Hello oAuth!

Next phase is learning to interact with Google Analytics API.  I started reading about oAuth.

Intervention

Some paid web work has intervened my learning here for just a little bit.  I’ll be right back…