tag:blogger.com,1999:blog-74364534722585716202024-03-14T01:32:08.609-07:00Skate through code..Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.comBlogger81125tag:blogger.com,1999:blog-7436453472258571620.post-90821633025840653492023-04-06T23:49:00.002-07:002023-04-06T23:49:10.534-07:00Video on Demand (VOD) and Video Streaming – How it works!<p><span style="background-color: white; color: #334455; font-family: Roboto, sans-serif; font-size: 16px;">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.</span></p><p style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.5; margin: 0px 0px 1.2em;">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”.</p><p style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.5; margin: 0px 0px 1.2em;">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.</p><p style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.5; margin: 0px 0px 1.2em;">HLS files used in video streaming typically include:</p><ol style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; margin: 0.2em 0px 1em;"><li style="box-sizing: border-box;">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.</li><li style="box-sizing: border-box;">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.</li><li style="box-sizing: border-box;">Encryption keys (key files): These are small files that contain the encryption keys used to secure the video content.</li><li style="box-sizing: border-box;">Subtitle files: These are text files that contain captions or subtitles for the video.</li></ol><p style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.5; margin: 0px 0px 1.2em;">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.</p><p style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.5; margin: 0px 0px 1.2em;">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.</p>Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-467832918178117112023-04-06T23:48:00.007-07:002023-04-06T23:48:43.181-07:00How many Requests can a Server handle?<p><span style="background-color: white; color: #334455; font-family: Roboto, sans-serif; font-size: 16px;">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:</span></p><ol style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; margin: 0.2em 0px 1em;"><li style="box-sizing: border-box;">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.</li><li style="box-sizing: border-box;">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.</li><li style="box-sizing: border-box;">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.</li><li style="box-sizing: border-box;">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.</li><li style="box-sizing: border-box;">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.</li></ol><p style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.5; margin: 0px 0px 1.2em;">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.</p>Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-2350905508053450802023-04-06T23:48:00.003-07:002023-04-06T23:48:17.406-07:00How to give view access to a new user in Mandrill<p> <span style="background-color: white; color: #334455; font-family: Roboto, sans-serif; font-size: 16px;">Follow the below steps:</span></p><ol style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; margin: 0.2em 0px 1em;"><li style="box-sizing: border-box;">Log in to your Mandrill account.</li><li style="box-sizing: border-box;">Click on the “Settings” option from the main menu.</li><li style="box-sizing: border-box;">In the “Settings” menu, click on the “Users” option.</li><li style="box-sizing: border-box;">Click on the “Add a User” button.</li><li style="box-sizing: border-box;">Enter the email address of the new user in the “Email” field.</li><li style="box-sizing: border-box;">Select the “Viewer” role from the “Role” dropdown menu.</li><li style="box-sizing: border-box;">Choose the permissions you want to grant to the new user under “Permissions.”</li><li style="box-sizing: border-box;">Click the “Add User” button to save your changes.</li></ol><p style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.5; margin: 0px 0px 1.2em;">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.</p>Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-77601056423556357432023-04-06T23:47:00.008-07:002023-04-06T23:47:56.180-07:00Should vspscc file be checked into TFS?<p><span style="background-color: white; color: #334455; font-family: Roboto, sans-serif; font-size: 16px;">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.</span></p><p style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.5; margin: 0px 0px 1.2em;">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.</p><p style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.5; margin: 0px 0px 1.2em;">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.</p>Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-54700373135207578162023-04-06T23:47:00.003-07:002023-04-06T23:47:16.143-07:00Best MongoDB Clients<p><span style="background-color: white; color: #334455; font-family: Roboto, sans-serif; font-size: 16px;">There are several MongoDB clients available that are user-friendly and easy to use. Here are some of the popular ones:</span></p><ol style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; margin: 0.2em 0px 1em;"><li style="box-sizing: border-box;"><strong style="box-sizing: border-box;">MongoDB Compass</strong>: 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.</li><li style="box-sizing: border-box;"><strong style="box-sizing: border-box;">Robo 3T</strong>: 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.</li><li style="box-sizing: border-box;"><strong style="box-sizing: border-box;">Studio 3T</strong>: 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.</li><li style="box-sizing: border-box;"><strong style="box-sizing: border-box;">NoSQLBooster for MongoDB</strong>: It is a powerful and user-friendly MongoDB GUI client that supports SQL query, import/export data, and auto-completion for queries.</li><li style="box-sizing: border-box;"><strong style="box-sizing: border-box;">mViewer Pro</strong>: It is a lightweight and easy-to-use MongoDB GUI client that allows you to view and edit data in a tree-like structure.</li></ol><p style="background-color: white; box-sizing: border-box; color: #334455; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.5; margin: 0px 0px 1.2em;">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.</p>Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-1924209866399988182023-04-06T23:46:00.003-07:002023-04-06T23:46:33.994-07:00Block emails from an email in Microsoft Office 365<p> <span style="background-color: rgba(255, 255, 255, 0.6); color: #111111; font-family: -apple-system, Roboto, SegoeUI, "Segoe UI", "Helvetica Neue", Helvetica, "Microsoft YaHei", "Meiryo UI", Meiryo, "Arial Unicode MS", sans-serif; font-size: 16px;">You can create a mail flow rule to block the sender’s email address in the new Exchange admin center. Here are the steps:</span></p><ol style="background-color: rgba(255, 255, 255, 0.6); color: #111111; display: flex; flex-direction: column; font-family: -apple-system, Roboto, SegoeUI, "Segoe UI", "Helvetica Neue", Helvetica, "Microsoft YaHei", "Meiryo UI", Meiryo, "Arial Unicode MS", sans-serif; font-size: 16px; gap: 10px; margin: 0px; padding-left: 24px;"><li>Sign in to the new Exchange admin center at https://admin.exchange.microsoft.com/</li><li>Go to <strong>Mail flow > Rules</strong></li><li>Click <strong>+</strong> to create a new rule</li><li>In the <strong>New rule</strong> page that opens, enter a name for the rule</li><li>Under <strong>Apply this rule if</strong>, select <strong>The sender…</strong></li><li>Select <strong>is this person</strong> and enter the email address of the sender you want to block</li><li>Under <strong>Do the following</strong>, select <strong>Block the message</strong></li><li>Click <strong>Save</strong> to save the new rule</li></ol>Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-37466533239727721162018-09-06T05:18:00.007-07:002018-09-06T05:20:59.299-07:00Windows Service - Add Dependency - After Service is InstalledI 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.<br />
<br />
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.<br />
<br />
You can do it via an elevated comand prompt using sc command. Follow the below syntax:<br />
<br />
<pre class="brush: xml">sc config [service name] depend= <dependencies by="" forward="" separated="" slash="">
</dependencies></pre>
<br />
Note 1 : Retain the <b>space </b>after the <b>depend=</b>. This is important.<br />
Note 2 : <b>depend= </b>will <b>overwrite </b>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.<br />
<br />
<b>Example 1:</b><br />
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.<br />
<pre class="brush: xml">sc config Service1 depend= Service2</pre>
<b>Example 2:</b><br />
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.<br />
<pre class="brush: xml">sc config Service1 depend= Service2/Service3/Service4</pre>
<b>Example 3:</b><br />
Remove all dependencies:<br />
<pre class="brush: xml">sc config Service1 depend= /</pre>
<b>Example 4:</b><br />
List all dependencies:<br />
<pre class="brush: xml">sc qc Service1</pre>
<br />Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-6775722787689953352017-01-15T21:52:00.003-08:002017-01-15T21:54:04.730-08:00SQL Server - List all Triggers in a DatabaseYou can use the below query to list ass Triggers in your database.<br />
It lists the Trigger name, table name and the type of trigger (update / delete / insert etc).<br />
<br />
<pre class="brush: sql">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'
</pre>
Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com3tag:blogger.com,1999:blog-7436453472258571620.post-80361698996821303122016-12-11T02:54:00.002-08:002016-12-11T03:09:46.294-08:00C# - Update Querystring Values in a UrlWe will look into a solution to update querystring values in a Url.<br />
<br />
<pre class="brush: csharp">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());
</pre>
<br />
Remember to import namespace "System.Web"Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-89036434506674470512016-12-08T23:50:00.001-08:002016-12-08T23:50:11.530-08:00ASP.NET MVC C# - Redirect to External Website from Controller Action MethodRefer the below code snippet for redirection from ASP.NET MVC Controller to an external website.<br />
The MVC Controller method "<b>Redirect()</b>", is used for redirection from MVC Controller.<br />
<br />
<pre class="brush: csharp">public ActionResult Index()
{
return Redirect("http://www.google.com");
}
</pre>
<br />
Redirect() method can be used for redirecting to an internal url as well.<br />
Find the sample code below:<br />
<pre class="brush: csharp">public ActionResult Index()
{
return Redirect("/Customer/List");
}
</pre>
Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com2tag:blogger.com,1999:blog-7436453472258571620.post-84555276706357311232016-10-24T23:36:00.004-07:002016-10-24T23:39:46.603-07:00SQL - While Loop SyntaxBelow is the WHILE LOOP Syntax in SQL<br />
<br />
<pre class="brush: sql">DECLARE @cnt INT = 1;
WHILE @cnt BETWEEN 1 AND 20
BEGIN
PRINT @cnt;
SET @cnt = @cnt+1;
END
</pre>
<br />
SQL Doesn't have For Loop, instead you have to use While loop.Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com1tag:blogger.com,1999:blog-7436453472258571620.post-28412171878485255992016-10-24T23:36:00.003-07:002016-10-24T23:39:59.487-07:00SQL - For Loop SyntaxSQL doesn't have For Loop, instead you have to use While loop.<br />
The syntax is as below.<br />
<br />
<pre class="brush: sql">
DECLARE @cnt INT = 1;
WHILE @cnt BETWEEN 1 AND 20
BEGIN
PRINT @cnt;
SET @cnt = @cnt+1;
END
</pre>
<br />Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-52471443454536737002016-08-18T04:09:00.002-07:002016-08-18T04:09:46.746-07:00SQL Server - Get DB Object Names, Count<pre class="brush: sql">SELECT sobjects.name
FROM sysobjects sobjects
WHERE sobjects.xtype = 'U'
</pre>
<br />
The above example lists all the tables in the database.<br />
You can modify the query to access other details about the db objects.<br />
Also the same can be used to count the number of objects (tables / stored procedures) in the database.<br />
<br />
Below are the reference to the other XTYPE values corresponding to each objects.<br />
<br />
-- AF: Aggregate function (CLR)<br />
-- C: CHECK constraint<br />
-- D: Default or DEFAULT constraint<br />
-- F: FOREIGN KEY constraint<br />
-- L: Log<br />
-- FN: Scalar function<br />
-- FS: Assembly (CLR) scalar-function<br />
-- FT: Assembly (CLR) table-valued function<br />
-- IF: In-lined table-function<br />
-- IT: Internal table<br />
-- P: Stored procedure<br />
-- PC: Assembly (CLR) stored-procedure<br />
-- PK: PRIMARY KEY constraint (type is K)<br />
-- RF: Replication filter stored procedure<br />
-- S: System table<br />
-- SN: Synonym<br />
-- SQ: Service queue<br />
-- TA: Assembly (CLR) DML trigger<br />
-- TF: Table function<br />
-- TR: SQL DML Trigger<br />
-- TT: Table type<br />
-- U: User table<br />
-- UQ: UNIQUE constraint (type is K)<br />
-- V: View<br />
-- X: Extended stored procedureHabeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-55099128066964528602016-07-21T05:41:00.000-07:002016-07-21T05:41:29.295-07:00Windows 2012 - Install IIS on Windows Server 2012 R2Installing and configuring IIS on Windows 2012 R2 is well explained in the below article with step by step screenshots.<div>
Below is the link to the article:</div>
<div>
<a href="http://thesolving.com/server-room/how-to-install-and-configure-iis-on-windows-server-2012-r2/">http://thesolving.com/server-room/how-to-install-and-configure-iis-on-windows-server-2012-r2/</a></div>
Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-6933523376711052262016-07-20T00:36:00.000-07:002016-07-20T00:37:20.327-07:00XSL - If Else condition Choose When OtherwiseIn XSL, there is no <b>If - Else</b> construct. Only If is present.<br />
<br />
<div>
If your requirement is stricly If - Else, instead use the <b>Choose When Otherwise</b> construct as below:</div>
<br />
<pre class="brush: xml"><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>
</pre>
<br />
In the above example, a ($a) and b ($b), are variables.Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-6942858554558272282016-07-19T23:13:00.001-07:002016-07-19T23:29:16.445-07:00XSL - Check if item is contained in a listUse the below sample if you want to check if an item is contained in a list.<br />
This sample is using XSL and XPATH with XML input.<br />
In the below sample:
<br />
<pre class="brush: xml"><!-- .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>
</pre>
<br />
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:
<br />
<pre class="brush: xml">concat ('|', $list, '|') ...</pre>
Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-63299859130832555462016-07-14T06:35:00.002-07:002016-07-14T06:54:05.938-07:00JavaScript - Replace Comma with New LineUse JavaScript String functions "<a href="http://www.w3schools.com/jsref/jsref_split.asp" target="_blank">split</a>" and "<a href="http://www.w3schools.com/jsref/jsref_join.asp" target="_blank">join</a>":
<br />
<pre class="brush: javascript">var formattedString = yourString.split(",").join("\n")
</pre>
If you'd like the newlines to be HTML line breaks replace "\n" with "<br />"<br /><br />
Alternate method using "<a href="http://www.w3schools.com/jsref/jsref_replace.asp" target="_blank">replace</a>" function.
<br />
<pre class="brush: javascript">yourString.replace(/,/g, '\n');
</pre>
Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com2tag:blogger.com,1999:blog-7436453472258571620.post-4015461167617865182016-04-11T23:14:00.000-07:002016-04-11T23:19:57.072-07:00SQL - Insert Multiple Rows in a Single QueryBelow code snippets can be used to insert multiple rows in a Single SQL Query Statement.<br />
This will be faster than using multiple Insert statements.<br />
<br />
<pre class="brush: sql">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;
</pre>Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-87457527587105739082016-03-17T00:19:00.002-07:002016-03-17T00:20:50.916-07:00C# - String to Stream & Stream to StringFollowing code can be used to convert Stream to String and Stream to String using C#<br />
<br />
<script src="https://gist.github.com/habeebmatrix/7d7e6893b9399bd79334.js"></script>Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-87626669534309650972016-03-08T12:00:00.002-08:002016-03-08T12:00:26.425-08:00ASP.NET MVC - WebGrid Column WidthIts 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.<br />
<br />
<script src="https://gist.github.com/habeebmatrix/a60ae30e1fe807fe0189.js"></script>
As in the sample above, you can apply multiple classes as well for the same column.Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com1tag:blogger.com,1999:blog-7436453472258571620.post-71150787917431214452016-02-12T06:33:00.001-08:002016-02-12T07:04:21.721-08:00HTML / ASP.NET / Javascript - 301 RedirectThere are multiple ways to implement a 301 Redirect on a webpage.<br />
Below are methods to do redirection as soon as the page gets the visit using HTML Meta tag, ASP.NET and Javascript.<br />
The most preferred way is ASP.NET than HTML Meta tag and Javascript as it is the most compatible option.<br />
<br />
<script src="https://gist.github.com/habeebmatrix/64466b0d9a3a50cd81fc.js"></script>
The above sample will redirect user to http://yahoo.com as soon as he reaches this page.Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com1tag:blogger.com,1999:blog-7436453472258571620.post-18891060143956836162016-01-11T04:26:00.002-08:002016-01-11T04:31:31.401-08:00ASP.NET MVC - Configure Multiple Roles for Controller<div>
Using ASP.NET Identity you can easily set access to Controllers based on Roles.<br />
You can use the "Authorize" for this.</div>
<div>
<br /></div>
<div>
Setting access to single Role:</div>
<div>
<pre class="brush: csharp">[Authorize(Roles="Admin")]</pre>
</div>
<div>
<br /></div>
<div>
Setting access to single Role:</div>
<div>
<pre class="brush: csharp">[Authorize(Roles="Admin, User")]</pre>
</div>
<div>
<br /></div>
<div>
Eg:<br />
<pre class="brush: csharp">[Authorize(Roles = "SuperAdmin", "Admin")]
public ActionResult Register()
{
return View();
}
</pre>
<br />
Its that simple. Happy coding... :)</div>
Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-3277672283595305602015-12-17T22:06:00.003-08:002015-12-17T22:07:06.270-08:00Windows - Easiest way to install Telnet ClientSometimes its confusing on Windows from version to version, how to enable TELNET.<br />
The easiest was to install Telnet Client is from the command line.<br />
<br />
Steps:<br />
<ol>
<li>Open command prompt. (Windows Key + R, to bring up the Run window -> Type cmd in the run window -> Click Ok</li>
<li>In the Command Prompt window type the following command:</li>
<pre class="brush: csharp"> pkgmgr /iu:"TelnetClient"</pre>
</ol>
If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.<br />
<br />
When the command prompt appears again, the installation is complete.Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-12551551732525242112015-12-06T21:56:00.001-08:002015-12-06T21:56:17.714-08:00Windows - How to add Programs to StartUpHere is an easy to follow article to how to add programs to Windows System Startup.<br />
<a href="http://www.howtogeek.com/208224/how-to-add-programs-files-and-folders-to-system-startup-in-windows-8.1/">http://www.howtogeek.com/208224/how-to-add-programs-files-and-folders-to-system-startup-in-windows-8.1/</a>Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com0tag:blogger.com,1999:blog-7436453472258571620.post-52317561910967331932015-11-18T22:33:00.004-08:002015-11-18T22:33:35.157-08:00C# - Easiest CSV parser built in .NET FrameworkToday it came to my surprise to know that there is a built in CSV parser in the .NET Framework library. Throughout the years, I have written many CSV parsers myself; but if I knew about this hidden parser, I might not have written any by myself.<br />
Its hidden inside "<b>Microsoft.VisualBasic</b>" namespace.<br />
<br />
Below is a sample usage of the class and methods to read a file "Person.csv".<br />
In the sample, the line commenting character is "#"; the delimiting character is ",".<br />
The class exposes property to configure delimiting character (comma in our sample) and comment token (# in our sample).<br />
Any field which are enclosed within double quotes will escape delimiting characters and double quotes within the data field. It beautifully handles with by just setting the HasFieldsEnclosedInQuotes property to true.<br />
<br />
<pre class="brush: csharp">using Microsoft.VisualBasic.FileIO;
var path = @"C:\Person.csv"; // Habeeb, "Dubai Media City, Dubai"
using (TextFieldParser csvParser = new TextFieldParser(path))
{
csvParser.CommentTokens = new string[] { "#" };
csvParser.SetDelimiters(new string[] { "," });
csvParser.HasFieldsEnclosedInQuotes = true;
// Skip the row with the column names
csvParser.ReadLine();
while (!csvParser.EndOfData)
{
// Read current line fields, pointer moves to the next line.
string[] fields = csvParser.ReadFields();
string Name = fields[0];
string Address = fields[1];
}
}
</pre>
<br />
The parser has many more options. It can read a complete line as a single string. It can even read the remaining file content as a single string as well if needed in any case.<br />
<br />
I will definitely rely on this parser rather than writing my own again.Habeebhttp://www.blogger.com/profile/12146084943042720362noreply@blogger.com16