A review of Logitech G710+; why I love it so much for coding

I had been using a Logitech K120 that I bought for more than three years for my typing activities. It was a value for my money and had served me through my debt laden days. However, it showed its age when its stiffened keys start to disrupt my typing pretty frequently to the point where I started to get physically tired from typing.

That was not acceptable to me as I spent most of my time in front of my computer. And hence, it was time for me to buy a new one as I had some budget in my hands. I had been hearing about mechanical keyboards for some time. In fact, people who love to game often turn to mechanical keyboards to quench their gaming thirst. Gaming can require a serious amount of typing, especially when played in a team setting.

I would say I am bias when it comes to choosing keyboards and mice; I always buy from Logitech. After some research, I settled on Logitech G710+ Mechanical Gaming Keyboard with Tactile High-Speed Keys.

How I make my Jenkins Slave Windows Service recognize the global modules installed by npm

I was trying to setup a Jenkins Slave on a Windows machine which will get protractor to run a series of functional tests that the team had written to test our AngularJS application.

Idea was that whenever that there was a code change being committed to the master branch on our GitHub repository, the Jenkins Slave will be called upon to checkout the latest codes and get protractor to run the functional tests base from a configuration.js file in the codebase.

One of the hurdles that I encountered was that my Jenkins Slave Windows Service was not able to recognize the executables from Node.js modules that were installed by npm globally, which in this case was the protractor executable.

This post describes the steps that I took in order to make Jenkins Slave Windows Service recognize the global modules installed by npm.

How to look for unittest.TestCase subclasses defined in random Python scripts and run them in one shot

To ensure robustness of our Python application, members of the team had written unit test cases to assert that the various code units of the application are working as intended. Unit test cases that are meant to test the same program component are placed together as functions of the same class and contained in a Python script.

As the Python application grows, the number of test scripts grew as well. In an attempt to perform automated unit testing with Jenkins, the first thing that I did was to write a Python script that will look for all the test cases in the application directory and run them at one go.

This post describes the Python script in detail.

How to look for classes defined in Python 3 files dynamically

There are times when we need to write Python codes that extends the functionality of others, especially when we are writing a framework that allows for custom extension. To allow my Python program to be extended by others via the template design pattern, the first exploration task that I did was to find out how to dynamically look for classes defined in arbitrary Python files.

This post documents a way to look for classes defined in Python 3 files dynamically.

How to traverse all folders and files within a folder dynamically in Python 3

I had this requirement where I need to be able to look into a folder and pick up any configuration files for my Python 3 application. In order to achieve that, I first set an exploratory task to get the Python 3 code for traversing all folders and files within a folder.

For this exploratory task, I had created a script that will traverse the folders and files that are contained within a folder and print out their full paths.

How I solved the database connection error from my WordPress installation which is hosted on the default PHP FPM server in Mac OS X EL Capitan

I was trying to setup a WordPress instance with the built-in PHP-FPM server on my Mac OS X el Capitan. After applying the relevant Nginx configurations for WordPress installations, I had been able to run the php codes from my WordPress instance.

However, when I tried to run the WordPress install script, my WordPress setup complained that it was unable to connect to the database server.

How to get the directory path of a Python 3 script from within itself

One of the best way to reference files in Python scripts is to based the file path on the directory where the Python script resides in. This will allow us to always reference our files correctly no matter where our Python script is being executed.

This post documents the Python 3 code that I often used to get the directory path of a Python 3 script from within itself.

How to loop through lines of text in a text file from a shell script dynamically

There are times when we need to dynamically run shell commands based on the items listed in a text file.

The shell script that I ran in my bash shell does the following:
for each line separated by newline and not preceded by a ‘#’ character, print the line to console.

In order to build the shell script, I would need the following code pieces:

  • A way to remove/delete empty lines or leading and trailing whitespace in a text file
  • A way to loop through the text file, line by line
  • A way to check if the first character of the string

This post documents what I had ran in my bash shell (in Ubuntu 14.0.4) to loop through items separated by newlines in a text file.

Preventing image hotlinking with Nginx, with some style

Image hotlinking is a situation when your image appears on other website(s) but that image was actually being served by your web server. Image hotlinking is bad; your image gets stolen from your website and your server resources is being spent to serve them. If you happen to be running Nginx as your web server, this post describes how you can use Nginx to prevent image hotlinking with a smarter way that was suggested by Hongkiat.