Skip to content

Instantly share code, notes, and snippets.

@nmandery
nmandery / gnus-interference.rs
Created August 5, 2022 19:33 — forked from wiseman/gnus-interference.rs
Fix trans-antimeridian polygons
/// Fix geojson polygons that span the antimeridian and have arcs > 180
/// degrees. This is a workaround for a bug in the underlying H3 library:
/// <https://github.com/uber/h3/issues/561>
///
/// This code is based on nrabinowitz's code in
/// <https://observablehq.com/@nrabinowitz/mapbox-utils>
pub fn fix_trans_meridian_coordinate(coord: &mut geo_types::Coordinate<f64>) {
if coord.x < 0.0 {
coord.x += 360.0;
@nmandery
nmandery / statemachine.c
Created February 1, 2012 14:55
State machines are very simple in C if you use function pointers.
/*
http://stackoverflow.com/questions/1371460/state-machines-tutorials/1371654#1371654
State machines are very simple in C if you use function pointers.
Basically you need 2 arrays - one for state function pointers and one for state
transition rules. Every state function returns the code, you lookup state
transition table by state and return code to find the next state and then
just execute it.
*/
@nmandery
nmandery / solidtest.py
Created November 22, 2019 12:58
solidpython playground
import geojson
from euclid3 import Point3
from solid.utils import extrude_along_path
from solid import scad_render_to_file
def main():
# https://raw.githubusercontent.com/isellsoap/deutschlandGeoJSON/master/1_deutschland/4_niedrig.geojson
#fs = geojson.loads(open('4_niedrig.geojson').read())
#outline_d = fs[0]["geometry"]["coordinates"][0][0]
@nmandery
nmandery / maildir2mailbox.py
Created September 25, 2015 14:19
Convert mails in maildir format to mailbox format
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
From http://stackoverflow.com/questions/2501182/convert-maildir-to-mbox
Frédéric Grosshans, 19 January 2012
Nathan R. Yergler, 6 June 2010
This file does not contain sufficient creative expression to invoke
assertion of copyright. No warranty is expressed or implied; use at
@nmandery
nmandery / eoc-bardabunga-volcano.markdown
Created April 4, 2018 12:54
EOC Bardabunga Volcano
@nmandery
nmandery / eoc-flood-using-wfs.markdown
Last active April 4, 2018 12:54
EOC Flood using WFS
@nmandery
nmandery / eoc-flood-using-wms-click.markdown
Last active April 4, 2018 12:54
EOC Flood using WMS + click
@nmandery
nmandery / make-git-changelog.sh
Last active November 29, 2016 12:10
generate a changelog from git tags
#!/bin/bash
# generate a changelog from git tags
TAGLIST=`git tag | grep -E '^v[0-9]+' | xargs -I@ git log --format=format:"%ai @%n" -1 @ | sort -r | awk '{print $4}'`
LAST_IN_LIST=HEAD
echo "Changelog"
echo "---------"
echo ""
@nmandery
nmandery / defer.cc
Created March 7, 2012 20:32
Go-like defer statement (C++11)
/**
* Go-like defer statement (C++11)
*
* g++ --std=c++0x -o def def.cc
*
* also see http://blog.korfuri.fr/post/go-defer-in-cpp/
*/
#include <functional>
#include <iostream>
@nmandery
nmandery / rsync_svn_only.sh
Last active September 29, 2015 21:17
rsync only svn files (directory and contents)
# copy only the .svn diretories form all subdirs
rsync -avP --include="*/" --include='.svn/***' --exclude='*' from/ to/