Posts

Incognito mode in chrome

Image
The least we can to do when browsing using chrome is use incognito mode. So here is way to always open chrome in incognito mode use this argument for the application shortcut. --incognito Open the properties of application shortcut and change as below Here is what incognito mode does and what most people think is just the opposite. So incognito just makes sure that data like the history and the cookie are deleted when you close that window. It does not hide what you are browsing from the ISP or the software's that is running in your OS like the key logger or the antivirus etc., Happy browsing! Somewhat incognito 👽😜

Protecting sensitive data using Secret Manager in .Net Core

Image
Accidentally pushing sensitive data stored in application config into source controls!!! Thankfully this happens to many not only you 😜. It feels good when you have company doing mistakes or anything else.
So here is how make sure this does not happen again. There are multiple ways to protect, the one we will learn now is using Secret Manager tool in #dotnetcore. All we have to do use dotnet user-secrets this command. Before using it remove the sensitive value of the property you are trying to hide. In my case it is "TwilioAuthToken":"" in appsettings.json file. Now in the terminal run this below command, dotnet add package Microsoft.Extensions.SecretManager.Tools We have the necessary tools required to run the commands on user-secrets. Lets create a key value vault for our project in *.csproj file like this <PropertyGroup>
<UserSecretsId>LocalKeyVault</UserSecretsId>
</PropertyGroup> Once you have a vault create we can now add/remove key value…

Containerize an Application

Image
Here is how we containerize an application in this example in this example I have chosen a dotnetcore application. Photo by Samuel Zeller on Unsplash
Add a Dockerfile which will be used to create an image for your application. Below is the sample.
FROM microsoft/dotnet:2.2-sdk AS build this basically says create our application based on this Microsoft image. Navigate the shell to your application folder and then using docker run create an image for your application. docker build -t sampleapp. you can see your image using docker images. Finally that you have your image ready we can create as many container we need using this. There are two options to create a container out of the image you just created either use this below command docker run -d -p 8080:80 --name sampleapp appcontainername or use the docker-compose.yml file from the app folder. Which consists the exact same information as yml file. Then use docker-compose up in the application folder from the shell. now you must be able to…

Launch .Net Core with VSCode for starters

Image
To use VSCode for .net core you would need Omnisharp extension so that we can debug our application just like as in Visual Studio.

--Photo by SpaceX on Unsplash

Using the dotnet new command we create a web and an API project
dotnet new webapp appname.web
dotnet new webapi appname.api

Create a solution so that it wraps all the projects in one place
dotnet new sln appname
dotnet sln add appname.web appname.api

After building the Web and the API projects we need to create the launch.json which VScode refers to build and debug the application. For a complete reference on doing these projects consider this great resource.
You can always use VSCode terminal to run these above commands as well, also note you can open multiple terminals the same VSCode instance like this.

Setup the launch.json by clicking on add configuration and select .Net core web app. we will need to add two such configurations one for web and another for web api. For web api you need to launch the browser on running the app…

How to Run two .net core apps with debugging On using Visual Studio Code ?

Image
When developing a web application we separate our application with *.web being initial server-side application and  *.api application which will help us fetch/update data for client-side operations and avoid page reloads.


Photo by Vincent van Zalinge on Unsplash

Here is .NET Core application I was working on which had a similar kind of ask, and I wanted to use VSCode to debug my application.

This is how we do it, first, we need to create a solution so that we keep both the API and Web project in one place

dotnet new sln -n appname
dotnet sln add src/appname/appname.web.csproj
dotnet sln add src/appname/apname.api.csproj

Open "launch.json" and Click on add configuration and add then select

.NET Core Launch (web) 

No go ahead and rename to web or web-api, also add a development URL with a different than web configs the "env" property

"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "https://localhost:5001"…

Setting up docker with Hyper-V

Image
Docker is just amazing with flexibility we get to not worry about setting up the environments for our application.


--Photo by Ilse Orsel on Unsplash

Download docker for windows.

So with Windows we can use hyper-V and get containers spawned in minutes.

Here is how we do it.

Make sure you have Hyper-V enabled on windows if not go to turn on windows feature and turn this feature On. Once this is done with restart.

Use Hyper-V Manager for Windows to create a Virtual Switch



Now use the following commands to create the docker containers

docker-machine create -d hyperv --hyperv-virtual-switch "Primary Virtual Switch" default
this will create a VM, you can see this with Hyper-V manager or

docker-machine ls
once the machine is created you need to set some of the machine details in Environments Variables

to list the variables use

docker-machine env default
Now set the env vairables as below using bash

eval $("C:\Users\arjun_shetty\bin\docker-machine.exe" env default --shell …

Load Testing an nodejs API

Image
Load Testing is quite a stream of its own all I did was smoothly sailed on top of it. With not much time in hand, the only weapon of choice was Jmeter, Well quite brilliant a tool!!



We had to test a facebook chat-bot built with nodejs. This app is a webhook for FB to push the chat messages down to our app.

This is how we achieved it

On Windows:
Download JMeter from here.

Now run the jmeter.bat, this will open up a java GUI where you can easily configure the endpoints you want to test.
Add a thread group and set the number of users/thread you want to spawn to test your APIAdd an Http request sampler Fill in the intuitive fields like URL, request body, Method, etc.,For setting up HTTP headers like content-type or authorization fields right click on HTTP request and add config element HTTP header manager, then the key values as you mayTo see the results on all the requests that will spawn create add listener View results tree. You are ready to click on play button an check out the View r…