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.

Enable web interface to manage printer settings in MacOS Sierra

I use a HP 915 All-in-One Inkjet printer. I like it because of the fact that buying a new cartridge costs almost same as the refilled cartridge. As a result, I always buy a new cartridge when the current ones run out of ink, minus the feeling of being taken for ride by the Printer companies (read: Why Is Printer Ink So Expensive? and All printer ink is more expensive than gold]

The printer settings dialog that can be opened via System Preferences -> Printers and Scanners -> Choose your printer in the list -> Options and Supplies is extremely simplified. This is good for a regular Mac user. But if you need to customize the print output, say, you would like to change the default presets, there is no way to achieve it via the Options and Supplies dialog. This is where enabling the web interface to manage printer settings comes into play.

Mac uses CUPS which is an acronym for Common Unix Printing System. In simpler terms, it’s the network printing service used by Mac. Ideally, it is utilized to setup and configure printers that are connected to the network. In our case, we will use it to configure the printer connected locally to our Mac.

Step 1: Open the terminal and enter the below command.

cupsctl WebInterface=yes

The above command may fail if you are not the root user. In that case, try executing:

sudo cupsctl WebInterface=yes

If you come across an error message that reads, cupsctl: Internal Server Error, you would have to follow the alternative method of enabling WebInterface as described in the Apple Support Forum, here: https://discussions.apple.com/thread/6485634?tstart=0. As listed on the support forum, the alternative is to edit cupsd.conf file located within the /private/../cups folder using a text editor and updating the line that starts with WebInterface no as WebInterface yes (if its not already yes).

Step 2: Open http://localhost:631/printers/ in your browser. You should be able to see the list of printers connected to your machine.

Step 3: After you have updated your printer settings, you can consider disabling the interface by executing:

cupsctl WebInterface=yes
# Or, sudo cupsctl WebInterface=yes

or, updating the cupsd.conf by replacing WebInterface yes as WebInterface no within it.


References:

Spotlight does not list newly installed applications on macOS Sierra

I decided to try the IntelliJ IDEA editor (https://www.jetbrains.com/idea/download/). After installing the editor, I realized that Spotlight did not list it even after several days.

While searching for a solution, it came to my notice that this is a common problem and can be fixed easily. There were several solutions listed on the Internet. The one that worked for me was to open System Preferences -> Spotlight -> Privacy  and add the volume Macintosh HD to the exclude list (volumes / directories that Spotlight will not index for search) and remove it immediately. This solution was listed in one of the threads related to Spotlight at the Apple Support Communities portal (https://discussions.apple.com/thread/2697313?tstart=0).

There were several other solutions that I did not try but found one of them worth mentioning:

Enable display of hidden files and folders in Mac

This article is note to myself. It lists the command to be executed to show hidden files and folder in Mac. As a practice, the names of the Hidden files and folders are prefixed with a period.

Step 1: Open the Terminal – type Cmd + Space followed by terminal in the search box and press return.

Step 2: Within the terminal window, enter the following command and press return.

defaults write com.apple.finder AppleShowAllFiles YES

If you would like to hide hiddens files and folders, type:

defaults write com.apple.finder AppleShowAllFiles NO

Step 3: Relaunch the Finder.

  • Hold the Option + Control keys and click on the Finder icon on the Dock.
  • Select Relaunch in the menu.

Find the version of the Linux distribution installed in your system

This post is a note to myself since I have come across the need of verifying the version of the Linux distribution installed on my system several times till date.

Method 1:

The standard technique I have been using till date to check the version of the Linux OS installed on my system was to execute: cat /etc/issue.

If you are using a customized version of the Linux based OS, the file, /etc/issue will probably display a custom message based on the OS distribution.

Method 2:

If you know that the Linux OS installed in your system is a variant of RHEL or Fedora, say CentOS, the command, cat /etc/redhat-release will provide the human readable release name of the installed OS followed by the version and the code name of the release.

If you are using other variants of the Linux OS, there is a high probability that the execution of the command, cat /etc/*-release may provide you with the necessary details.

Method 3:

If you are using a recent version of Linux distribution, the command: lsb_release -i -r will display the Distribution name (-i) and the Release number (-r).

On a side-note, if you are just looking for the version of the kernel and gcc that were used to build the release: cat /proc/version will provide the details.


References:
1. http://serverfault.com/questions/89654/what-version-of-rhel-am-i-using
2. http://serverfault.com/questions/188037/how-do-i-determine-what-version-of-red-hat-enterprise-linux-my-server-is-running
3. http://www.cyberciti.biz/faq/find-linux-distribution-name-version-number/
4. http://unix.stackexchange.com/questions/124667/how-to-know-which-linux-and-which-version-i-am-using