Skip to content

Instantly share code, notes, and snippets.

View amakukha's full-sized avatar

Andriy Makukha amakukha

  • Toronto
View GitHub Profile
@amakukha
amakukha / ring_buff.h
Created December 27, 2018 10:56
Circular buffer in C++
#ifndef _RING_BUFFER_
#define _RING_BUFFER_
// Source: https://embeddedartistry.com/blog/2017/4/6/circular-buffers-in-cc
#include <memory>
#include <mutex>
template <class T>
class RingBuffer {
@amakukha
amakukha / Play2Tones.ino
Last active July 10, 2019 15:35
Play duo melody with Arduino
/*
* Play duo melody with Arduino
* ============================
*
* Description:
* This sketch simultaneously plays two separate melodies on two (passive)
* speakers or buzzers. This creates effect of a "choir".
* For simplicity, it uses function play2Tones(), which only plays two notes
* of equal duration simultaneosly.
* The actual melody here is the Anthem of Ukraine.
@amakukha
amakukha / circle_overlap.py
Last active August 18, 2018 08:30
Percentage area overlap between circles in Python.
#!/usr/bin/python
## Percentage area overlap between circles in Python.
## Inspired by PHP code by JP Hastings-Spital:
## https://gist.github.com/jphastings/316058
import math
def circle_overlap(centers_distance, radius1, radius2):
# Make sure the larger circle is left-most (for convenience)
#!/usr/bin/env python3
'''
A script to recursively compare two directories (including file size and file hash changes)
Usage: python3 compare_dirs.py DIR1 DIR2
'''
import os, sys, hashlib, unicodedata
COMPARE_FILES = True # should file sizes be compared if their names are the same?
#!/usr/bin/env python3
import os, sys, hashlib
MD5 = True
def md5sum(fn):
hasher = hashlib.md5()
with open(fn, 'rb') as f:
hasher.update(f.read())