How to Add a Container in Google Tag Manager

Add a Container in Google Tag Manager

  1. Open Google Tag Manager and login. You will see the the Accounts screen with a list of all existing GTM containers.

2. To create/add a new container, click the three dots on the right – next to the settings icon as below

3. Click on Create Container and you will see the below screen

Note: In order to Create a Container, you need to have permission for it. Please ask the account admin, if you don’t have it

4. Add the container name, e.g. techiespice.com and select the Target Platform, e.g. Web. Click Create and your container is ready.

5. Once you click Create, you will see the below screen with all the container settings (Tags, Variables, Triggers, etc.) along with the GoogleTagManagerID (marked in red) on the right.

6. Click the GoogleTagManagerID and you will see the popup with GTM script that you need to add to your site.

Rebuild examine index programmatically

Rebuild examine index

You can rebuild the examine index programmatically by using the following code –

ExamineManager.Instance.IndexProviderCollection["InternalIndexer"].RebuildIndex();
               

Combine one or more generic lists in C#

Combine one or more lists in C#

One or more generic lists can be combined or merged using zip() method in C#.

Below is an example of combining 4 lists by creating an extension method.

public static IEnumerable<TResult> ZipFour<T1, T2, T3, T4, TResult>(
            this IEnumerable<T1> source,
            IEnumerable<T2> second,
            IEnumerable<T3> third,
            IEnumerable<T4> fourth,
            Func<T1, T2, T3, T4, TResult> func)
        {
            using (var e1 = source.GetEnumerator())
            using (var e2 = second.GetEnumerator())
            using (var e3 = third.GetEnumerator())
            using (var e4 = fourth.GetEnumerator())
            {
                while (e1.MoveNext() && e2.MoveNext() && e3.MoveNext() && e4.MoveNext())
                    yield return func(e1.Current, e2.Current, e3.Current, e4.Current);
            }
        }

Usage

list1.ZipFour(list2, list3, list4, (a, b, c, d) => new { A = a, B = b, C = c, D = d });

Generate a hex encoded HMAC-SHA256 hash using Crypto in Nodejs

How to generate an encoded hash in nodejs using crypto

import { Service } from './service';
import crypto from 'crypto';

export class TestService extends Service {
    private _secretKey: string;

    constructor() {
        this._secretKey = '1234567890';
		this._userId = '123';
    }

    /**
     * Get Hex encoded hash of secret key
     */
    private GetHashKey(): string {
        return crypto
            .createHmac('sha256', this._secretKey)
            .update(this._getUserString(this._userId))
            .digest('hex');
    }
}

Restore SQL database from .bak file stored in AWS S3 bucket

A Sql Database can be restored using .bak file

A Sql Database can be restored using .bak file

The below query can be used to restore database using a .bak file stored in AWS S3 bucket

exec msdb.dbo.rds_restore_database

-- replace name with the database name

@restore_db_name='<name>', 

--Replace backup s3 path with the actual path. 
--Eg. prod-backups/DLProdDB-12-07-19
--In this, prod-backups is the bucket name and DLProdDB-12-07-19 is the .bak --file name

@s3_arn_to_restore_from='arn:aws:s3:::{backup s3 path}'


To check the status of the restore, use the following query –

exec msdb.dbo.rds_task_status @db_name='<name>'

For more info, click here