Skip to content

Instantly share code, notes, and snippets.

View priyankakundu's full-sized avatar

priyankakundu

View GitHub Profile
This file has been truncated, but you can view the full file.
{
"runtime": "Net50",
"defaultVariables": "",
"documentGenerator": {
"fromDocument": {
"json": "{\r\n \"x-generator\": \"NSwag v13.11.3.0 (NJsonSchema v10.4.4.0 (Newtonsoft.Json v12.0.0.0))\",\r\n \"openapi\": \"3.0.0\",\r\n \"info\": {\r\n \"title\": \"Resource Demand Main Web API\",\r\n \"description\": \"Resource Demand Main Web API\",\r\n \"version\": \"v1\"\r\n },\r\n \"servers\": [\r\n {\r\n \"url\": \"https://localhost:5001\"\r\n }\r\n ],\r\n \"paths\": {\r\n \"/Projects/DetailExport\": {\r\n \"get\": {\r\n \"tags\": [\r\n \"Projects\"\r\n ],\r\n \"operationId\": \"Projects_DetailExport\",\r\n \"parameters\": [\r\n {\r\n \"name\": \"Id\",\r\n \"in\": \"query\",\r\n \"schema\": {\r\n \"type\": \"string\",\r\n \"format\": \"guid\",\r\n \"nullable\": true\r\n },\r\n \"x-position\": 1\r\n },\r\n {\r\n
[FromQuery] attribute handles query parameters, i.e. key-value pairs coming after "?" in URI. [FromRoute] attribute handles
route parameters coming before "?" in URI, i.e. path parameters.
For example, if you configured route "orders/{id}", then "id" is your route parameter, and if some actual request is like
"orders/123?showHistory=true", then "showHistory" is your query parameter.
IEnumerable describes behavior, while List is an implementation of that behavior. When you use IEnumerable, you give the compiler a chance
to defer work until later, possibly optimizing along the way. If you use ToList() you force the compiler to reify the results right away.
Whenever I'm "stacking" LINQ expressions, I use IEnumerable, because by only specifying the behavior I give LINQ a chance to defer evaluation and possibly optimize the program. Remember how LINQ doesn't generate the SQL to query the database until you enumerate it.
i.e deffered execution
- Non-Generic collections - These are the collections that can hold elements of different data types. It holds all elements as object type.
So it includes overhead of type conversions.
- Generic collections - These are the collections that can hold data of same type and we can decide what type of data that collections can hold.
@priyankakundu
priyankakundu / gist:731de8fde00f19f8d74df9df014c97f8
Created March 22, 2022 11:19 — forked from tejpaldev/gist:4ceebdca16b1fb3a6049595b31509ae5
Check if MaxJsonDeserializerMembers values set
<add key="aspnet:MaxJsonDeserializerMembers" value="2147483647" />
Response.Write(new ScriptingJsonSerializationSection().MaxJsonLength);
int y = Nullable.Compare<DateTime>(DateTime.UtcNow, x);
if y=-1 means x is greater
if y=1 means x is lesser
if y=0 means equal
select f.*,
count(*) over (
partition by title, uk_release_date
) ct
from films f;
select *
from (
select f.*,
count(*) over (
Pivot C# Array or DataTable: Convert a Column To a Row with LINQ
var data = new[] {
new { Product = "Product 1", Year = 2009, Sales = 1212 },
new { Product = "Product 2", Year = 2009, Sales = 522 },
new { Product = "Product 1", Year = 2010, Sales = 1337 },
new { Product = "Product 2", Year = 2011, Sales = 711 },
new { Product = "Product 2", Year = 2012, Sales = 2245 },
new { Product = "Product 3", Year = 2012, Sales = 1000 }
};
1.Create a cookie before writing the stream to Response.
2.Use JavaScript timer to check whether the value of cookie is set to true
3.If downloaded cookie is true, display a message that file download is successful and erase cookie
<script>
var timer;
function getCookie(name) {
var re = new RegExp(name + "=([^;]+)");
var value = re.exec(document.cookie);
return (value != null) ? unescape(value[1]) : null;
@priyankakundu
priyankakundu / test
Created March 22, 2022 11:17 — forked from tejpaldev/test
testng
"scripts": {
"ng": "ng",
"start": "ng serve --open",
"start-hmr": "ng serve --configuration hmr --source-map=false --hmr-warning=false",
"start-hmr-sourcemaps": "ng serve --configuration hmr --source-map=true --hmr-warning=false",
"build": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --aot --deploy-url=dist/ --output-hashing all --watch",
"build-watch": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --deploy-url=dist/ --output-hashing all --watch",
"build-stats": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --dev --stats-json",
"build-prod": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --prod --aot --deploy-url=dist/",
"build-ci": "ng build --prod --aot --output-path=prod/dist --deploy-url=dist/",
@priyankakundu
priyankakundu / PasswordCryptoServiceProvider.cs
Created March 22, 2022 08:44 — forked from tejpaldev/PasswordCryptoServiceProvider.cs
C# password-based encryption helper class.
using System;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
public class PasswordCryptoServiceProvider : IDisposable
{
protected const string Base58Chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
private readonly SymmetricAlgorithm algorithm;