53 thoughts on “Today I Learned (TIL)”

  1. First you have to add below dependency in your gradle file:
    implementation 'com.google.android.gms:play-services-ads:17.1.1'
    Then You have to add meta-data tag in your manifest that specifies your admob application id. So add below code to your manifest in application tag:

    android:value="your admob application id"

    and if you want to test ads in your app, you can use sample application id provided by google itself, which is as below:
    Now you can implement all types of ads by your own and first use test ad unit ID for testing purpose. It shows that your ads will be showed or not. Test ad unit Ids are as follows:

    For Banner Ad: ca-app-pub-3940256099942544/6300978111
    For Interstitial Ad: ca-app-pub-3940256099942544/1033173712
    For Native Ad: ca-app-pub-3940256099942544/2247696110
    For Rewarded Video Ad: ca-app-pub-3940256099942544/5224354917


  2. mongodump -d -o
    mongodump –db –out
    mongodump –host $HOST –port $PORT -u $USERNAME -p $PASSWORD -d $DB -o

    mongorestore –drop -d
    mongorestore –drop –db
    mongorestore –host $HOST –port $PORT -u $USERNAME -p $PASSWORD -d $DB

  3. IAP Offline Testing
    There are 4 reserved Product IDs defined by Google that can be used for offline testing. These IDs can be used to test for various user responses when an attempt is made to purchase the item. Your game does not have to be published to test with these IDs.

    android.test.purchased : Buying this item will cause a successful purchase response.
    android.test.canceled : Buying this item will act as if the user had canceled the purchase.
    android.test.refunded : Buying this item will act as if the purchase was refunded.
    android.test.item_unavailable : Buying this item will act as if this item was not added to the Google Developer Console for your game.

  4. 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;


  5. 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


  6. 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,

  7. 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.

  8. 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.


  9. 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.


  10. 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), ...


  11. 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.

  12. If it’s Ubuntu you’ll need to install the build-essential package:

    $ sudo apt-get install build-essential
    Then try to install the package again.

Leave a Reply