How do you clear the DNS Cache in your Asus 1900RT router?

Step 1:
Login to your router and enable SSH. You will find the SSH related settings at [http(s):// System (Tab).

You should see something similar to the screenshot below:

Click Apply at the bottom of the page after you enable SSH.

Step 2:
Login to you root through a terminal:

$ ssh -l admin 192.168.1.1
admin@192.168.1.1's password:
admin@(none):/tmp/home/root#

Step 3:
Issue the below command to reset the DNS Cache.

admin@(none):/tmp/home/root# killall -1 dnsmasq

Your router cache should be reset now. Alternatively, you can reboot the router to reset the cache.

Advertisements

Generate and import a Self-Signed SSL certificate on Mac OS X Sierra

Step 1: Verify that you have openssl installed.

$ which openssl
/usr/bin/openssl
$

If not, install openssl using:

$ brew install openssl
$

If you are using Microsoft(r) Windows, checkout http://gnuwin32.sourceforge.net/packages/openssl.htm for details about the openssl package on Windows.

If you using Linux, you can use the default package manager to get the openssl package installed on your box. For example:

# In case of Ubuntu:
$ sudo apt-get install openssl
$

Step 2: Create a RSA private key.

# The below command will create a file named 'server.pass.key' and place it in the same folder where the command is executed. 
$ openssl genrsa -des3 -passout pass:x -out server.pass.key 2048

# The below command will use the 'server.pass.key' file that just generated and create 'server.key'.
$ openssl rsa -passin pass:x -in server.pass.key -out server.key

# We no longer need the 'server.pass.key'
$ rm server.pass.key
$

server.key is a PEM RSA private key. To know more about what is a PEM file and it’s significance, read What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats? at serverfault.com.

Step 3: Create the Certificate Signing Request (CSR) utilizing the RSA private key we generated in the last step.

# The below command will ask you for information that would be included in the certificate. Since this is a self-signed certificate, there is no need to provide the 'challenge password' (to leave it blank, press enter).
$ openssl req -new -key server.key -out server.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []: <provide a CN - usually, FQDN of your site>
Email Address []: <provide the email address to be included in the certificate signing request>

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
$

The ‘challenge password’ is used by the Certificate Authority (CA) to authenticate the certificate owner when they have to revoke the certificate. There is no way to revoke a Self-Signed Certificate via Certificate Revocation List (CRL) (refer: https://devcenter.heroku.com/articles/ssl-certificate-self#generate-private-key-and-certificate-signing-request]

As a result of executing the above command, you will find a file named server.csr (‘csr’ stands for Certificate Signing Request) in the same directory.

Step 4: Generate a file named, v3.ext with the below listed contents:

$ cat v3.ext
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = <specify-the-same-common-name-that-you-used-while-generating-csr-in-the-last-step>
$

This step is required because when you load the certificate in the Chrome browser, it would display an error portrayed in the below screenshot.

Setting the DNS.1 value in v3.ext file to be same as the Common Name that you mentioned while generating the certificate signing request would resolve the error. Refer https://stackoverflow.com/questions/43665243/chrome-invalid-self-signed-ssl-cert-subject-alternative-name-missing for more details about the subject alternate name missing error and the solution.

  1. Create the SSL Certificate utilizing the CSR created in the last step.
    $ openssl x509 -req -sha256 -extfile v3.ext -days 365 -in server.csr -signkey server.key -out server.crt
    Signature ok
    subject=/C=<country>/ST=<state>/L=<locality>/O=<organization-name>/OU=<organization-unit-name>/CN=<common-name-probably-server-fqdn>/emailAddress=<email-address-provided-while-generating-csr>
    Getting Private key
    $
    

The above command will use the Certificate Signing Request and the RSA Private Key that we generated as part of executing the previous steps and generate a Certificate file named, server.crt (‘crt’ is an abbreviation of ‘Certificate’) and place it in the same directory.

Step 5: Import the newly generated certificate in your Keychain (Mac OSX only).

Since this is a self-signed certificate, the browser would display a warning mentioning that the certificate is self-signed and the website should not be trusted as portrayed in the below-listed screenshot captured on the Chrome browser.

Click the Advanced hyperlink at the bottom of the warning page and click Proceed to hyperlink.

The browser will allow you to proceed and open the homepage but will mark the site as Not-Secure as portrayed in the image below.

To avoid this accepting the self-signed certificate everytime you restart chrome or restart your web server, follow the steps outlined at Google Chrome, Mac OS X and Self-Signed SSL Certificates to add the certificate to your Mac OSX Keychain. Restart Chrome.

Other platforms like Microsoft(r) Windows and Linux have similar techniques to import a certificate into a browser. A quick Google(r) search should be able to provide you with the exact steps based on the browser that you use.

Now Chrome should happily display the green ‘Secure’ icon against the URL when you navigate to your locally deployed website. Also, the Security tab within the Developer Tools should list the site as ‘Secure’ as portrayed in the screenshot below.


References:

  1. Generating a self-signed certificate using OpenSSL
  2. How to create a self-signed certificate with openssl?
  3. Creating a Self-Signed SSL Certificate
  4. What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats?
  5. Chrome: Invalid self signed SSL cert – “Subject Alternative Name Missing”
  6. Google Chrome, Mac OS X and Self-Signed SSL Certificates

Turn GIMP look and feel into Photoshop

If you had ever planned to switch over from Photoshop to GIMP, the first thing that comes to mind is to figure out a way to learn and adjust to a look and feel that is different from Photoshop.

The developers of GIMP have designed the look and feel of GIMP to signify and portray the strengths of GIMP. The default look and feel (after selecting Window => Single-Window Mode) is similar to the screenshot below (captured on MacBook Pro with GIMP 2.8.22 installed).

While there is a learning curve involved in getting used to GIMP, it may help new comers migrating from Photoshop to change the look and feel of GIMP to the one they are used to while using Photoshop.

There are multiple suggestions and tutorials all over the web to help you achieve it. This article outlines one such method that I used to change the theme such that the look and feel is simliar to the one portrayed in the image below.

Step 1: Follow the instructions listed at https://github.com/doctormo/GimpPs/blob/master/README.md to install the excellent GIMP 2.8 Photoshop tweaks by the Deviant Art contributor who goes by the handle, Doctormo. The Deviant Art page that describes the GIMP 2.8 Photoshop tweaks is available at: https://doctormo.deviantart.com/art/Gimp-2-8-Photoshop-Tweaks-432736644.

Installing the tweaks by following the steps listed in the Doctormo’s README not only changes the look and feel of GIMP to that of Photoshop (more like a Photoshop CS6) but also installs the Photoshop keyboard shorts.

Step 2: Unlike Photoshop, by default, GIMP does not snap layers to the grid. To enable this feature, edit the gimprc file. This file can be found either in the ~/Library/Application Support/GIMP/2.8 folder or within the ~/.gimp-2.8 folder. If it does not exist, create one and place it in one of the two folders listed above. Append the below two lines to gimprc and restart GIMP.

(default-snap-to-canvas yes)
(default-snap-to-grid yes)

Credits:
One of the blogs that has heavily influenced the contents of this blog and also the options that I tried out is https://www.pcsteps.com/1566-make-gimp-look-work-like-photoshop/. It contains suggestions on additional changes that can be added to your GIMP installation to turn it more into Photoshop.


References:

  1. How to Make GIMP Look and Work like Photoshop
  2. https://github.com/draekko/gimp-cc-themes
  3. https://github.com/doctormo/GimpPs

Restore your Macbook Pro’s TouchBar soft ‘Esc’ key if it turns unresponsive (hung / struck)

It’s very rare that I either ‘Restart’ or ‘Shutdown’ my Macbook Pro. Most often, I just opt ‘Sleep’.

Since I do not reboot my Mac often, there are cases where I have found the TouchBar strip to turn unresponsive. One such instance occurred today as soon as I woke up my Mac. The soft Esc key on the TouchBar was unresponsive. Since it isn’t a physical key, there is nothing much I could do other than hitting it multiple times akin to a child!

I remembered that the TouchBar on the Macbook Pro runs on a dedicated ARM processor and a customized version of iOS. So, could I reboot (or force reboot) or restore or refresh it?

The answer is yes. There are few things we could do:

  1. We could Quit or Force Quite the Touch Bar Agent via the Activity Monitor or through the terminal, using the command: pkill "Touch Bar Agent".
  2. Refresh just the Control Strip, fire up the terminal and execute the command: killall ControlStrip.

It turns out that that soft Esc key on the TouchBar is part of the Control Strip. Therefore, the first option listed above did not fix my problem. But, the second option of refreshing the Control Strip fixed the problem.

In summary: if any of the soft buttons on your Macbook Pro’s TouchBar turn unresponsive, refresh the Control Strip using the command: killall ControlStrip.


Reference:

  1. Is there a way to restart the Touch Bar on MacBook Pro
  2. MacBook Pro Touch Bar stuck? Learn how to unstick it
  3. The new MacBook Pro’s biggest secret? It runs iOS on an ARM chip
  4. MacBook Pro’s new Touch Bar is powered by iOS
  5. Everything you need to know about the Touch Bar for MacBook Pro

How to fix the ‘Experimental Decorator’ warning in Visual Studio Code when working on React-Native codebase?

Recently, I started to work on a React-Native project which used mobx and firebase. As part of building the Authentication Store that would allow me to authenticate a user against the user data stored in the firebase account, I resolved to using the @observable and @action decorators available in as part of the mobx package. As the title of this article hints, Visual Studio Code was used as the IDE during the development.

When these decorators were used, VSCode displayed a warning as depicted below.

It read,

[js] Experimental support for decorators is a feature that is subject to change in a future release. Set the ‘experimentalDecorators’ option to remove this warning.

1.13.1 was the version of the Visual Studio Code in use.

How do we fix this?

  • Create a file, entitled, tsconfig.json (if not already present) in the root directory of your project folder.

    tsconfig.json represents the ‘TypeScript configuration options’ that VSCode is expected to read and apply when the developer is working on the files related to the project that are stored in the sub-folders within the project folder.

  • Add the below content to tsconfig.json (ref: https://stackoverflow.com/questions/31737677/vscode-is-it-possible-to-supress-experimental-decorator-warnings).
  • {
        "compilerOptions": {
            "experimentalDecorators": true,
            "allowJs": true
        }
    }
    
  • The second option, allowJs: true is important.

  • Shutdown (⌘+q) and restart Visual Studio Code.

There are several other options which can be set in the tsconfig.json that affect the behaviour of Visual Studio Code editor. You can read about them in the docs – https://code.visualstudio.com/docs – search for tsconfig.json.


References:

  1. Getting an error for experimental support for decorators with experimentalDecorators enabled #470
  2. –experimentalDecorators flag seemingly not accepted from tsconfig.json #10084
  3. experimentalDecorators Typescript warning always present #8069
  4. How to remove experimentalDecorators warning in VSCode
  5. VSCode: Is it possible to supress experimental decorator warnings

Increase the Key repeat rate in OS X Sierra

Settings on my Macbook Pro:

~ $ defaults read -g InitialKeyRepeat
68
~ $ defaults read -g KeyRepeat
60

The InitialKeyRepeat value represents the ‘Delay Until Repeat option’ in the ‘Keyboard Preferences’ (System Preferences => Keyboard). The KeyRepeat value signifies the value set by the ‘Key Repeat’ option in the ‘Keyboard Preferences’. Below is a screenshot that portrays these options for clarity.

Default key repeat settings in Macbook Pro

‘Key Repeat’ value signifies how quickly the characters repeat when a key is held down.

‘Delay Until Repeat’ option indicates how long to wait before the character is repeated when a key is held down.

To increase the key repeat rate, drag the sliders under ‘Key Repeat’ and ‘Delay Until Repeat’ options all the way to the Right.

Updated key repeat settings

This updates the values as:

~ $ defaults read -g InitialKeyRepeat
15
~ $ defaults read -g KeyRepeat
2

The value of 15 for ‘InitialKeyRepeat’ option indicates that the system waits for 225 milliseconds before repeating a character initially. The value of 2 for ‘KeyRepeat’ tells the system to wait for 30 milliseconds before repeating the character after the initial repetition.

You can also consider using a third party tool like Karabiner (https://pqrs.org/osx/karabiner/), that provides a more flexible way to set these options. Please note, as of Jun 2017, the tool does not support MacOS Sierra, yet.

If you would like to further increase the key repeat speed, you can do it through the command line:

~ $ defaults write -g InitialKeyRepeat -int 10
~ $ defaults write -g KeyRepeat -int 1

The value of 10 for InitialKeyRepeat implies a wait of 112.5 milliseconds before repeating the character for the first time and the value of 1 for KeyRepeat indicates a wait of 10 milliseconds for subsequent repetitions.


References:

  1. How to increase keyboard key repeat rate on OS X?
  2. Karabiner-Elements

How to skip tracking changes in a file while using git?

I was working on a Angular-Firebase project. I had stored the firebase configuration in a config file. I wanted git to recognize and index the initial version of the file with keys listed in it but not values. Which implies that I had to commit the initial version of the file but force git to ignore any future modifications.

The solution that I came across at stackoverflow servered my purpose.

Step 1: Create the config file. Lets call it, firebase.config.ts (I use TypeScript). And commit it.

$ git add firebase.config.ts
$ git commit -m "Default version of the firebase configuration." firebase.config.ts

Step 2: Inform git to skip tracking the changes in the file.

$ git update-index --skip-worktree firebase.config.ts

# Check if the file is marked to be ignored
$ git ls-files -v . | grep ^S

# To enable tracking changes in the file, use the below command:
$ git update-index --no-skip-worktree firebase.config.ts

Refer the Git update manual for additional details about the options.