Using Android Apps on PC

Yesterday before going out for our usual shopping my younger brother told me he needed to use WhatsApp as soon as possible. His phone was damaged and there wasn’t any time to visit a repair shop. So, what did I do?

Having a strong conviction that there had to be a way to use WhatsApp without having a phone on hand, I hit the internet in search of a way. I ran into a Quora article discussing a few ways of doing just that (Quora was finally really useful! Kidding – Quora is an awesome site). So, I discovered two applications that could accomplish this – one Andy Emulator and another BlueStacks.

So, I tried out Andy Emulator on my Lenovo PC. One large download later and several minutes of supposed-installation, nothing happened. Perhaps there was a bug with the software on my PC, I don’t know. Either way, being in a hurry, I quickly switched gears and tried BlueStacks. Download was quick and the app started without problems. A short while later, my younger brother was able to happily install WhatsApp into BlueStacks, then we put his SIM card into my phone and used that to verify his phone number on WhatsApp’s request, and voila! He was able to use WhatsApp from the PC without a phone! Happy with his triumph, he went on to install some other of his favourite Android apps successfully.

By and large, it’s really amazing to see how virtual machines like BlueStacks, VirtuBox, etc. have greatly increased the range of operating systems, and consequently applications, available to users from a single piece of hardware. For the most part, gone are the days when, just because an application was written for one operating system, a user needs to have just one type of hardware to use that application. I guess the next big leap would be to be able to use software without conventional hardware, e.g. embedding software chips directly into the brain. There’re probably people working on this already. Looking at the proliferation of Internet of Things (IoT), everything is becoming “smart” these days, it’s only a matter of time when we become “smart” people as well. Fun times ahead.

Cool Chords for Gospel Music

Hi folks,

Today I will discuss a few good chords to use for each number of the scale, in the key of D♭ major.

D 1st tone

Chord LH RH Notes
D (add 9) D D E F A
or
E A D
D quartal chord D B E A
D♭ maj7 D C F A
D♭ maj9 D C E F A
D♭ 9 (add 6) D F B B E Secondary chord (not starting)
D♭ 13 D B E G B

E 2nd tone

Chord LH RH Notes
E♭ min7 E B D G
E♭ min9 E G B D F
or
F G B D
E♭ 9 (add 6) E G C D F
E♭ min7 (♭5) E A D E G
E♭ 9 E G B D F

F 3rd tone

