Skip to content

Instantly share code, notes, and snippets.

View dotnet22's full-sized avatar

Sukhdev dotnet22

  • Rachanaa Innovations
  • Ahmedabad, India
View GitHub Profile
@dotnet22
dotnet22 / tsup.config.ts
Created January 2, 2025 07:51 — forked from ixahmedxi/tsup.config.ts
tsup multi entrypoint
import fs from 'fs';
import path from 'path';
import { defineConfig } from 'tsup';
// INFO: This is the only place you need to update when adding new entry folders
const entryFolders = ['primitives', 'ui'];
function getAllFilesInDirectory(dirPath: string): string[] {
return fs.readdirSync(dirPath).reduce<string[]>((allFiles, file) => {
@dotnet22
dotnet22 / 0_Program.cs
Created November 22, 2024 07:29 — forked from mykeels/0_Program.cs
Code for extracting OpenAPI schema from ASP.NET Core projects
// Use a conditional, because You may not want to provide swagger documentation in public environments
if (_configuration.GetValue<bool>("SwaggerConfiguration:EnableSwagger"))
{
services.AddEndpointsApiExplorer();
services.AddSwaggerGen(options => {
options.AddCustomIds();
options.AddMetadata(typeof(Program));
options.SchemaFilter<NullableEnumSchemaFilter>();
options.SchemaFilter<RequiredPropertiesSchemaFilter>();
@dotnet22
dotnet22 / ModelBuilderExtensions.cs
Created September 5, 2024 09:26 — forked from haacked/ModelBuilderExtensions.cs
Example of applying an EF Core global query filter on all entity types that implement an interface
/*
Copyright Phil Haack
Licensed under the MIT license - https://github.com/haacked/CodeHaacks/blob/main/LICENSE.
*/
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
import { useQuery, useQueryClient, useMutation } from "@tanstack/react-query";
import axios from "axios";
export const useEntities = <T extends { id: string }>(
key: string,
url: string
) => {
const entities = useQuery<T[], Error>(
[key],
async ({ signal }): Promise<T[]> => {
@dotnet22
dotnet22 / AppendImageExtension.cs
Created August 30, 2021 17:50 — forked from ChuckSavage/AppendImageExtension.cs
C# Is file an image and get its type
// Includes a mini-program for checking and fixing files that have no extension
// Only checks for the most common types
// If you create a better version, please upload it here.
using System;
using System.Collections.Generic;
using System.IO;
namespace AppendJPG
{
@dotnet22
dotnet22 / delete-likes-from-twitter.md
Created April 7, 2021 12:10 — forked from aymericbeaumet/delete-likes-from-twitter.md
[Recipe] Delete all your likes/favorites from Twitter

Ever wanted to delete all your likes/favorites from Twitter but only found broken/expensive tools? You are in the right place.

  1. Go to: https://twitter.com/{username}/likes
  2. Open the console and run the following JavaScript code:
setInterval(() => {
  for (const d of document.querySelectorAll('div[data-testid="unlike"]')) {
    d.click()
 }
@dotnet22
dotnet22 / allDNS.md
Created December 11, 2020 05:18 — forked from TwistingTwists/allDNS.md
All Rau Dns Descriptions.
@dotnet22
dotnet22 / nginx.conf
Created October 31, 2020 07:52 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@dotnet22
dotnet22 / nginx-tuning.md
Created July 3, 2020 09:28 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@dotnet22
dotnet22 / AwsV4SignatureCalculator.cs
Created December 18, 2019 06:02 — forked from yvanin/AwsV4SignatureCalculator.cs
This C# code calculates a request signature using Version 4 signing process. It was developed for and tested on Amazon SQS requests, so it does not cover every scenario for the other services, e.g. multipart uploads are not supported. Nevertheless, it's simple and independent single class that can be easily embedded into other projects. .NET Fra…
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
namespace AwsV4SignatureCalculator