Skip to content

Instantly share code, notes, and snippets.

View anuraj's full-sized avatar
🏠
Working from home

Anuraj anuraj

🏠
Working from home
View GitHub Profile
@anuraj
anuraj / winservice.iss
Created January 28, 2017 09:01
Innosetup script file for dotnet core windows service installation
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "dotnet core windows service"
#define MyAppVersion "1.5"
#define MyAppPublisher "dotnetthoughts"
#define MyAppURL "http://dotnetthoughts.net/"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
@anuraj
anuraj / CSSIsolationActionFilter.cs
Created March 1, 2022 01:54
CSS Isolation Action Filter for .NET Framework MVC projects
public class CSSIsolationActionFilterAttribute : ActionFilterAttribute
{
public CSSIsolationActionFilterAttribute()
{
}
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
ViewResult viewResult = filterContext.Result as ViewResult;
RazorView view = viewResult?.View as RazorView;
@anuraj
anuraj / feature-flags.json
Last active January 26, 2022 04:04
Feature Flags
{
"showSecondCTA": true
}
@anuraj
anuraj / Startup.cs
Created September 10, 2016 02:24
WebSocket middleware example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using WebApp2.Middlewares;
@anuraj
anuraj / MinimalAPIs.md
Created September 11, 2021 11:29 — forked from davidfowl/MinimalAPIs.md
Minimal APIs at a glance

Minimal APIs

WebApplication

Creating an application

var app = WebApplication.Create(args);

app.MapGet("/", () => "Hello World");
@anuraj
anuraj / index.js
Created April 23, 2021 12:41
index.js
'use strict';
const express = require('express');
// Constants
const PORT = 8095;
const HOST = '0.0.0.0';
// App
const app = express();
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="System.IO" #>
<#@ assembly name="System.Data" #>
<#@ assembly name="System.Configuration" #>
<#@ assembly name="Microsoft.SqlServer.ConnectionInfo" #>
<#@ assembly name="Microsoft.SqlServer.Smo" #>
<#@ assembly name="Microsoft.SqlServer.Management.Sdk.Sfc" #>
@anuraj
anuraj / function.csx
Created June 12, 2020 17:30
Azure Function
private static readonly AzureKeyCredential Credentials = new AzureKeyCredential("KEY");
private static readonly Uri Endpoint = new Uri("ENDPOINT");
private static readonly string SearchApiKey = "KEY";
private static readonly string BitlyKey = "KEY";
private static readonly string TwitterConsumerKey = "CONSUMERKEY";
private static readonly string TwitterConsumerSecret = "CONSUMERSECRET";
private static readonly string TwitterAccessToken = "ACCESSTOKEN";
private static readonly string TwitterAccessTokenSecret = "ACCESSTOKENSECRET";
private static readonly string[] searchTerms = new[] { "Application Technology", "Architecture",
"Artificial Intelligence", "Open Source", "SAAS", "Business Transformation",
@anuraj
anuraj / NewsSearch.cs
Created June 12, 2020 17:29
News Search using Bing News Search API
//Add reference of Microsoft.Azure.CognitiveServices.Search.NewsSearch Package
using Microsoft.Azure.CognitiveServices.Search.NewsSearch;
public static async Task<News> GetSearchResults(string searchTerm)
{
var searchClient = new NewsSearchClient(new ApiKeyServiceClientCredentials(SearchApiKey));
return await searchClient.News.SearchAsync(query: searchTerm, market: "en-us", count: 5);
}
@anuraj
anuraj / ExtractKeyPhrases.cs
Last active June 12, 2020 17:28
Extract Key Phrases using Text Analytics
//Add reference of Azure.AI.TextAnalytics
using Azure;
using Azure.AI.TextAnalytics;
using Microsoft.Azure.CognitiveServices.Search.NewsSearch.Models;
public static async Task<string> GetKeywords(string text)
{
var client = new TextAnalyticsClient(Endpoint, Credentials);
var response = await client.ExtractKeyPhrasesAsync(text);
var tags = new List<string>();