Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Author: Luc Hermitte <luc.hermitte@gmail.com>
# Purpose: Script that runs a tsocks in a conf where the passowrd isn't hardcoded
# Licence: GPLv3
# Version: 1.0.0
# Copyright 2020-2022
#
# Policy
# 1. Check in $http_proxy if the password is present -- TDB
# 2. Check in a gpg encrypted file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ******************************************************************************
#
# Name: copy-projection.py (forked from gdalcopyproj.py)
# Project: GDAL Python Interface
# Purpose: Duplicate the geotransform and projection metadata from
# one raster dataset to another, which can be useful after
# performing image manipulations with other software that
# ignores or discards georeferencing metadata.
@LucHermitte
LucHermitte / observer-mixin.cpp
Created March 7, 2019 14:17
Old POC: Observer implementation in C++ with mixin layers
// (c) Luc Hermitte, 2008
// Distributed under Boost Software Licence
#include <algorithm>
#include <list>
#include <iostream>
template <class Super>
class ObservationLayer : public Super
{
protected:
@LucHermitte
LucHermitte / calibre-initials.py
Last active May 6, 2017 12:55
My way of shortening serie names for Calibre
# Python function that generates a shortened name for a serie managed by Calibre
# (c) Luc Hermitte 2017
# GPLv3
#
# The following has been inspired by https://manual.calibre-ebook.com/template_lang.html#using-general-program-mode
# but defined as a Python function as I found nowhere where GPM programs go.
# Copy-paste this function in the Function template (advanced options), name: "initials", number of parameters: 1
# and then add a custom colunm named "initials" defined as "{series:initials()}"
#
# The function strips French and English leading articles, and then keep the stripped serie name if it is
@LucHermitte
LucHermitte / domain.cpp
Last active October 22, 2016 19:38
Experience with domain<>/bounded numerical values in C++
#include "domain.h"
#include <limits>
#include <iostream>
using namespace literals;
double g(decltype(3.5_c) v)
{
return literals::value(v);
}
@LucHermitte
LucHermitte / delegate.cpp
Last active October 22, 2016 19:38
Helper macro to delegate function calls to member functions from attributes
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
// (c) 2015 Luc Hermitte
#include <vector>
#include <iostream>
#include <algorithm>
#include <list>
#define DELEGATE_TO(fname, attribute) \
auto fname() const noexcept(noexcept(attribute.fname())) { \
@LucHermitte
LucHermitte / VLV-assignment-op-definitions.cpp
Last active October 28, 2015 09:10
itk::VariableLengthVector micro benchmark
/** Copy-Assignment operator */
template< typename TValue >
VariableLengthVector< TValue > &
VariableLengthVector< TValue >
::operator=(const Self & v)
{
// No self assignment test is done. Indeed:
// - the operator already resists self assignment through a strong exception
// guarantee
// - the test becomes a pessimization as we never write "v = v;".
@LucHermitte
LucHermitte / gist:032b669e1bc9fb486cea
Created October 23, 2015 13:27
Playing with opaque typedefs
// A little attempt at defining a way to define opaque typedefs
// Yeah, it has already been done
// - https://www.youtube.com/watch?v=jLdSjh8oqmE
// - http://sourceforge.net/projects/opaque_typedef/
// (c) 2015 Luc Hermitte
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
// TODO
// - add some missing noexcept specs