Skip to content

Instantly share code, notes, and snippets.

@letmaik
letmaik / sample_nb.py
Created February 7, 2021 15:18
Embed matplotlib svg plots as regular image in jupyter notebooks (with "Save as..." and automatic resize)
# Jupyter Notebook content
import numpy as np
import matplotlib.pyplot as plt
import util
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
@letmaik
letmaik / README.md
Last active November 23, 2020 04:37
Using travis_retry inside shell scripts together with set -e

If you want to use travis_retry from within your own shell script files then you first have to make the travis_retry shell function available by sourcing the travis_retry.sh file, otherwise you just get a "command not found" error. See example.sh for a full example.

Note that the original function as found in the travis-ci/travis-build repository was slightly modified to allow it to be used in a shell context where set -e is enabled.

For reference, a tweet by Travis CI saying that you should copy the travis_retry code as I've done here: https://twitter.com/plexus/status/499194992632811520

@letmaik
letmaik / CartesianProduct.ps1
Created April 27, 2017 09:23
Cartesian product with keys (cross join) in PowerShell
function CartesianProduct {
param
(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[Hashtable]
$values = @{ Foo = 1..5; Bar = 1..10}
)
$keys = @($values.GetEnumerator() | ForEach-Object { $_.Name })
$result = @($values[$keys[0]] | ForEach-Object { @{ $keys[0] = $_ } })
if ($keys.Length -gt 1) {
@letmaik
letmaik / symlinks.psm1
Created March 8, 2017 19:02
Create symlinks to folders and files on Windows without admin privileges in Powershell
@letmaik
letmaik / print-program-options.cc
Last active January 19, 2017 15:12 — forked from gesquive/print-program-options.cc
Methods to print out boost::program_options objects (C++11)
#include <string.h>
#include <iostream>
#include "boost/program_options.hpp"
#include "boost/filesystem.hpp"
#include "boost/any.hpp"
namespace po = boost::program_options;
inline void PrintUsage(const boost::program_options::options_description desc) {
std::cout << "Usage: " << app_name << " [options]" << std::endl;
@letmaik
letmaik / index.html
Created October 7, 2016 10:07
Leaflet GridLayer example with Canvas
<!DOCTYPE html>
<html>
<head>
<title>GridLayer Test</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.1/dist/leaflet.css" />
<style>
body {
padding: 0;
margin: 0;
@letmaik
letmaik / index.html
Last active October 28, 2016 09:00
CovJSON minimal visualization example
<!DOCTYPE html>
<html>
<style>
html, body, #map {
width: 100%; height: 100%;
margin: 0;
}
</style>
@letmaik
letmaik / 0_input.jsonld
Last active May 12, 2016 10:11
GeoDCAT-AP Sandbox JSON-LD framing
{
"@graph": [{
"@id": "http://inspire-sandbox.jrc.ec.europa.eu/resource/de_e70f8705-e89d-11e2-9634-52540004b857_dataset_6555",
"@type": "http://www.w3.org/ns/dcat#Dataset",
"http://purl.org/dc/terms/modified": [{
"@value": "2015-12-03",
"@type": "http://www.w3.org/2001/XMLSchema#date"
}],
"http://www.w3.org/2000/01/rdf-schema#comment": [{
"@value": "Spatial resolution (equivalent scale): 1:1000",
@letmaik
letmaik / ndarray.html
Created August 16, 2015 19:07
Fun with ndarray and canvas
<!DOCTYPE html>
<html>
<body>
<canvas id="canvas" width="300" height="300"></canvas>
<script src="https://jspm.io/system@0.16.js"></script>
<script>
System.import('npm:ndarray').then(function(ndarray) {
System.import('npm:ndarray-warp').then(function(warp) {
var canvas = document.getElementById('canvas')
var w = canvas.width
@letmaik
letmaik / test.html
Created July 26, 2015 13:57
Performance of DataView vs inline code for little/big endian conversion (inline wins)
<!doctype html>
<html>
<body>
DataView: <span id="time_dataview"></span><br />
Inline: <span id="time_inline"></span>
<script>
var littleEndian = (function() {