Skip to content

Instantly share code, notes, and snippets.

View jakesays-old's full-sized avatar

Big Jake jakesays-old

View GitHub Profile
internal enum PacketSignature : uint
{
Valid = 0x42424242,
Failover = 0x43434343
}
[StructLayout(LayoutKind.Sequential)]
internal struct MessagePacketHeader
{
@jakesays-old
jakesays-old / AppSettings.cs
Created October 20, 2014 23:52
Simple app settings class
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows;
using System.Windows.Media;
using FirstFloor.ModernUI.Presentation;
@jakesays-old
jakesays-old / Base36.cs
Created November 5, 2014 02:03
Base 36 Conversion Methods
using System;
namespace Frob.Utility
{
public static class Base36
{
private static readonly char[] _digits =
{
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
@jakesays-old
jakesays-old / frob.cs
Last active August 29, 2015 14:11
Pattern matching in c#
ParseClaimIdentifiers(@ref, claim)
.Match(ReferenceQualifier.SpecialPaymentReferenceNumber,
r => claim.ServiceAuthExceptionCode = ServiceAuthExceptionCodeConverter.FromAnsi(r).Adapt())
.Match(ReferenceQualifier.OriginalReferenceNumber,
r => claim.OriginalPayerClaimControlNumber = r)
.Match(ReferenceQualifier.ReferralNumber,
r => claim.ReferralNumber = r)
.Match(ReferenceQualifier.PriorAuthorizationNumber,
r => claim.PriorAuthorization = r)
.Match(ReferenceQualifier.RepricedClaimReferenceNumber,
using System;
using System.Collections;
using System.Collections.Generic;
public class Foo
{
public string OtherKey { get; set; }
}
public class StupidDictionary : IDictionary<string, Foo>
@jakesays-old
jakesays-old / FileDecryptor.cs
Created January 5, 2015 14:42
libgpgme usage example
using System;
using System.IO;
using Libgpgme;
namespace Frob
{
public class FileDecryptor : IDisposable
{
private Context _gpgContext;
private readonly char[] _passphrase;
<!-- instead of: -->
<Border BorderThickness="0,0,1,0" BorderBrush="Black" Width="300" HorizontalAlignment="Left">
<StackPanel Width="300" HorizontalAlignment="Left">
<TextBlock Text="46. DATE OF ACCIDENT" Style="{DynamicResource SectionHeaders}"/>
<DatePicker Margin="10,5,10,0"/>
</StackPanel>
</Border>
<!-- i want: -->
public abstract class PropertyIndexer<TProperty>
{
protected abstract TProperty GetValue(int index);
protected abstract void SetValue(int index, TProperty value);
public TProperty this[int index]
{
get { return GetValue(index); }
set { SetValue(index, value); }
}
@jakesays-old
jakesays-old / SimpleCommand.cs
Created March 7, 2015 04:03
SimpleCommand - simple ICommand implementation
public class SimpleCommand : ICommand
{
private readonly Func<bool> _canExecute;
private readonly Action _execute;
public SimpleCommand(Action execute, Func<bool> canExecute = null)
{
_execute = execute;
_canExecute = canExecute;
}
using System;
namespace JakeSays
{
public static class DateTimeExtensions
{
/// <summary>
/// Determines whether value represents a leap day
/// </summary>