Skip to content

Instantly share code, notes, and snippets.

View dotchetter's full-sized avatar
🎯
Focusing

Simon Olofsson dotchetter

🎯
Focusing
  • Sweden
View GitHub Profile
@dotchetter
dotchetter / .ps1
Last active November 28, 2019 11:03
PowerShell Inline Help Template
<#
.Synopsis
Short Description
.Description
Long Description
.Parameter x
Describe parameter (x)
@dotchetter
dotchetter / gist:1f65bd093af0b4b79db45ba8007953ce
Created November 19, 2019 19:42
Simple class demo in C++
#include <string>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <vector>
class Player
{
std::string name;
@dotchetter
dotchetter / .ps1
Created November 28, 2019 10:53
PowerShell OOP example
class Email
{
hidden [string]$prefix
hidden [string]$suffix
hidden [string]$domain
hidden [string]$fullAddress
hidden [string]$reEmailDomainPattern = "^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"
Email($prefix, $suffix, $domain)
@dotchetter
dotchetter / PollCache.py
Last active March 17, 2020 17:22
Call functions through the PollCache object for only receiving output from the function if new output is detected.
class PollCache:
"""
This object is designed to act as a cushion between a
function or other callable, and its caller, and only
give returns when new data from the function is identified.
This way you can pass functions to an instance of this class
and loop indefinitely, where only new results will be returned.
The PollCache object will treat every function and its
@dotchetter
dotchetter / serial_read_python.py
Created October 13, 2020 17:20
Simple script to parse UART on linux
import serial
import sys
import argparse
class ConnectionHandle:
def __init__(self, *args, **kwargs):
self._isactive = False
self._connection = None
self._bytes_available = 0
@dotchetter
dotchetter / interrupts.md
Created October 27, 2020 15:08 — forked from fpigerre/interrupts.md
Timer/Counter and Interrupt cheat-sheets for the Atmel ATMega324A microcontroller

AVR Interrupts

Each of the pins on the AVR may have multiple functions. For example, pin D0 and D1 are able to serve as receive and transmit pins for serial port one, respectively. Similarly, a number of pins on the AVR are able to transmit interrupt requests to the CPU when they receive a particular signal. How to implement this functionality is shown below.

Register Summary

Register Name Purpose of Register
PCICR Pin Change Interrupt Control Register (Enable interrupts for a particular set of PCINT ports)
PCIFR Pin Change Interrupt Flag Register (When a logic change triggers an interrupt on a particular PCINT pin, the corresponding flag will be set)
PCMSK0 Pin Change Mask Register (Select whether interrupts are enabled on a particular PCINT pin)
@dotchetter
dotchetter / mixins.py
Last active May 6, 2023 14:27
Simple mixin class in Python extracted from my framework Pyttman, mitigating the need to override __repr__ in convoluted ways over and over.
class PrettyReprMixin:
"""
Mixin providing a common interface for
__repr__ methods which represents classes
in a very readable way.
- How to use:
Define which fields to include when printing the
class or calling repr(some_object), by adding their
names to the '__repr_fields__' tuple.