Skip to content

Instantly share code, notes, and snippets.

View davidwengier's full-sized avatar
🇦🇺
Working from home, in Australia.

David Wengier davidwengier

🇦🇺
Working from home, in Australia.
View GitHub Profile
@davidwengier
davidwengier / Program.cs
Last active March 14, 2024 10:09
MEF GetExportedValue validation
using System.Composition;
using Microsoft.VisualStudio.Composition;
var exportProvider = await GetExportProviderAsync();
var service = exportProvider.GetExportedValue<IService>();
var dependent = exportProvider.GetExportedValue<IDependent>();
var service2 = exportProvider.GetExportedValue<IService>();
var dependent2 = exportProvider.GetExportedValue<IDependent>();
using System;
using System.Threading.Tasks;
using SkiaSharp;
using SkiaSharp.Views.Desktop;
namespace HiDarran
{
public partial class HiDarran : System.Windows.Forms.Form
{
private readonly SKControl skView;
using System;
namespace ConsoleApp35
{
class Program
{
private static ExceptionHandler _exceptionHandler = new ExceptionHandler();
static async void Main(string[] args)
{
var result = _exceptionHandler.With(() => someEvilShit())
@davidwengier
davidwengier / toggle_title_bar.ahk
Created August 25, 2020 06:18
AutoHotKey Script to toggle window title bars
;-Caption
LWIN & LButton::
WinSet, Style, -0xC00000, A
WinSet, Style, -0x40000, A
return
;
;+Caption
LWIN & RButton::
WinSet, Style, +0xC00000, A
using BenchmarkDotNet.Attributes;
namespace BenchmarkCore
{
[MemoryDiagnoser]
public class InterpolatedStrings
{
[Benchmark]
public string IntToString()
{
using System;
using System.Text;
using BenchmarkDotNet.Attributes;
namespace BenchmarkFull
{
// @Lyrcaxis on the C# discord asked for help improving the string interpolation code below, and someone dared suggest that string.Concat wasn't good
// and I couldn't let that rest!
[MemoryDiagnoser]
let is divisor outputString n result =
if n % divisor = 0 then
Some ( (result |> Option.defaultValue("")) + outputString)
else if result.IsSome then
result
else
None
let fizz x s = is 3 "fizz" x s

Keybase proof

I hereby claim:

  • I am davidwengier on github.
  • I am ch00k (https://keybase.io/ch00k) on keybase.
  • I have a public key whose fingerprint is 7925 6C7D 90F4 8AF6 74E8 7AE9 506B 43FC CD89 AD33

To claim this, I am signing this object:

NSDate *today = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd MMM yyyy"];
[dateFormat setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
NSString *dateString = [dateFormat stringFromDate:today];
[dateFormat release];