Chord LH RH Notes
F 7 (#9 #5) F A D E A
Dmaj / F F A D F#
Any 1 tone chord over F F D E F A
F half-dim7 F A B E

G 4th tone

Chord LH RH Notes
G♭ maj7 G F B D
G (add 9) G G A B D
G♭ maj7 (add 6) G B E F B

A 5th tone

Chord LH RH Notes
A♭ 13 A G B D F
A – 4 chords A 1. G♭ maj (D G B)
2. A♭ maj (E A C)
3. D♭ maj (F A D)
4. A♭ maj (E A C)
Any 1 tone chord over A bass
Any 3 tone chord over A bass A C F A
Any 4 tone chord over A bass A D G B
A (add 9) A A B C E
A♭ min9 A G B B E

B 6th tone

Chord LH RH Notes
B♭ min9 B A C D F
B♭ 13 B A C E G
B♭ 7 (♭9) B A B D F This is a diminished chord
C maj7 (#5) / B B C E A B
4 tone chord / B B D G B

C 7th tone

Chord LH RH Notes
C min11 C E G B D F
4 tone major chord / C C B D G
6 tone minor chord / C C B D F
5 tone major chord / C C A C E

With these chords you can create some really awesome sounding gospel music if you make good use of patterns. Hopefully I’ll post a recording of some songs played using these soon.
If you want to learn more about these chords or what cool music you can play with them, I refer you to Hear and Play Gospel Keys 202 – http://info.hearandplay.com/gk202quizgmtcmcjg/?code=infemail.

Enjoy!

How to wait for visibility in PhantomJS

I found an excellent piece of code on Stack Overflow on how to wait for elements to become visible before performing an action in PhantomJS. I thought I would share it here.

Here is the function required:

function waitFor ($config) {
    $config._start = $config._start || new Date();

    if ($config.timeout && new Date - $config._start > $config.timeout) {
        if ($config.error) $config.error();
        if ($config.debug) console.log('timedout ' + (new Date - $config._start) + 'ms');
        return;
    }

    if ($config.check()) {
        if ($config.debug) console.log('success ' + (new Date - $config._start) + 'ms');
        return $config.success();
    }

    setTimeout(waitFor, $config.interval || 0, $config);
}

Then use the code as follows:

waitFor({
    debug: true,  // optional
    interval: 0,  // optional
    timeout: 1000,  // optional
    check: function () {
        return page.evaluate(function() {
            return $('#thediv').is(':visible');
        });
    },
    success: function () {
        // we have what we want
    },
    error: function () {} // optional
});

Reference

http://stackoverflow.com/questions/16807212/how-to-wait-for-element-visibility-in-phantomjs

How to Enable Custom Error Pages for Apps using Nginx and uWSGI

Here’s a quick tutorial on how to enable error pages on your application when using uWSGI and Nginx. Let’s assume you have your nice custom 500 error page created and want Nginx to use it. First, add the error page configuration to Nginx as follows:

 

error_page 500 /my_500.html
location = /my_500.html {
   root /some/path;
}

You may notice Nginx still serves its default 500 error page. To make your custom pages work, add the following statement:

uwsgi_intercept_errors on;

That’s all for now. Happy coding!

How to Disable Specific Pylint Checks

Suppose you’re working on a Python application and using Pylint to monitor code quality, you may come across specific lines in code where you do not want Pylint to check. Here’s how you disable such check.

Add a comment of the form:

# pylint: disable=some-error-attribute

To re-enable checks within the same function, you can use a comment like

# pylint: enable=some-error-attribute

You may place the disable comment just able the block of codes you want to disable checks for and any code after that line in the function will not be checked for the attribute. You can also place the comment just after the code on the same line so it acts only on that line.

The Pylint documentation [1] has a lot more information and examples on these.

References

1. Messages control — Pylint 1.7.0 documentation. https://pylint.readthedocs.io/en/latest/user_guide/message-control.html [08/03/17].

How to fix MySQL Error: The server quit without updating PID file

When using a Mac, having installed MySQL using Homebrew, you may run into an error as follows when trying to start MySQL perhaps after changing some MySQL configuration:

. ERROR! The server quit without updating PID file (/usr/local/var/mysql/your-pc-name.lan.pid).

Here’s a quick way to fix it:

Check the ownership if /usr/local/var/mysql/. If it is not owned by mysql user, then simply make it owned by mysql with the following command:

sudo chown -R mysql /usr/local/var/mysql/

Then start the service once more.

sudo mysql.server start

That’s all!

Reference

1. MySql server startup error ‘The server quit without updating PID file’ – Stack Overflow. http://stackoverflow.com/questions/4963171/mysql-server-startup-error-the-server-quit-without-updating-pid-file [4/3/2017].

How to install a local package via pip

Assuming you have set up your setup.py script in your local package sitting on your machine and you want to install this package in another project using pip, then first you can build an archive of your package using the following command:

python setup.py sdist

This will create a dist folder in your package and put the archive inside it.

Next, switch to the virtualenv of the destination project if applicable and install the package using a command like:

pip install /srv/pkg/mypackage/mypackage-0.1.0.tar.gz

Reference

1. Installing Python packages from local file system folder with pip – Stack Overflow. http://stackoverflow.com/questions/15031694/installing-python-packages-from-local-file-system-folder-with-pip

How to Perform an Action on Key Press in Angular JS

Here’s a quick way to perform certain operations on key press in an input field while working with AngularJS. E.g. say you want to prevent non-digits from being accepted in an input field.

<input name='foo' id='foo' ng-model='foo' ng-keypress="isNumber($event)" />

Then in your controller, you can do something like:

$scope.isNumber = function (event) {
    var charCode = (event.which) ? event.which: event.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        event.preventDefault();
        return false;
    }
    return true;
};

How to Scroll to Top of Page on Changing Location in AngularJS App

In this post I discuss a quick way of fixing a minor annoyance you may experience while developing apps with AngularJS. Specifically, you may notice that when your app navigates from one url to another, the scroll location remains the same, which could causes lots of usability issues. To fix this, in your Angular module’s run method, call anchorscroll() in a callback function to the $locationChangeSuccess event as follows:

 angular.module('myAngularApp')
.run(function($rootScope, Auth, $state, $anchorScroll){
    $rootScope.$on("$locationChangeSuccess", function(){
        $anchorScroll();
    });

References

Changing route doesn’t scroll to top in the new page. Stack Overflow. http://stackoverflow.com/questions/21055952/changing-route-doesnt-scroll-to-top-in-the-new-page.