Monday, October 5, 2015

What is ::ffff:

I was adding additional logs for my Node.js Web app. During testing, I noticed my IP address is logged as "::ffff:" instead of "". Turns out this is due to the transition from IPv4.

::ffff:0:0:0/96 — A prefix used for IPv4-translated addresses which are used by the Stateless IP/ICMP Translation (SIIT) protocol.

Stack Overflow user rockerBOO explained:
Windows 7 has IPv6 enabled by default. Even though my server listens on IPv4 only, Windows 7 sends the ::ffff: prefix to the IPv4 as part of the transition to IPv6.

node.js - Express.js req.ip is returning ::ffff: - Stack Overflow
IPv6 address - Wikipedia, the free encyclopedia

Sunday, October 4, 2015

Node.js: How to get client's IP address

var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;

Wednesday, May 20, 2015

GitHub: Getting the download count for your releases

Do you own a GitHub repository? Did you ever wonder how many people downloaded your releases? Apparently there's an API for that!

For example, you can get the metadata of your latest release by making a GET request:<username>/<repo_name>/releases/latest

It returns a json payload, which has a download_count for each asset.

Getting the download count for your releases - User Documentation
Releases | GitHub API

Thursday, May 14, 2015

Android: unable to uninstall application

A friend of mine wanted to uninstall an app from his Android phone. But for some reasons, the "Uninstall" option is disabled. I tried running adb uninstall <package_name>, but it failed to uninstall.

Checking logcat, there was a warning:
W/PackageManager: Not removing package has active device admin

Basically, this app has device admin features enabled, meaning it can erase your phone's data if you lost your phone for example. So we need to first go into Settings > Location and Security > Device Administrator, and disable the app before we can uninstall it.

uninstall - How to remove an app with active device admin enabled on Android? - Stack Overflow

Monday, May 4, 2015

IE: Issue with Compatibility View settings in Internet Explorer 11

I wrote a Web app using AngularJS for an intranet site. Everything works fine, except a few users reported that they were seeing a blank screen. They confirmed that they were running the latest version of IE 11. But when I check it on mine, the page shows up properly.

It turns out those users have one thing in common: under Tools > Compatibility View settings, the "Display intranet sites in Compatibility View" option was checked. The simplest solution is to ask the user to uncheck that option, which is not ideal.

A better solution is to use a meta tag to instruct IE to always use the latest standards rendering mode:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

It would prevent IE from rendering the page with an older rendering engine. And now my Web app displays correctly regardless of the Compatibility View settings.

Understanding Compatibility Modes in Internet Explorer 8 - We know IE! - Site Home - MSDN Blogs
Fix site display problems with Compatibility View - Windows Help

Wednesday, April 22, 2015

AWS EC2: Install Node.js on an Amazon Linux AMI instance

I wanted to install Node.js on my Amazon Linux EC2 instance. Unlike Ubuntu, I can't just apt-get install nodejs.

The solution appears to be very simple. I just need to enable the EPEL (Extra Packages for Enterprise Linux) repository to get yum install to work.

1. Edit the repository config file
  sudo nano /etc/yum.repos.d/epel.repo

2. In the [epel] section, change the enabled flag to 1

3. Press Ctrl+O to save the file, and then Ctrl+X to exit

4. Update yum
  sudo yum update

5. Install npm and Node.js
  sudo yum install npm

6. Verify Node.js is installed
  node -v

How to install node.js on AWS AMI Linux instance | SpiderSoft

Tuesday, April 14, 2015

Java: Send email through Gmail's SMTP server

There are various examples of using the JavaMail API for sending emails, e.g.
I was able to get my program up and running relatively quick. However, the code stopped working once I deployed it to my AWS EC2 instance. It threw an javax.mail.AuthenticationFailedException, and links to

Following the link above, I was able to resolve the issue by enabling allow less secure apps and allow access from a new location or device.