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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract BubbleSort { | |
function sort(uint[] memory array) public pure returns (uint[] memory) { | |
bool swapped; | |
for (uint i = 1; i < array.length; i++) { | |
swapped = false; |
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
using System.Drawing; | |
using System.Drawing.Drawing2D; | |
using System.Drawing.Imaging; | |
using System.IO; | |
public static class ImageUtil | |
{ | |
public static Image Resize(this Image image, int width, int height) | |
{ | |
var destRect = new Rectangle(0, 0, width, height); |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using SharpX.Extensions; | |
static class EnumerableExtensions | |
{ | |
public static IEnumerable<IEnumerable<T>> Partition<T, TKey>(this IEnumerable<T> source, Func<T, TKey> selector) | |
{ | |
var result = new List<IEnumerable<T>>(); |
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
// requires Microsoft.IdentityModel.Clients.ActiveDirectory 5.29 | |
// Microsoft.Azure.Management.ResourceManager 3.15.1-preview | |
using System; | |
using System.Collections.Generic; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.Azure.Management.ResourceManager; | |
using Microsoft.Azure.Management.ResourceManager.Models; |
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
// based on: https://gist.github.com/FrankHu-MSFT/b6750185b19fd4ada4ba36b099985813 | |
// can removes \r to fit in a single log line when using ILogger | |
using System.IO; | |
using Newtonsoft.Json; | |
static class JsonUtil | |
{ | |
public static string Prettify(string json, bool stripLineFeed = false) | |
{ | |
using var stringReader = new StringReader(json); |
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
using System; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Azure.WebJobs; | |
using Microsoft.Azure.WebJobs.Extensions.Http; | |
using Microsoft.Extensions.Logging; | |
namespace HealthTest2 | |
{ |
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
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Polly.Contrib.Simmy; | |
using Polly.Contrib.Simmy.Outcomes; | |
using Microsoft.Extensions.Diagnostics.HealthChecks; | |
using CSharpx; | |
sealed class ChaosHealthCheck : IHealthCheck | |
{ |
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
@echo off | |
setlocal enabledelayedexpansion | |
::Batch script to compare a file SHA256 checksum to a given one. | |
::Usage: checksum [FILE] [VALUE] | |
set filepath=%1 | |
set checksum=%2 | |
set idx=0 |
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
$aiAppId = '00000000-0000-0000-0000-000000000000' | |
$aiApiKey = 'ehzgdrES4kBJNCuRUzcBfkuka5CGWkAr4hyhJ6y3' | |
$result = Invoke-RestMethod -Uri "https://api.applicationinsights.io/v1/apps/$aiAppId/query" ` | |
-Method Post -UseBasicParsing ` | |
-Headers @{ | |
'x-api-key' = $aiApiKey | |
'content-type' = 'application/json' | |
} ` | |
-Body '{"query": "traces | where timestamp <= ago(1m) | limit 10"}' |
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
// inspired by https://www.youtube.com/watch?v=RWyZkNzvC-c&t=553s | |
// $ dotnet fsi chaos3.fsx | |
// latency test | |
// 0.490776 | |
open System | |
open System.Threading | |
let chaosAsync (name:string) (shouldChaosAsync:unit -> Async<bool>) (chaosAsync:unit -> Async<unit>) = | |
fun (serviceAsync:unit -> Async<'t>) -> | |
async { |
NewerOlder