Skip to main content

Posts

Showing posts from 2019

Create and Configure a User in MSSQL

This article will show you how to create and configure a user in MSSQL. Open SQL Server Management Studio (SSMS). Connect to SQL Server using your log in information. In the left-hand panel, expand  Security > Logins . Right click  Logins  and select  New Login  from the drop-down menu. Assign a Login name and select the authentication method and default database/language. Note:  Only Domains can use Windows Authentication. If you are using SQL authentication you will need to enter an initial password and choose the enforcement options for password policy and expiration as well as whether or not the user will need to change their password when they log in. In the left-hand panel, click  Server Roles  to assign any server roles you want this user to have, including  bulkadmin ,  dbcreator ,  public , and so on. In the left-hand panel, click  Securables  and then click  Search . The Ad...

Typescript - Self-Executing Anonymous Functions

/** * Self executing anonymous function using TS. */ (()=> { // Whatever is here will be executed as soon as the script is loaded. console . log ( 'executed' ) })(); I want a built a plugin that may work for Node.js, also for fron-tend as well. In that case you should compile your TypeScript in AMD and use an AMD loader on the frontend, like  http://requirejs.org/docs/start.html On the server side, you would need to use  requirejs  node package as well to load the file. Take a look at this:  http://requirejs.org/docs/node.html Basically there are two ways to compile TS to JS, using AMD, which is browser compliant, or using CommonJS, which is node.js compliant. Loading an AMD script in the browser or in the server needs to use an AMD compliant loader, and *requirejs** is one of them. (the most famous/used I'd say) Ref :  https://stackoverflow.com/questions/30274464/typescript-self-executing-anonymous-functions

TempData keep() vs peek()

When an object in a  TempDataDictionary  is read, it will be marked for deletion at the end of that request. That means if you put something on TempData like TempData [ "value" ] = "someValueForNextRequest" ; And on another request you access it, the value will be there but as soon as you read it, the value will be marked for deletion: //second request, read value and is marked for deletion object value = TempData [ "value" ]; //third request, value is not there as it was deleted at the end of the second request TempData [ "value" ] == null The  Peek  and  Keep  methods allow you to read the value without marking it for deletion. Say we get back to the first request where the value was saved to TempData. With  Peek  you get the value without marking it for deletion with a single call, see  msdn : //second request, PEEK value so it is not deleted at the end of the request object value = TempData . Peek ( "value"...

Adding Ctrl-Click “Go To Definition” support to Visual Studio 2015

So here's how I fixed this. First download Noah Richard's extension from:  https://visualstudiogallery.msdn.microsoft.com/4b286b9c-4dd5-416b-b143-e31d36dc622b Save the .vsix file somewhere on your computer Open the file with Winzip / Winrar or similar (it's just a disguised .zip file so you could change the extension to .zip) Open the extension.vsixmanifest file in a text editor Add the following lines inside the  <SupportedProducts>...</SupportedProducts>  section: <VisualStudio Version="14.0"> <Edition>Pro</Edition> </VisualStudio> Update the zip file with the modified file and change it back to a .vsix file. Double click the .vsix and install. Ref :  https://stackoverflow.com/questions/33301909/adding-ctrl-click-go-to-definition-support-to-visual-studio-2015 Visit -  https://marketplace.visualstudio.com/items?itemName=NoahRichards.GoToDefinition https://marketplace.visualstudio.com/items?ite...

How to increase timeout for your ASP.NET Application ?

A. executionTimeout attribute of httpRuntime element (web.config): ASP.NET will timeout the request, if it is not completed within “ executionTimeout ” duration value. And System.Web.HttpException: Request timed out exception will be thrown by ASP.NET Application. executionTimeout attribute of httpRuntime element (in the web.config) can be used to change the request timeout duration for ASP.NET Application. executionTimeout   value is specified in seconds. Default value is 110 seconds. <configuration> <system.web> <httpRuntime targetFramework= "4.5.1" executionTimeout= "500" /> </system.web> </configuration> B. timeout attribute of sessionState element (web.config): If the user remains idle for duration specified in  timeout attribute vaule of sessionState element (in web.config) , then his session will expire. timeout attribute of sessionState element (in the web.config) can be used to change session tim...

Override AccessTokenExpireTimeSpan - Session Expire too early

You have to set the expiration time in the  TokenEndPoint  method instead of  GrantResourceOwnerCredentials  method: public override Task TokenEndpoint(OAuthTokenEndpointContext context) { ... if (condition) { context.Properties.ExpiresUtc = DateTime.UtcNow.AddDays(14); } ... } Ref:  https://stackoverflow.com/questions/32120754/override-accesstokenexpiretimespan

SQL Server replace, remove all after certain character

Use LEFT combined with CHARINDEX: UPDATE MyTable SET MyText = LEFT ( MyText , CHARINDEX ( ';' , MyText ) - 1 ) WHERE CHARINDEX ( ';' , MyText ) > 0 Note that the WHERE clause skips updating rows in which there is no semicolon. Here is some code to verify the SQL above works: declare @ MyTable table ([ id ] int primary key clustered , MyText varchar ( 100 )) insert into @ MyTable ([ id ], MyText ) select 1 , 'some text; some more text' union all select 2 , 'text again; even more text' union all select 3 , 'text without a semicolon' union all select 4 , null -- test NULLs union all select 5 , '' -- test empty string union all select 6 , 'test 3 semicolons; second part; third part;' union all select 7 , ';' -- test semicolon by itself UPDATE @ MyTable SET MyText = LEFT ( MyText , CHARINDEX ( ';' , MyText ) - 1 ) WHERE CHARINDEX ( '...