Skip to content

Instantly share code, notes, and snippets.

View ankittyagii's full-sized avatar
:octocat:
Hungry

Ankit Tyagi ankittyagii

:octocat:
Hungry
View GitHub Profile
@ankittyagii
ankittyagii / UnitConverters
Last active October 15, 2019 18:45
Xamarin Essentials
//UnitConverterPageViewModel
private string _kilometers;
public string Kilometers
{
get { return _kilometers; }
set
{
SetProperty(ref _kilometers, value);
1 . cd c:/program files/docker/docker
.\dockercli -Version
TO check the CLI vrsion
2. docker image ls - List out the images from docker host
3. docker container ls - list out the active container
4. docker system info
5. docker-compose --version
6. docker-machine --version
7. notary --version
8. docker container run -it ubuntu:latest /bin/bash
@ankittyagii
ankittyagii / gist:2f1b541ae88fc54bc1969afa1ba45e1b
Created December 27, 2019 14:12
How to enable Cleartext in Android
Solution 1. Open AndroidManifest file.
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:usesCleartextTraffic="true"
...>
...
</application>
@ankittyagii
ankittyagii / Common
Last active January 4, 2020 02:40
Cosmos DB SQL API Demo C# Code Snippets
public static class Common
{
public const string EndpointUrl = "https://<your-account>.documents.azure.com:443/";
public const string AuthorizationKey = "<your-account-key>";
public const string DatabaseId = "FamilyDatabase";
public const string ContainerId = "FamilyContainer";
public const string employeesPartitionKey = "/department";
@ankittyagii
ankittyagii / mycustomapicaller.http
Created January 12, 2020 07:29
Rest Client Demo
@baseUrl = https://jsonplaceholder.typicode.com/todos/1
GET {{baseUrl}}
Accept: application/json
@ankittyagii
ankittyagii / CSProjFile (ASP.NET Core)
Last active February 26, 2020 11:19
Prevent From Hotlinking in IIS/ASP.NET Framework/ASP.Net Core Application
<ItemGroup>
<None Update="hotlinkingURLRewrite.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
@ankittyagii
ankittyagii / startup.cs
Last active April 18, 2020 21:14
Add Migration In Different Assembly.
#if you want your migration in different assembly and your DbContext lies in different project, then you can use the strategy to maintain multiple sets of migrations
#As a example, you have ASP.Net Core MVC project Named - AspNetCoreDemo.Web and AspNetCoreDemo.Migrations library
#Open Startup File in "AspNetCoreDemo.Web" add the below code in ConfigureServices method
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<AppDBContext>(options =>
{
@ankittyagii
ankittyagii / Startup.cs
Last active April 18, 2020 21:25
Razor Runtine Compilation
#By default in asp.net core 3.0 razor views runtime compilation is disabled . See why and how we need to enable this razor runtime compilation
#After we enable the runtime compilation we need not to recompile the program again. By saving and refreshing the browser we can easily see the new changes.
#How to overcome from this problem.
#Solution - You need to install the nuget package i.e
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
@ankittyagii
ankittyagii / .Net Core WebApi
Last active April 28, 2022 19:24
.Net Coding Standard
S.No Description
1 ConfigureServices Method should be as lean as possible. Create an extension class with the static method. then just to call this extended method upon the IServiceCollection type
2 DAL should be created as a separate service. With DAL as a separate service we can register it inside the IOC (Inversion of Control) container.
3 The repository logic should always be based on interfaces
4 The controllers shouldn’t have any business logic inside it.
5 Actions should always be clean and simple. Actions should have IActionResult as a return type in most of the cases. That way we can use all the methods inside .NET Core which returns results and the status codes as well.
6 Handle errors globally as much as possible using built-in and ready to use middleware or custom middleware. Add that exception middleware in the Startup class by modifying the Configure method
7 Use ActionFilters to Remove Duplicated Code
8 Separate entities that communicate with the database from the entities that