36 thoughts on “Today I Learned (TIL)”

  1. react-router > V5 useHistory hook:
    If you have React >= 16.8 and functional components you can use the useHistory hook from react-router.

    import React from 'react';
    import { useHistory } from 'react-router-dom';

    const YourComponent = () => {
    const history = useHistory();

    const handleClick = () => {

    return (


    export default YourComponent;


  2. VSC PowerShell. After npm updating packages .ps1 cannot be loaded because running scripts is disabled on this system

    This is a powershell security policy, to fix it run the following

    PS C:\> Set-ExecutionPolicy RemoteSigned
    The stricter the policy, the more secure your system becomes.

    You can change RemoteSigned to other options like: Restricted, AllSigned, RemoteSigned, Unrestricted


  3. object key by variable
    You need to make the object first, then use [] to set it.

    var key = "happyCount";
    var obj = {};
    obj[key] = someValueArray;

    UPDATE 2018:

    If you’re able to use ES6 and Babel, you can use this new feature:

    [yourKeyVariable]: someValueArray,

  4. Allowing node.js applications to run on port 80
    in order to avoid this error, you can resolve the non-symlink executable with which node, as full example:

    sudo apt-get install libcap2-bin
    sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\``

    the “which” command shows the full path of shell commands.

  5. How to open Visual Studio Code from the command line on OSX?
    Tip: If you want to run VS Code from the terminal by simply typing ‘code’, VS Code has a command, Shell Command: Install ‘code’ command in PATH, to add ‘code’ to your $PATH variable list.

    After installation, launch VS Code. Now open the Command Palette (F1 or ⇧+⌘+P on Mac) and type shell command to find the Shell Command: Install ‘code’ command in PATH command.

    After executing the command, restart the terminal for the new $PATH value to take effect. You’ll be able to simply type ‘code .’ in any folder to start editing files in that folder.


  6. How to copy code from Visual Studio to MS Word with EVERY highlight exactly as it is?

    So I was looking for an answer to this and this is what i found. Go to Extensions (manager) -> look for: Productivity Power Tools -> install & restart VS. Now when i copy/paste from VS to Word, literally all syntax colors are being copied over 1:1. even the background color is matched.

    I use VS 2019 preview these days.


  7. I have never worked with firebase. However i’m 99% sure that your dictionary should be

    Dictionary <string, object > or Dictionary<string, System.Object>

    instead of

    Dictionary<string, Object> which actually is Dictionary<string, UnityEngine.Object>

    Keep in mind that the compiler will use classes from the namespaces you are “using”. There is no “Object” class in the global namespace. Since most Unity scripts have a using UnityEngine; at the top, “Object” will refer to UnityEngine.Object.

    The C# base class for every type (System.Object) has an alias name in the global namespace: object. Note the lower case “o”. There are several alias names for built-in fundamental types, like string (System.String), int (System.Int32), long (System.Int64), ...


  8. Functional programming:
    1. Keep data immutable
    2. Keep functions pure-accept at least one argument, return data or another function.
    3. Use recursion over looping.

Leave a Reply