Skip to content

Instantly share code, notes, and snippets.

@phenyque
phenyque / counter.rs
Created April 21, 2022 11:01
Implementation of Python's collection.Counter in Rust
use std::collections::HashMap;
use std::hash::Hash;
use std::ops::Index;
/// Collection that counts occurences of items in an iterable container
///
/// Inspired by the equivalent in Python's `collections` package
///
/// # Example usage
///
#!/usr/bin/env python3
"""
Small program for convolving a mono .wav file. Purpose is to test equality of
the blockwise convolution with direct convolution.
"""
import argparse
import soundfile as sf
import numpy as np
@phenyque
phenyque / pythagorean.tex
Created August 25, 2019 18:59
Tikz angle drawing example
% draws triangle with 90 deg angle
% as example for drawing and naming angles in a shape
\documentclass[tikz, crop, border=5pt]{standalone}
%\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{amsmath}
\usepackage{bm}
@phenyque
phenyque / block_diag.tex
Created August 24, 2019 16:30
Blockdiagrams-in-Tikz reminder
\documentclass[crop, border=5pt, tikz]{standalone}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[>=Triangle, line width=1pt,
block/.style={draw, rectangle, minimum width=3em, minimum height=3em},
point/.style={coordinate, anchor=center}]
@phenyque
phenyque / wav2raw.c
Last active December 19, 2021 20:17
Extract raw sample data from .wav files
/*
* wav2raw
*
* Read .wav file and write only the signal values into a .raw file
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@phenyque
phenyque / pbrt_doc.py
Last active December 5, 2018 14:35
Auto-document configuration files and output for rendering with pbrt
#!/usr/bin/env python3
import argparse
import os
import shutil
import subprocess
import sys
COMMAND_TEMPLATE = '{exe} {scenefile} --outfile {outfile} {options}'
COMMENT_CHAR = '# '
@phenyque
phenyque / vlc_remote.py
Last active August 22, 2018 14:00
Vlc remote control script
#!/usr/bin/env python3
# -*- coding:utf8 -*-
"""
Code snippet for controlling one or multiple instances of vlc player over the
network.
To make this work, the respective vlc player instances have to be configured
to expose their web interfaces as described here:
https://wiki.videolan.org/documentation:modules/http_intf
"""
import requests
@phenyque
phenyque / reusable.py
Created September 8, 2017 13:24 — forked from LilyFoote/reusable.py
A reusable generator
def reusable(generator):
"""Convert a generator into a ReusableIterator."""
class ReusableIterator:
"""Create an wrapper for a generator to allow repeated iteration."""
def __init__(self, *args, **kwargs):
"""Store the arguments to pass to the wrapped generator."""
self.args = args
self.kwargs = kwargs