Skip to content

Instantly share code, notes, and snippets.

@cdjoubert
cdjoubert / argparse_example.py
Last active May 30, 2018 16:13
Basic usage of argparse in python
import argparse
# See also Python boilerplates:
# https://www.python-boilerplate.com/py2+executable+argparse+logging
# https://gist.github.com/ssokolow/151572
parser = argparse.ArgumentParser(description="Description")
parser.add_argument('--output','-o', help='Output file', default='out.csv')
# with type information:
parser.add_argument("-b", "--bits", help="bits", type=int, default=16)
@cdjoubert
cdjoubert / logging_example.py
Created December 10, 2017 12:09
Example of logging initialisation for python
import logging
from logging import debug, info, warning, error
logging.basicConfig(format="%(lineno)d:%(levelname)s: %(message)s", level=logging.DEBUG)
# example use:
warning("Protocol problem: %s", "connection reset")
@cdjoubert
cdjoubert / filter.c
Last active August 1, 2022 11:52
Infinite impulse response (IIR) filter in C.
#include <stdio.h>
#include <stdlib.h>
#include "filter.h"
/*
* Infinite Impulse Response (IIR) filter
* Also defines some other structures
* - arrays of double (allocation, release). Functions are defined for easier interface with SWIG
* - circular buffers