Skip to content

Instantly share code, notes, and snippets.

View mterwoord's full-sized avatar

Matthijs ter Woord mterwoord

  • ter Woord Computers
View GitHub Profile
using System;
using System.IO;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using SkiaSharp;
namespace Microcharts.Uwp
{
@mterwoord
mterwoord / Source.cs
Created November 13, 2018 12:59
Socket extension
public static class SocketExtensions
{
public static Task ConnectExAsync(this Socket socket, string host, int port, CancellationToken cancellationToken = default)
{
var xCompletion = new TaskCompletionSource<bool>();
socket.BeginConnect(host,
port,
r =>
{
try
@mterwoord
mterwoord / Test.xml
Created August 16, 2017 17:06
Button sample
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Style Selector="Button.Round">
<Setter Property="Template">
<ControlTemplate>
<Border CornerRadius="8" Background="{TemplateBinding Background}">
<ContentPresenter Content="{TemplateBinding Content}"/>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TerWoord.Framework.Contracts.JetBrains.Annotations;
namespace TerWoord.Framework
{
Set-ExplorerOptions -showHiddenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
cinst fiddler4
cinst git-credential-winstore
cinst console-devel
cinst sublimetext2
cinst poshgit
cinst dotpeek
int i = 1;
Action<string> x = s => Console.WriteLine("i = {0}, s = '{1}'", i, s);
x("Hello, World");
i = 2;
x("Hello, World");
IL:
@mterwoord
mterwoord / Error.txt
Created November 12, 2016 17:24
Avalonia error
System.Reflection.TargetInvocationException was unhandled
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance[T]()
at Avalonia.Controls.AppBuilder.Start[TMainWindow]()
@mterwoord
mterwoord / Test.il
Created November 10, 2016 15:21
Test
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call UserQuery.DoIt
IL_0007: pop
IL_0008: ret
DoIt:
IL_0000: nop
IL_0001: ldc.i4.0
IL_0002: stloc.0 // result
@mterwoord
mterwoord / Test.cs
Created October 21, 2016 13:22
Voorbeeldje van simpele analyse mbt procesdumps
using (var xTarget = DataTarget.LoadCrashDump(@"e:\email.dmp"))
{
Console.WriteLine("Available clr versions:");
foreach (var xClrVersion in xTarget.ClrVersions)
{
Console.WriteLine(" - {0}", xClrVersion.Version);
}
if (xTarget.PointerSize != IntPtr.Size)
{
//Go through all the arguments
foreach (var argument in tmpStringArray)
{
//If the argument starts with the variable tag then....
if (argument.StartsWith(variableTag))
{
//Go through all the variables
foreach (var variable in variables)
{
//Check if the variable is valid