This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
document.addEventListener('DOMContentLoaded', function () { | |
const errorContainer = document.getElementById('error'); | |
const pdfViewerContainer = document.getElementById('pages-container'); | |
const loader = document.getElementById('loader'); | |
const pdfFileUrl = "sample-pdf-with-images.pdf"; | |
renderPdf( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Loaded via <script> tag, create shortcut to access PDF.js exports. | |
const pdfjsLib = window['pdfjs-dist/build/pdf']; | |
let pdfDoc = null; | |
let currentRenderingPage = 1; | |
const scale = 1.5; | |
const pagesContainer = document.getElementById('pages-container'); | |
const renderPage = (num, onPdfLoaded) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Simplest PDF viewer ever</title> | |
<link href="style.css" rel="stylesheet" /> | |
<script src="https://unpkg.com/pdfjs-dist@latest/build/pdf.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private (bool IsCritical, MonitoringData Data) ValueCritical( | |
MonitoringData[] monitoringData, | |
DateTime startingDate, | |
Metrics metric, | |
double threshold) | |
{ | |
foreach (var data in monitoringData | |
.Where(d => d.CollectionTime > startingDate) | |
.OrderByDescending(d => d.CollectionTime)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool alertShouldBeGenerated = boolli.EvaluateFuncOfBoolExpression( | |
rule.BooleanExpression, | |
namedBooleanFunctions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool alertShouldBeGenerated = boolli.EvaluateFuncOfBoolExpression( | |
rule.BooleanExpression, | |
namedBooleanFunctions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Alert> GenerateAlerts(MonitoringData[] monitoringData) | |
{ | |
var alerts = new List<Alert>(); | |
var boolli = new Evaluator(); | |
foreach (var rule in _alertGenerationRules) | |
{ | |
// I need object for String.Format | |
var lastValues = new Dictionary<Metrics, MonitoringData>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Rule() | |
{ | |
RuleName = "RAM full and CPU busy last minute", | |
BooleanExpression = $"{Metrics.CPUPercentage} and {Metrics.UsedRAMGigaBytes}", | |
ResultingAlertGravity = AlertGravity.Critical, | |
MessageFormat = "Attention! Last minute CPU ({0}%) and RAM ({1} GB) are very critical! (Last value collection time: {2})", | |
TimeFrameMinutes = 1, | |
DataEvaluationFunctionDescription = new DataEvaluationFunctionDescription[] | |
{ | |
new DataEvaluationFunctionDescription() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var boolli = new Evaluator(); | |
bool result = await boolli.EvaluateFuncOfBoolExpressionAsync( | |
"f3 and f4", | |
new NamedAsyncBooleanFunction[] | |
{ | |
new NamedAsyncBooleanFunction("f3", async () => { await Task.Delay(100); return true; }), | |
new NamedAsyncBooleanFunction("f4", async () => { await Task.Delay(100); return true; }), | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var boolli = new Evaluator(); | |
bool result = boolli.EvaluateFuncOfBoolExpression( | |
"f1 and f2", | |
new NamedBooleanFunction[] | |
{ | |
new NamedBooleanFunction("f1", () => true), | |
new NamedBooleanFunction("f2", () => false), | |
}); |
NewerOlder