Skip to content

Instantly share code, notes, and snippets.

View krishnaanaril's full-sized avatar
🎯
Focusing

Krishna Mohan krishnaanaril

🎯
Focusing
View GitHub Profile
@krishnaanaril
krishnaanaril / audio-caption.html
Created March 5, 2023 11:24
POC for displaying audio with captions and subtitles
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Podcast</title>
</head>
<script src="https://cdn.tailwindcss.com"></script>
@krishnaanaril
krishnaanaril / file-download-from-fetch.js
Created March 1, 2023 05:18
Download response.data as a file, through Blob()
// Reference: https://gist.github.com/davalapar/d0a5ba7cce4bc599f54800da22926da2
export function downloadFile(data, filename, mime) {
// It is necessary to create a new blob object with mime-type explicitly set
// otherwise only Chrome works like it should
const blob = new Blob([data], {type: mime || 'application/octet-stream'});
if (typeof window.navigator.msSaveBlob !== 'undefined') {
// IE doesn't allow using a blob object directly as link href.
// Workaround for "HTML7007: One or more blob URLs were
// revoked by closing the blob for which they were created.
@krishnaanaril
krishnaanaril / Screenshot.cs
Created March 24, 2021 17:20
Snippet for generating image from a html element using puppeteer-sharp.
var t = Task.Run(async () =>
{
_ = await new BrowserFetcher().DownloadAsync("848005");
var url = "file:///C:/KrishnaMohan/Learning/tailwind/tailwind-npm/banner/banner.html";
var outputFile = ".\\somepage02.png";
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Headless = true,
DefaultViewport =
{
@krishnaanaril
krishnaanaril / test-repetition.ps1
Last active June 22, 2020 12:31
Powershell script to repeat the testing certain number of times. This is to find the errors caused by the numbers generated in random/inputs generated in random.
$count = 0
do {
$count = $count + 1
Write-Host "Testing: "+$count
$result = dotnet test .\Sample.csproj --filter "FullyQualifiedName=Test_Namespace.Test_Name" --nologo --no-build
} while(($result.ExitCode -ne 0) -and ($count -lt 50))
param (
[Parameter(Mandatory=$true)]
[string]$goodCommit = $( Read-Host "Good commit hash, please" ),
[Parameter(Mandatory=$true)]
[string]$badCommit = $( Read-Host "Bad commit hash, please" ),
[Parameter(Mandatory=$true)]
[string]$testProjectPath = $( Read-Host "Test project path, please" )
)
Write-Host $goodCommit $badCommit $testProjectPath
try
var video = document.createElement("video");
var canvasElement = document.getElementById("canvas");
var canvas = canvasElement.getContext("2d");
var loadingMessage = document.getElementById("loadingMessage");
var outputContainer = document.getElementById("output");
var outputMessage = document.getElementById("outputMessage");
var outputData = document.getElementById("outputData");
function drawLine(begin, end, color) {
canvas.beginPath();
@krishnaanaril
krishnaanaril / CoreTest.ps1
Created July 5, 2019 04:42
Powershell script for running dotnet-core unit tests and generate report.
param(
[Parameter(Mandatory=$true)]
[string]$testProjectPath,
[Parameter(Mandatory=$true)]
[string]$testSettingsPath,
[Parameter(Mandatory=$true)]
[string]$testResultsFolder
)
<#
@krishnaanaril
krishnaanaril / DotnetTest.ps1
Created July 5, 2019 04:32
Dotnet core test using .runsettings file
dotnet test <Path to .csproj file> --settings:<Path to .runsettings file>
@krishnaanaril
krishnaanaril / reportgenerator.ps1
Created July 4, 2019 13:58
Generate reports from *.coveragexml file
dotnet <UserProfile>\.nuget\packages\reportgenerator\<version>\tools\netcoreapp2.1\ReportGenerator.dll "-reports:<Coveragexml file path>" "-targetdir:<path to coverage report>"
<#
Eg: dotnet C:\Users\krishnamohan\.nuget\packages\reportgenerator\4.1.10\tools\netcoreapp2.1\ReportGenerator.dll "-reports:d:\MyTestOutput.coveragexml" "-targetdir:d:\coveragereport"
#>
@krishnaanaril
krishnaanaril / analyze.ps1
Last active July 4, 2019 13:53
Generate .coveragexml from .coverage file
<UserProfile>\.nuget\packages\microsoft.codecoverage\<version>\build\netstandard1.0\CodeCoverage\CodeCoverage.exe analyze /output:<xml file name with Path>.coveragexml <path to coverage file>
# Eg: C:\Users\krishnamohan\.nuget\packages\microsoft.codecoverage\15.9.0\build\netstandard1.0\CodeCoverage\CodeCoverage.exe analyze /output:d:\MyTestOutput.coveragexml d:\SomeName.coverage