Skip to content

Instantly share code, notes, and snippets.

@Japanuspus
Japanuspus / main.rs
Created December 4, 2019 15:02
Create iterator that returns lenghts of runs of identical elements of slice
use std::iter;
fn run_lengths<'a, T>(a: &'a[T]) -> impl Iterator<Item=usize> + 'a
where
T: std::cmp::PartialEq
{
a
.windows(2)
.enumerate()
.filter_map(|(i, ab)| if ab[0]==ab[1] {None} else {Some(i as isize)})
@Japanuspus
Japanuspus / volumiosetup.sh
Created April 25, 2015 19:06
Shell script for Volumio config
echo 'Doing stuff'
@Japanuspus
Japanuspus / lectiolize.py
Last active August 29, 2015 14:01
A python script for preparing files for upload to the Lectio system by adding student numbers to file names based on a reference folder
#!/usr/bin/env python2.7
"""
Lectiolize: A python script for preparing files for upload to the Lectio system
by adding student numbers to file names based on a reference folder.
(C) janus@insignificancegalore.net, 2014
"""
from collections import namedtuple
import re