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
#!/bin/bash | |
# from https://blogs.msdn.microsoft.com/powershell/2017/02/01/installing-latest-powershell-core-6-0-release-on-linux-just-got-easier/ | |
# Import the public repository GPG keys | |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - | |
# Register the Microsoft Ubuntu repository | |
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list | |
# Update apt-get |
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
/// <summary> | |
/// Used for getting DateTime.Now(), time is changeable for unit testing | |
/// </summary> | |
public static class SystemTime | |
{ | |
/// <summary> Normally this is a pass-through to DateTime.Now, but it can be overridden with SetDateTime( .. ) for testing or debugging. | |
/// </summary> | |
public static Func<DateTime> Now = () => DateTime.Now; | |
/// <summary> Set time to return when SystemTime.Now() is called. |
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
#!/usr/bin/env bash | |
# ---------------------------------------------------------------------------------- | |
# Script for checking the temperature reported by the ambient temperature sensor, | |
# and if deemed to high send the raw IPMI command to enable dynamic fan control. | |
# | |
# Requires ipmitool – apt-get install ipmitool | |
# Tested on Ubuntu 17.04 | |
# ---------------------------------------------------------------------------------- |
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 static class ListExtentions | |
{ | |
public static IEnumerable Cartesian(this IEnumerable<IEnumerable> items) | |
{ | |
var slots = items | |
// initialize enumerators | |
.Select(x => x.GetEnumerator()) | |
// get only those that could start in case there is an empty collection | |
.Where(x => x.MoveNext()) | |
.ToArray(); |
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
string stringFromSQL = "0x6100730064006600"; | |
List<byte> byteList = new List<byte>(); | |
string hexPart = stringFromSQL.Substring(2); | |
for (int i = 0; i < hexPart.Length / 2; i++) | |
{ | |
string hexNumber = hexPart.Substring(i * 2, 2); | |
byteList.Add((byte)Convert.ToInt32(hexNumber, 16)); | |
} |
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
//Returns time taken for execution of synchronous code | |
var syncTime = Metricity.Timings.Time(() => | |
{ | |
SyncMethod(); | |
}); | |
//Returns time taken for execution of asynchronous code | |
var asyncTime = Metricity.Timings.Time(async () => | |
{ | |
await ASyncMethod(); |
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
static MetricsCollector _collector; | |
_collector = new MetricsCollector(new BosunOptions(ex => Handle(ex)) | |
{ | |
MetricsNamePrefix = "TestApp.", | |
BosunUrl = new System.Uri("http://192.168.1.5:8070"), | |
PropertyToTagName = NameTransformers.CamelToLowerSnakeCase, | |
ThrowOnPostFail = true, | |
DefaultTags = new Dictionary<string, string>{ {"host", NameTransformers.Sanitize(Environment.MachineName.ToLower())}, | |
{ "client", "home" }, } |
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
_timer = _collector.CreateMetric<EventGauge>("GetWeather", "time taken", "measures time taken to get weather from api"); |
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
await Time(async () => | |
{ | |
await GetWeather(); | |
}, _timer); |
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 static async Task Time(Func<Task> action, EventGauge gauge) | |
{ | |
Stopwatch stopwatch = new Stopwatch(); | |
stopwatch.Start(); | |
await action.Invoke(); | |
stopwatch.Stop(); | |
gauge.Record(stopwatch.Elapsed.TotalMilliseconds, DateTime.Now); | |
} |
OlderNewer