Skip to content

Instantly share code, notes, and snippets.

View alvinashcraft's full-sized avatar

Alvin Ashcraft alvinashcraft

View GitHub Profile
@LanceMcCarthy
LanceMcCarthy / Example_A.MauiProgram.cs
Last active August 30, 2022 05:40
MAUI Window Position and Size (WinUI3 and MacCatalyst)
// ******** WinUI3 Window management ******** //
using Microsoft.Maui.LifecycleEvents;
#if WINDOWS
using Microsoft.UI;
using Microsoft.UI.Windowing;
using Windows.Graphics;
#endif
namespace MyApp.Maui
@beufordy3k
beufordy3k / EnumerableExtensions.cs
Created January 22, 2016 19:31
Enumerable extension methods that utilize the LambdaComparer
public static class EnumerableExtensions
{
public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> enumerable, Func<TSource, TSource, bool> comparer)
{
return enumerable.Distinct(new LambdaComparer<TSource>(comparer));
}
public static IEnumerable<TSource> Except<TSource>(this IEnumerable<TSource> enumerable, IEnumerable<TSource> comparison, Func<TSource, TSource, bool> comparer)
{
return enumerable.Except(comparison, new LambdaComparer<TSource>(comparer));
@beufordy3k
beufordy3k / LambdaComparer.cs
Created January 22, 2016 19:30
Use a lambda for comparison as an IEqualityComparer<T>
public class LambdaComparer<T> : IEqualityComparer<T>
{
private readonly Func<T, T, bool> _lambdaComparer;
private readonly Func<T, int> _lambdaHash;
public LambdaComparer(Func<T, T, bool> lambdaComparer) :
this(lambdaComparer, o => 0)
{
}

String interpolation

var x = 1;

// same as string.Format("A {0} B", x) 
var y1 = $"A {x} B"; // y == "A 1 B"

// $@ for multiline
var y2 = $@"A
@DanDiplo
DanDiplo / JS-LINQ.js
Last active October 14, 2025 22:02
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// First: This version using older JavaScript notation for universal browser support (scroll down for ES6 version):
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
@mbcrump
mbcrump / MVP2013
Last active December 28, 2015 14:49
MVP Summit 2013
Michael Crump
@mbcrump
michael.crump@telerik.com
-------------
All Source Code (WPF, WP8, Win 8)
http://bit.ly/HTwKWD
RadControl Bits Required
WPF/SL
@erichexter
erichexter / download.ps1
Last active December 18, 2015 02:18
Download the Microsoft Build 2013 videos - Just the Developer Videos
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
$rss = (new-object net.webclient)
#Set the username for windows auth proxy
#$rss.proxy.credentials=[system.net.credentialcache]::defaultnetworkcredentials
#http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/rss/mp4high/?sort=sequential&direction=desc&term=&r=Developer+Tools+%26+Application+Lifecycle+Management&r=Windows+Azure+Application+Development&y=Breakout&Media=true#fbid=FDnmapgI5Hf
#http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/RSS/mp4high
#http://channel9.msdn.com/Events/Build/2013/RSS/mp4high#theSessions
#http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/rss/mp4high/?sort=sequential&direction=desc&term=&r=Developer+Tools+%26+Application+Lifecycle+Management&r=Windows+Azure+Application+Development&y=Breakout&Media=true#fbid=FDnmapgI5Hf
$a = ([xml]$rss.downloadstring("http://channel9.msdn.com/Events/Build/2013/RSS/mp4high#theSessions"))
$a.rss.channel.item | foreach{