Skip to content

Instantly share code, notes, and snippets.

View anuraj's full-sized avatar

Anuraj anuraj

View GitHub Profile
@anuraj
anuraj / launch.json
Created January 1, 2018 13:59
Launching different browsers from VS Code
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
@anuraj
anuraj / inspectcode.xslt
Last active July 5, 2018 05:12 — forked from maartenba/inspectcode.xslt
R# InspectCode XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:key name="ISSUETYPES" match="/Report/Issues/Project/Issue" use="@TypeId"/>
<xsl:output method="html" indent="no"/>
<xsl:template match="/" name="TopLevelReport">
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" />
<style>
body {font-family: 'Open Sans', sans-serif;}
@anuraj
anuraj / UsersController.cs
Last active July 25, 2019 04:54
EF Core - FirstOrDefaultAsync throws Null Reference Exception - Code sample to reproduce the issue.
public class UsersController : Controller
{
private readonly DatabaseContext _databaseContext;
public UsersController(DatabaseContext databaseContext)
{
_databaseContext = databaseContext;
}
public async Task<ActionResult<User>> Get(int id)
{
apiVersion: apps/v1
kind: Deployment
metadata:
name: azure-vote-back
spec:
replicas: 1
selector:
matchLabels:
app: azure-vote-back
template:
@anuraj
anuraj / lighthouse-buildpipeline
Created January 6, 2020 04:54
Google Lighthouse Azure DevOps build pipeline
pool:
name: Azure Pipelines
demands: npm
steps:
- task: Npm@1
displayName: 'npm install'
inputs:
workingDir: '$(Build.SourcesDirectory)'
verbose: false
@anuraj
anuraj / lighthouse-json-to-junit-xml
Created January 6, 2020 05:04
Powershell script converts Lighthouse Json to JUnit XML
function Get-ObjectMembers {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True, ValueFromPipeline=$True)]
[PSCustomObject]$obj
)
$obj | Get-Member -MemberType NoteProperty | ForEach-Object {
$key = $_.Name
[PSCustomObject]@{Key = $key; Value = $obj."$key"}
}
@anuraj
anuraj / zoomqna.cs
Created June 5, 2020 10:33
QnA Maker Zoom Integration code.
var kbServiceUrl = "https://appservice.azurewebsites.net/qnamaker/knowledgebases/id/generateAnswer";
var kbAuthKey = "authkey";
var answer = string.Empty;
using (var httpClient = httpClientFactory.CreateClient())
{
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("EndpointKey", kbAuthKey);
var question = new JObject();
question["question"] = cmd;
var questionContent = new StringContent(question.ToString(), Encoding.UTF8, "application/json");
@anuraj
anuraj / CreateShortURL.cs
Last active June 12, 2020 17:26
Azure Function - AI + Tweets
//Add reference of BitlyAPI package
public static async Task<string> CreateShortURL(string url)
{
var bitly = new BitlyAPI.Bitly(BitlyKey);
var shortLink = await bitly.PostShortenLink(url);
return shortLink;
}
@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>();
@anuraj
anuraj / createtweet.cs
Created June 12, 2020 17:27
Create and Publish tweet.
//Add reference of Tweetinvi
using Tweetinvi;
using Tweetinvi.Models;
public static void CreateTweet(string text)
{
var credentials = new TwitterCredentials(TwitterConsumerKey,
TwitterConsumerSecret,
TwitterAccessToken,
TwitterAccessTokenSecret);