Skip to content

Instantly share code, notes, and snippets.

thatClass.OnSomeEvent += (sender, args) => Console.WriteLine(“Some event happened”);
public class MyClass
{
public event EventHandler OnSomeEvent;
 
public void TriggerSomeEvent()
{
  try
  {
  OnSomeEvent?.Invoke(this, new EventArgs());
  }
@NZSmartie
NZSmartie / asyncEventExceptions.cs
Created August 18, 2017 00:54
Handle Exceptions from async EventHandler with Nunit tests
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
namespace NunitTest
{
public delegate Task AsyncEventHandler(object sender, EventArgs e);
public class MyEventClass
@NZSmartie
NZSmartie / dual-shock-3.py
Last active May 3, 2016 10:58
Dualshock 3 example with PyHIDParser and PyUSB
import usb
import hidparser
if __name__ is not "__main__":
exit()
class MyDevice:
def __init__(self, interface: usb.core.Interface):
@NZSmartie
NZSmartie / Timers.c
Created April 16, 2016 22:13
[ATMega32u4] Why is TIFRO's OCF0B flag set and not OCF0A in the TIMER0_COMPA ISR as it's been configured to do so?
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include "Timers.h"
#define TIMER_CALLBACKS_MAX 16

Keybase proof

I hereby claim:

  • I am NZSmartie on github.
  • I am nzsmartie (https://keybase.io/nzsmartie) on keybase.
  • I have a public key whose fingerprint is 0448 F8EA A55E 7DC5 2F93 019F B7E1 258B 1896 B531

To claim this, I am signing this object: