Skip to content

Instantly share code, notes, and snippets.

View peters's full-sized avatar
😀
On

Peter Rekdal Khan-Sunde peters

😀
On
View GitHub Profile
@peters
peters / FluentAggregationExtensions.md
Last active October 2, 2017 15:58
A collection of fluent aggregation extension methods that should find it's way into the official MongoDB c# driver

Spec

public static class FluentAggregationExtensions 
{

  public static Task<List<TNewResult>> ProjectToListAsync<TResult, TNewResult>(this IAggregateFluent<TResult> aggregate, Expression<Func<TResult, IEnumerable<TNewResult>>> field)
  {
    var fieldName = $"${((MemberExpression) field.Body).Member.Name}";
@peters
peters / DomainRoute.cs
Created October 22, 2017 00:43 — forked from IDisposable/DomainRoute.cs
Domain (hostname) Routing for Asp.Net MVC and WebAPI
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Http;
using System.Web.Http.Routing;
using System.Web.Mvc;
@peters
peters / DomainRoute.cs
Created October 22, 2017 00:43 — forked from IDisposable/DomainRoute.cs
Domain (hostname) Routing for Asp.Net MVC and WebAPI
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Http;
using System.Web.Http.Routing;
using System.Web.Mvc;
@peters
peters / answer.cs
Created June 21, 2018 14:12 — forked from jkingry/answer.cs
How do you close TCP connections gracefully without exceptions?
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace Example
{
class Channel
# apt-get install
sudo apt-get update
# For ubuntu 14.04
sudo apt-get install -y xserver-xorg-video-dummy-lts-trusty
# For ubuntu 16.04
sudo apt-get install -y xserver-xorg-video-dummy-lts-willy
# Copy the xorg.conf to `/etc/X11/xorg.conf`.
wget -P /etc/X11 https://gist.githubusercontent.com/mangoliou/ba126832f2fb8f86cc5b956355346038/raw/b6ad063711226fdd6413189ad905943750d64fd8/xorg.conf
Section "Monitor"
Identifier "Monitor0"
HorizSync 28.0-80.0
VertRefresh 48.0-75.0
# 1024x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 64.11 MHz
# Modeline "1024x768_60.00" 64.11 1024 1080 1184 1344 768 769 772 795 -HSync +Vsync
# 1280x720 @ 60.00 Hz (GTF) hsync: 44.76 kHz; pclk: 74.48 MHz
# Modeline "1280x720_60.00" 74.48 1280 1336 1472 1664 720 721 724 746 -HSync +Vsync
# 1368x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 85.86 MHz
# Modeline "1368x768_60.00" 85.86 1368 1440 1584 1800 768 769 772 795 -HSync +Vsync
PS C:\github\snapx.demoapp> snapx restore -i
Adding package sources from C:\github\snapx.demoapp\NuGet.Config
Adding package sources from C:\Users\peter\AppData\Roaming\NuGet\NuGet.Config
Adding package sources from C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
Adding package sources from C:\Program Files (x86)\NuGet\Config\Xamarin.Offline.config
Applications that will be restored: demoapp. Runtime identifiers (RID): win-x64, linux-x64.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Id: demoapp.
Rid: win-x64
Packages directory: C:\github\snapx.demoapp\.snapx\packages\demoapp\win-x64
@peters
peters / nuget.config
Created June 26, 2020 11:37
Snapx publish/update using a local directory
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="demoapp-publish" value="c:\demoapp_nupkgs" />
<add key="demoapp-update" value="c:\demoapp_nupkgs" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
@peters
peters / .vsconfig
Created July 8, 2020 10:17
Finter Mobility As - Visual Studio 2019 16.6
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Component.CoreEditor",
"Microsoft.VisualStudio.Workload.CoreEditor",
"Microsoft.NetCore.Component.Runtime.3.1",
"Microsoft.NetCore.Component.SDK",
"Microsoft.VisualStudio.Component.NuGet",
"Microsoft.Net.Component.4.6.1.TargetingPack",
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
@peters
peters / skiasharp_arm64.md
Created September 4, 2020 17:29 — forked from jclapis/skiasharp_arm64.md
Building SkiaSharp on a Raspberry Pi 4B

Recently, I've been playing around with a Raspberry Pi 4B that I just picked up. It's an awesome little device for the price; I'm really impressed with what it can do so far. I'm planning to use it as a driver for a DIY observatory I'm working on. As part of that, I'm writing an application that can remote control my camera and a custom motorized mount for my telescope. I decided to use .NET Core as my framework of choice; I'm a big fan of C# and its ecosystem, and the fact that .NET Core 3.1 works on ARM64 systems (which is what the Pi 4B runs) makes it a no-brainer.

Unfortunately, .NET Core doesn't come with any cross-platform UI frameworks out of the box. I use WPF a lot for Windows projects, but one of its biggest weaknesses is that it isn't supported on anything else. The WPF repo already has a very long thread about this very topic, so it's definitely one that's on a lot of peoples' minds. That be