Skip to content

Instantly share code, notes, and snippets.

View thomhayward's full-sized avatar
💭
Floundering

Thom thomhayward

💭
Floundering
View GitHub Profile
@thomhayward
thomhayward / bools.rs
Last active June 19, 2022 08:15
An Iterator for booleans
#[derive(Default)]
struct Bools(bool);
impl Iterator for Bools {
type Item = bool;
fn next(&mut self) -> Option<Self::Item> {
let value = self.0;
Some(std::mem::replace(&mut self.0, !value))
}
}
@thomhayward
thomhayward / join.rs
Created May 23, 2021 19:36
Merge two .fit files into one
extern crate chrono;
extern crate rustfit;
//use chrono::{TimeZone, Utc};
use std::convert::TryFrom;
use std::io::prelude::*;
//const FIT_TS_OFFSET: u32 = 631065600;
trait ToBytes {
@thomhayward
thomhayward / concatgpx.py
Created April 29, 2020 10:18
Concatenate track segments of multiple .gpx files into one
#!/usr/bin/env python
##
## Concatenate track segments of multiple .gpx files into one.
##
## Usage: python concatgpx.py [input1] [input2] [...] > [output]
##
## If the first .gpx file contains more than one <trkseg>, then the output file will contain a <trk> element
## with multiple <trkseg> child elements appended from the subsequent input files. If there is only a single
## <trkseg> element in the first input file, then the output file will contain a <trk> element with a single
## <trkseg> element containing all the <trkpt> elements from the subsequent input files.