Monday, October 24, 2016

.htaccess missing from server breaks all page links except index.php

I had deployed my application from my new Mac, my first time, and got an error on AWS:

the requested URL /about was not found on this server

I struggled trying to debug my application and then figured out it had to do with my server. Which means, the issues was with my file: .htaccess

Come to find out after nobody made the following simple statement, I figured out the solution.

  1. Show all hidden files on your Mac.
  2. Go to the directory/folder that you're zipping up to upload and deploy on ElasticBeanstalk in AWS.
  3. Zip up all the subfolders and files (by compressing into .zip file), but make sure the '.htaccess' file is included!
  4. Then upload and deploy in AWS.

Tah-dah! Another problem solved!


Wednesday, September 7, 2016

D3 - Coding with Readability and Usefulness, no more d variable

One of the things I find so irritating is the overuse of letters which lack sufficient readability (to understand code without having to dig into the back-end to gain meaning).

I'm learning and working on D3 stuff and I see many examples using the letter d. This d stands for data, obviously. BUT, almost everything in the world is a d (i.e. data). Needless to say, I had to update code to ensure better understanding and programming. Here's my example of better coding using D3.

Before

groups.selectAll('text')
    .data(function (d) {
        console.log(d);
        return d;
    })
    .enter()
    .append('text')
    .text( function (d, i) {
        console.log(i);
        if (typeof d === 'number')
        {
            console.log("data type is a number, not object...skipping.");
            return;
        }
        console.log(d);
        return d.x;
    });

After

groups.selectAll('text')
    .data(function (arr) {
        console.log(arr);
        return arr;
    })
    .enter()
    .append('text')
    .text( function (obj, i) {
        console.log(i);
        if (typeof obj === 'number')
        {
            console.log("data type is a number, not object...skipping.");
            return;
        }
        console.log(obj);
        return obj.x;
    });

In the After, I updated the d within the data method into "arr" as its a data array representing the dataset passed in. I updated the d within the text method into "obj" as its a data object of the data array passed in.

I hope this helps somebody.

Blessings,

Thursday, September 1, 2016

Debugging - PHP + Javascript - Unexpected Token <

I recently came across an unusual error in the JavaScript Console when processing my PHP code into JavaScript to display in the browser. The line number provided in the console is misleading - b/c it's not the actual line number with the error. So I don't use the 'line number' information to debug.

Error

Code

The root cause is how either PHP is calculating the 'addition assignment' operation (i.e. a += b; ) within JavaScript tags during compilation or how JavaScript is processing the PHP output before displaying to the browser. I'm not exactly sure as this would require more research and investigation on my part which I don't currently have time - yay, deadlines!



Initial Attempt

At first, I thought I needed to replace the shorthand 'addition assignment' operator into its expanded equivalent. (See the green arrow in my image below.)


The expanded equivalent would be:
a = a +b;
or according to my code:
// line 91
$num_of_users_per_org[$k][1] = $num_of_users_per_org[$k][1] + 1;

Solution

At last (within 5 minutes), I figured out that I need to initialize the 2nd array in my multi-dimensional array corresponding to 'user_count'.  (See the light green arrow in my image below.)



Proof

After adding the code and rendering again in the browser, our results pass and the code works. Bingo!

Click on image to enlarge (see clearly)

Nice Debugging Reference

Wednesday, August 31, 2016

Article - Russian, Chinese programmers are the most talented

Devs,

This is pretty insightful. I always knew that most of the talent was OUS, but also outside of India was kind of a surprise. Check out this article for details (although I'm not completely sure of its credibility).
http://www.infoworld.com/article/3113107/application-development/us-developers-have-the-numbers-but-china-and-russia-have-the-skills.html


Tuesday, August 30, 2016

Saving Print PDF version instead of Downloading Google Doc

Devs,

I recently downloaded a Google Doc into a PDF and saw all the text in bold. Screech! So, I found this answer helpful in getting the PDF format desired.

https://productforums.google.com/forum/#!topic/docs/fp5eDPafroY

Downloading to PDF


Save as PDF via Chrome's Print Page


Tuesday, August 2, 2016

Google's QUIC protocol - a review by Mattias Geniar

Devs,

Here's another great article for today's read.

https://ma.ttias.be/googles-quic-protocol-moving-web-tcp-udp/

This relates to improving network performance. Most people won't care if their networks are performing well. But, this network performance can make a huge difference for users who have poor network infrastructure like in 2nd, 3rd world countries. And with FB and Amazon attempting to provide wifi access in remote areas across the globe, this networking performance and connection reliability could make a tremendous difference. Let's stay tuned into Google's networking research.

Cheers,
G2