Thursday, 6 April 2023

Video on Demand (VOD) and Video Streaming – How it works!

Video on demand (VOD) and video streaming are two popular methods for delivering video content over the internet. While VOD allows users to download and watch videos on their own time, video streaming enables real-time playback without the need for a download.

Technically, video streaming involves sending compressed video data in small chunks, which are decoded and played by the user’s device in real-time. The most common streaming protocol used today is HTTP Live Streaming (HLS), which segments video into small files called “chunks”.

When a user requests to watch a video, the server divides the video into chunks and sends the data to the user’s device. The device’s media player downloads each chunk and decodes it for playback, while simultaneously downloading the next chunk in the sequence.

HLS files used in video streaming typically include:

  1. Manifest file (M3U8): This is an index file that contains a list of video segments (chunks) that the player requests from the server. It tells the player how to download and play the video.
  2. Video chunks (TS files): These are small video files that contain a portion of the video content. The player downloads these files in sequential order, and decodes them to play the video.
  3. Encryption keys (key files): These are small files that contain the encryption keys used to secure the video content.
  4. Subtitle files: These are text files that contain captions or subtitles for the video.

When a user watches a video on a browser, the media player in the browser sends an HTTP request to the server for the manifest file. The server then sends the manifest file, which the media player reads to determine the location and sequence of the video chunks. The media player then requests the video chunks, which are downloaded and decoded in real-time for playback.

In summary, video streaming involves the segmentation of video into small files called “chunks”, which are sent to the user’s device for real-time playback. The HLS protocol is the most commonly used streaming protocol, and it uses files such as the manifest file, video chunks, encryption keys, and subtitle files to deliver video content over the internet.

How many Requests can a Server handle?

Determining the maximum requests a server can handle is a complex task that depends on various factors, such as the server hardware, network infrastructure, server software configuration, and the nature of the requests. Here are some general steps to estimate the maximum requests a server can take:

  1. Check the server specifications: Look at the server specifications such as CPU, RAM, disk space, and network bandwidth. These specifications can give you an idea of the server’s capacity to handle requests.
  2. Check the server logs: Analyze the server logs to determine the number of requests it receives in a given period. This can help you understand the server’s current traffic load and whether it is approaching its limit.
  3. Conduct load testing: Use load testing tools to simulate heavy traffic and measure the server’s response time and resource usage. Gradually increase the number of requests until you notice performance degradation or errors.
  4. Analyze resource usage: Monitor the server’s resource usage during the load test to identify any bottlenecks, such as CPU or memory usage. This can help you determine the maximum number of requests the server can handle before it becomes overwhelmed.
  5. Optimize server software: Adjust server software settings, such as caching, threading, and connection limits, to improve performance and increase the maximum number of requests the server can handle.

Keep in mind that the maximum requests a server can handle is not a fixed number and can change over time as traffic patterns and server configurations change. Therefore, it’s important to regularly monitor and optimize your server’s performance to ensure it can handle your expected traffic.

How to give view access to a new user in Mandrill

 Follow the below steps:

  1. Log in to your Mandrill account.
  2. Click on the “Settings” option from the main menu.
  3. In the “Settings” menu, click on the “Users” option.
  4. Click on the “Add a User” button.
  5. Enter the email address of the new user in the “Email” field.
  6. Select the “Viewer” role from the “Role” dropdown menu.
  7. Choose the permissions you want to grant to the new user under “Permissions.”
  8. Click the “Add User” button to save your changes.

Once you have completed these steps, the new user will receive an email inviting them to create an account and log in to Mandrill. They will then be able to access the account with view-only permissions according to the permissions you granted in step 7.

Should vspscc file be checked into TFS?

Yes, the .vspscc file should be checked in to Visual Studio and TFS (Team Foundation Server). The .vspscc file is a source control file that helps manage the source code in Visual Studio projects. It contains information about the files in the project, such as their source control status, and helps maintain consistency between the local copy of the project and the version stored in the source control repository.

When you check in the .vspscc file, it ensures that the correct source control information is maintained and that the project can be properly managed in TFS. If the .vspscc file is not checked in, it can lead to issues such as incorrect source control status or inconsistencies between the local copy and the version in TFS.

Therefore, it is recommended that you always check in the .vspscc file along with the rest of the project files to ensure proper management of your Visual Studio project in TFS.

Best MongoDB Clients

There are several MongoDB clients available that are user-friendly and easy to use. Here are some of the popular ones:

  1. MongoDB Compass: It is an official graphical user interface (GUI) for MongoDB. It provides a visually appealing interface to manage, explore and query data, create indexes, and more.
  2. Robo 3T: It is a free and open-source MongoDB GUI client. It offers a simple and intuitive interface, supports a wide range of MongoDB features, and is available for Windows, Mac, and Linux.
  3. Studio 3T: It is a paid MongoDB GUI client that offers a rich set of features, including SQL support, data visualization, and a powerful aggregation pipeline editor.
  4. NoSQLBooster for MongoDB: It is a powerful and user-friendly MongoDB GUI client that supports SQL query, import/export data, and auto-completion for queries.
  5. mViewer Pro: It is a lightweight and easy-to-use MongoDB GUI client that allows you to view and edit data in a tree-like structure.

