Skip to content

Instantly share code, notes, and snippets.

View amithegde's full-sized avatar
🎯
Focusing

Amit Hegde amithegde

🎯
Focusing
View GitHub Profile
@davidfowl
davidfowl / TimeHttpEvents.cs
Last active August 7, 2024 01:57
Using Yarp.Telemetry.Consumption to track outbound network events (this package isn't tied to YARP)
using System.Diagnostics;
using System.Net.Sockets;
using System.Security.Authentication;
using Yarp.Telemetry.Consumption;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddTelemetryConsumer<TelemetryConsumer>();
var app = builder.Build();
@leonardo-m
leonardo-m / gist:6e9315a57fe9caa893472c2935e9d589
Last active October 13, 2024 14:40
A selection of 101 LINQ Samples converted to Rust
// Port of the C# 101 LINQ Samples rewritten into Apple's Swift 3.
#![feature(ordering_chaining, step_by)]
fn main() {
// linq5: Where - Indexed
/*
//c#
public void Linq5()
{
@jehugaleahsa
jehugaleahsa / join.ps1
Last active September 11, 2024 21:37
PowerShell Script to Split Large Files
function join($path)
{
$files = Get-ChildItem -Path "$path.*.part" | Sort-Object -Property @{Expression={
$shortName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name)
$extension = [System.IO.Path]::GetExtension($shortName)
if ($extension -ne $null -and $extension -ne '')
{
$extension = $extension.Substring(1)
}
[System.Convert]::ToInt32($extension)
@rymoore99
rymoore99 / IEnumerableExtension.cs
Last active August 29, 2015 13:56
IEnumerable Paging Extension
// Usage: myCollection.Page(pageNumber, pageSize);
public static class IEnumerableExtension {
public static IEnumerable<T> Page<T>(this IList<T> source, int pageNumber, int pageSize)
{
return source.Skip((pageNumber - 1) * pageSize).Take(pageSize);
}
}
@j2jensen
j2jensen / BenchmarkTemplate.cs
Created November 10, 2010 00:22
Fill in the blanks to test the difference in performance between different actions.
void Main()
{
var actions = new[]
{
new TimedAction("first", () =>
{
// Insert logic here.
}),
new TimedAction("second", () =>
{