Skip to content

Instantly share code, notes, and snippets.

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:

@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
@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 / 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
public class MyClass
{
public event EventHandler OnSomeEvent;
 
public void TriggerSomeEvent()
{
  try
  {
  OnSomeEvent?.Invoke(this, new EventArgs());
  }
thatClass.OnSomeEvent += (sender, args) => Console.WriteLine(“Some event happened”);
thatClass.OnSomeEvent += async (sender, args) => 
{
await Task.Yield();
throw new Exception();
}
@NZSmartie
NZSmartie / afunix.h
Last active July 2, 2020 07:35
afunix.h (Windows Insiders SDK for the Windows build 17061)
/*++
Copyright (c) Microsoft Corporation
Module Name:
afunix.h
Abstract:
@NZSmartie
NZSmartie / go-dep.sh
Created February 17, 2018 01:33
Becausse Go doesn't support command aliasing... 🤬
# TODO: Get latest release, not aa fixed version
sudo wget https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 -O /usr/bin/go-dep
sudo chmod u=rwx,go=rx /usr/bin/go-dep
cat > $HOME/.bashrc <<EOL
# Alias 'go dep' to go-dep
go() {
if [[ $@ == dep\ * ]]; then
@NZSmartie
NZSmartie / pcbnew_mod_reference_set_layer.py
Last active September 16, 2018 12:48
Set the Module's reference text to Cmts.User layer if their reference value matches
import pcbnew
import re
board = pcbnew.GetBoard()
for item in board.GetModules():
if re.match('D\d+-\d+$',item.GetReference()) is None:
continue
print "found %s" % item.GetReference()