Overall, MongoDB Compass and Robo 3T are among the most user-friendly and easy-to-use MongoDB clients, and they are also available for free.

Block emails from an email in Microsoft Office 365

 You can create a mail flow rule to block the sender’s email address in the new Exchange admin center. Here are the steps:

  1. Sign in to the new Exchange admin center at https://admin.exchange.microsoft.com/
  2. Go to Mail flow > Rules
  3. Click + to create a new rule
  4. In the New rule page that opens, enter a name for the rule
  5. Under Apply this rule if, select The sender…
  6. Select is this person and enter the email address of the sender you want to block
  7. Under Do the following, select Block the message
  8. Click Save to save the new rule

Thursday, 6 September 2018

Windows Service - Add Dependency - After Service is Installed

I have a Windows service, that has a dependency on MSMQ (Message Queuing). So I want my service to start only after MSMQ service is started completely. Else my service will run into some anomalies.

A way to do it is to add the dependency in the service install, but this dependency came later on. So now I need to add the dependency post install.

You can do it via an elevated comand prompt using sc command. Follow the below syntax:

sc config [service name] depend= <dependencies by="" forward="" separated="" slash="">
</dependencies>

Note 1 : Retain the space after the depend=. This is important.
Note 2 : depend= will overwrite and not append to existing dependencies list. So if you have multiple dependencies, remember to add all the required dependencies while trying to add new one as well.

Example 1:
Below command will add a dependency of service Service2 to service Service1. That means Service1 will start only after Service2 starts. Also Service1 will stop if Service2 is stopped.
sc config Service1 depend= Service2
Example 2:
Command for dependency on multiple services is added below. Here Service1 will not start until Service2, Service3, Service4 are started. Also if any of the dependent services are stopped Service1 will stop.
sc config Service1 depend= Service2/Service3/Service4
Example 3:
Remove all dependencies:
sc config Service1 depend= /
Example 4:
List all dependencies:
sc qc Service1

Sunday, 15 January 2017

SQL Server - List all Triggers in a Database

You can use the below query to list ass Triggers in your database.
It lists the Trigger name, table name and the type of trigger (update / delete / insert etc).

SELECT 
     sysobjects.name AS trigger_name 
    ,USER_NAME(sysobjects.uid) AS trigger_owner 
    ,s.name AS table_schema 
    ,OBJECT_NAME(parent_obj) AS table_name 
    ,OBJECTPROPERTY( id, 'ExecIsUpdateTrigger') AS isupdate 
    ,OBJECTPROPERTY( id, 'ExecIsDeleteTrigger') AS isdelete 
    ,OBJECTPROPERTY( id, 'ExecIsInsertTrigger') AS isinsert 
    ,OBJECTPROPERTY( id, 'ExecIsAfterTrigger') AS isafter 
    ,OBJECTPROPERTY( id, 'ExecIsInsteadOfTrigger') AS isinsteadof 
    ,OBJECTPROPERTY(id, 'ExecIsTriggerDisabled') AS [disabled] 
FROM sysobjects 

INNER JOIN sysusers 
    ON sysobjects.uid = sysusers.uid 

INNER JOIN sys.tables t 
    ON sysobjects.parent_obj = t.object_id 

INNER JOIN sys.schemas s 
    ON t.schema_id = s.schema_id 

WHERE sysobjects.type = 'TR' 

Sunday, 11 December 2016

C# - Update Querystring Values in a Url

We will look into a solution to update querystring values in a Url.

using System.Web;

// url has the complete url with querystring 
// ex: http://bing.com?abc=1xyz=20
var uriBuilder = new UriBuilder(url);

var query = HttpUtility.ParseQueryString(uriBuilder.Query);

// Existing Querystring parameter xyz value will be updated from 20 to 10
query["xyz"] = "10";

// As QS Parameter hello doesn't existed, it will be added.
query["hello"] = "world";

// Set updated querystring to the Url.
uriBuilder.Query = query.ToString();

// New Url: http://bing.com?abc=1xyz=10&hello=world
Response.Redirect(uriBuilder.ToString()); 

Remember to import namespace "System.Web"

Thursday, 8 December 2016

ASP.NET MVC C# - Redirect to External Website from Controller Action Method

Refer the below code snippet for redirection from ASP.NET MVC Controller to an external website.
The MVC Controller method "Redirect()", is used for redirection from MVC Controller.

public ActionResult Index()
{
    return Redirect("http://www.google.com");
}

Redirect() method can be used for redirecting to an internal url as well.
Find the sample code below:
public ActionResult Index()
{
    return Redirect("/Customer/List");
}

Monday, 24 October 2016

SQL - While Loop Syntax

Below is the WHILE LOOP Syntax in SQL

DECLARE @cnt INT = 1;

WHILE @cnt BETWEEN 1 AND 20
BEGIN

PRINT @cnt;
SET @cnt = @cnt+1;

END

SQL Doesn't have For Loop, instead you have to use While loop.

SQL - For Loop Syntax

SQL doesn't have For Loop, instead you have to use While loop.
The syntax is as below.


DECLARE @cnt INT = 1;

WHILE @cnt BETWEEN 1 AND 20
BEGIN

PRINT @cnt;
SET @cnt = @cnt+1;

END


Thursday, 18 August 2016

SQL Server - Get DB Object Names, Count

SELECT sobjects.name
FROM sysobjects sobjects
WHERE sobjects.xtype = 'U'

The above example lists all the tables in the database.
You can modify the query to access other details about the db objects.
Also the same can be used to count the number of objects (tables / stored procedures) in the database.

Below are the reference to the other XTYPE values corresponding to each objects.

-- AF: Aggregate function (CLR)
-- C: CHECK constraint
-- D: Default or DEFAULT constraint
-- F: FOREIGN KEY constraint
-- L: Log
-- FN: Scalar function
-- FS: Assembly (CLR) scalar-function
-- FT: Assembly (CLR) table-valued function
-- IF: In-lined table-function
-- IT: Internal table
-- P: Stored procedure
-- PC: Assembly (CLR) stored-procedure
-- PK: PRIMARY KEY constraint (type is K)
-- RF: Replication filter stored procedure
-- S: System table
-- SN: Synonym
-- SQ: Service queue
-- TA: Assembly (CLR) DML trigger
-- TF: Table function
-- TR: SQL DML Trigger
-- TT: Table type
-- U: User table
-- UQ: UNIQUE constraint (type is K)
-- V: View
-- X: Extended stored procedure

Thursday, 21 July 2016

Windows 2012 - Install IIS on Windows Server 2012 R2

Installing and configuring IIS on Windows 2012 R2 is well explained in the below article with step by step screenshots.
Below is the link to the article:

Wednesday, 20 July 2016

XSL - If Else condition Choose When Otherwise

In XSL, there is no If - Else construct. Only If is present.

If your requirement is stricly If - Else, instead use the Choose When Otherwise construct as below:

<xsl:choose>
 <xsl:when test="$a > $b">
  <h2> A is greater than B </h2>
 </xsl:when>
 <xsl:otherwise>
  <h2> B is greater than A </h2>
 </xsl:otherwise>
</xsl:choose>

In the above example, a ($a) and b ($b), are variables.

Tuesday, 19 July 2016

XSL - Check if item is contained in a list

Use the below sample if you want to check if an item is contained in a list.
This sample is using XSL and XPATH with XML input.
In the below sample:
<!-- .xsl file -->

<!-- List of items to be checked against -->
<xsl:variable name="students" select="'Jon Tom Ana Ben'" />

<!-- Item to be checked if contained in list -->
<xsl:variable name="classTopper" select="'Ana'" />

<!-- Alternately the item can be dynamically taken from the xml input file as below -->
<!-- <xsl:variable name="classTopper" select="/root/@topper" /> -->

<!-- Check if class topper is in the students list -->
<xsl:if test="
  contains(
    concat(' ', $students, ' '),
    concat(' ', $classTopper, ' ')
  )
">
  <xsl:value-of select="concat('Student ', $classTopper, ' is in the students list.')" />
</xsl:if>

Note: Here space is used as separator in the list. You can replace with something else like a pipe "|". In that case, the concat in contains() will be like:
concat ('|', $list, '|') ...

Thursday, 14 July 2016

JavaScript - Replace Comma with New Line

Use JavaScript String functions "split" and "join":
var formattedString = yourString.split(",").join("\n")
If you'd like the newlines to be HTML line breaks replace "\n" with "<br />"

Alternate method using "replace" function.
yourString.replace(/,/g, '\n');

Monday, 11 April 2016

SQL - Insert Multiple Rows in a Single Query

Below code snippets can be used to insert multiple rows in a Single SQL Query Statement.
This will be faster than using multiple Insert statements.

INSERT INTO MyTable ( Column1, Column2 ) 
VALUES
  ( Value1, Value2 ), 
  ( Value1, Value2 );

-- Ex:

INSERT INTO tblPerson (First,Last) 
VALUES 
  ('Fred','Smith'),
  ('John','Smith'),
  ('Michael','Smith'),
  ('Robert','Smith');

-- If data is from another table
INSERT INTO table1 ( col1, col2, col3, col4 )
SELECT  table2.column1, table2.column2, 8, 'some string etc.'
FROM    table2
WHERE   table2.ID = 7;

Thursday, 17 March 2016

C# - String to Stream & Stream to String

Following code can be used to convert Stream to String and Stream to String using C#

Tuesday, 8 March 2016

ASP.NET MVC - WebGrid Column Width

Its easy to set the individual column width for ASP.NET MVC WebGrid. You can apply a CSS Style Class to the column. Find a sample below.

As in the sample above, you can apply multiple classes as well for the same column.