Skip to content

Instantly share code, notes, and snippets.

View cerebrate's full-sized avatar

Alistair Young cerebrate

View GitHub Profile
@cerebrate
cerebrate / gist:6695088
Created September 25, 2013 04:11
Today's faulty, pain-in-the-ass code.
<xctk:EditorDefinitionCollection x:Key="StandardPropertyEditors" x:Shared="False">
<xctk:EditorTemplateDefinition TargetProperties="{arkane:Nullable TypeName=system:Boolean}" >
<xctk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Value}" IsThreeState="True" />
</DataTemplate>
</xctk:EditorTemplateDefinition.EditingTemplate>
</xctk:EditorTemplateDefinition>
<xctk:EditorTemplateDefinition TargetProperties="{arkane:Nullable system:DateTime}">
<xctk:EditorTemplateDefinition.EditingTemplate>
@cerebrate
cerebrate / gist:6695095
Created September 25, 2013 04:12
The markup extension that's supposed to make today's faulty, pain-in-the-ass code work.
/// <summary>
/// XAML markup extension to make it possible to reference nullable types.
/// </summary>
[MarkupExtensionReturnType (typeof (Type))]
public class NullableExtension : TypeExtension
{
/// <summary>
/// Initializes a new instance of the NullableExtension class.
/// </summary>
public NullableExtension ()
@cerebrate
cerebrate / ApartmentAspect.cs
Last active January 3, 2016 15:29
ApartmentAspect for PostSharp.
namespace ArkaneSystems.Arkane.Aspects
{
/// <summary>
/// An aspect to execute a function on a thread in the given COM apartment state.
/// </summary>
[Serializable]
public sealed class ApartmentAspect : MethodInterceptionAspect
{
private readonly ApartmentState desiredState;
private Exception returnException;
@cerebrate
cerebrate / UnlessDisposed
Created January 21, 2014 18:56
Automatically implement the "if disposed, throw exception" pattern.
namespace ArkaneSystems.Arkane.Aspects
{
/// <summary>
/// An aspect which blocks calls to all public methods of a class implementing <see cref="IDisposable"/> once the class has
/// been disposed, instead throwing <see cref="ObjectDisposedException"/>. The class upon which this aspect is placed must
/// use the common pattern in which a private boolean field named 'disposed' is used to hold the disposed state.
/// </summary>
/// <remarks>
/// Private methods, static methods, and finalizers can still run when the class is disposed, as they may
/// be required for cleanup.
!
! Last configuration change at 10:05:35 CDT Wed Aug 17 2016 by avatar
! NVRAM config last updated at 09:31:51 CDT Wed Aug 17 2016 by avatar
!
version 12.4
no service pad
service timestamps debug datetime msec
service timestamps log datetime msec
service password-encryption
service linenumber

Keybase proof

I hereby claim:

  • I am cerebrate on github.
  • I am cerebrate (https://keybase.io/cerebrate) on keybase.
  • I have a public key ASAggWBv-rBgDm8LNH1F4_vo9P0b6QN8-BjJnFO_MxvYzAo

To claim this, I am signing this object:

@cerebrate
cerebrate / gist:81ad9501ed2e6ee129b5aac192adc292
Created November 13, 2016 09:10
script for security example
#!/bin/sh
echo "Seriously!? After I _told_ you what it could do?"
echo "Kinda makes me wish I'd put rm -rf / in here after all."
(use-package vc
:config
(progn
;; show vc commands being executed
(setq vc-command-messages t)
;; confirm when chasing symlinks in a VC directory
(setq vc-follow-symlinks 'ask)
;; handled back-ends
/*
Dogtector - operating code for the Dogtector
Copyright Alistair Young, 2017. All Rights Reserved.
*/
#include <ESP8266WiFi.h>
#include <Ticker.h>
#include <Adafruit_MQTT.h>
#include <Adafruit_MQTT_Client.h>
@cerebrate
cerebrate / Update-AUPackages.md
Created January 25, 2017 00:54
Update-AUPackages Report #powershell #chocolatey