Skip to content

Instantly share code, notes, and snippets.

View simon04's full-sized avatar

Simon Legner simon04

  • Innsbruck, Austria
View GitHub Profile
@simon04
simon04 / app.js
Created May 18, 2016 10:21
Delay Angular $http requests for testing
angular.module('app').config(function($httpProvider) {
$httpProvider.interceptors.push(delayHttp);
function delayHttp($timeout) {
return {
response: function(response) {
return $timeout(angular.identity, Math.random() * 1000, true, response);
}
};
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#! /bin/bash
cd $(dirname $0)
verLocal=$(cat josm_version)
verRemote=$(wget -qO - http://josm.openstreetmap.de/latest)
echo local $verLocal remote $verRemote
if [ $verLocal -lt $verRemote ]; then
@simon04
simon04 / buble-loader.js
Created February 28, 2018 16:25
Minimal buble-loader supporting webpack 4
/* eslint-env node */
const buble = require('buble');
const loaderUtils = require('loader-utils');
const path = require('path');
module.exports = function BubleLoader(source) {
this.cacheable && this.cacheable();
const options = Object.assign({transforms: {modules: false}}, loaderUtils.getOptions(this));
const transformed = buble.transform(source, options);
@simon04
simon04 / PngjWriter.java
Last active March 27, 2018 14:28
PngjWriter
import ar.com.hjg.pngj.FilterType;
import ar.com.hjg.pngj.ImageInfo;
import ar.com.hjg.pngj.ImageLineByte;
import ar.com.hjg.pngj.PngWriter;
import ar.com.hjg.pngj.PngjException;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.Raster;
import java.awt.image.SinglePixelPackedSampleModel;
@simon04
simon04 / plotly_schema_to_java.js
Created June 6, 2018 07:58
Convert Plot.ly schema to Java POJOs
const schema = JSON.parse(require('fs').readFileSync('dist/plot-schema.json'));
generate("layout", schema.layout.layoutAttributes);
generate("scatter", schema.traces.scatter.attributes);
generate("annotations", schema.layout.layoutAttributes.annotations);
generate("shapes", schema.layout.layoutAttributes.shapes);
function generate(key, value, indent = 0) {
if (key[0] === '_') {
return;
@simon04
simon04 / README.md
Last active January 4, 2019 15:34
Google Truth extension for XMLUnit

This provides a Google Truth extension for XMLUnit in order to allow to compare XML documents in unit tests.

XmlSubject.assertThat("<a><b foo='1' bar='2'></b></a>")
        .isTheSameXmlAs("<a><b bar='2' foo='1'/></a>");
@simon04
simon04 / distances.txt
Created February 3, 2019 21:30
Haltestellenabstände IVB aus OSM-Daten (https://www.openstreetmap.org/copyright, ODbL)
286 m route ("1 Bergisel – Mühlauer Brücke", 46 members)
0 m Bergisel
355 m Stubaitalbahnhof
389 m Fritz-Konzert-Straße
296 m Westbahnhof
319 m Franz-Fischer-Straße
295 m Maximilianstraße
318 m Bürgerstraße
242 m Terminal Marktplatz
306 m Maria-Theresien-Straße
#!/bin/sh
set -e
# setup ssh-agent and provide the GitHub deploy key
eval "$(ssh-agent -s)"
openssl aes-256-cbc -K $encrypted_dc4c0df7bb33_key -iv $encrypted_dc4c0df7bb33_iv -in id_ed25519.enc -out id_ed25519 -d
chmod 600 id_ed25519
ssh-add id_ed25519
# commit the assets in build/ to the gh-pages branch and push to GitHub using SSH
@simon04
simon04 / generate_smt.py
Created May 11, 2019 19:34
Solving magic squares using SMT solving
# generates SMTLIB input for SMT solvers such as [MiniSmt](http://cl-informatik.uibk.ac.at/software/minismt/)
rows = range(1, 8)
cols = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
def assert_sum(v, cells):
print(f':assumption (= {v} (+ {cells}))')
print('(benchmark none')
print(':logic QF_NIA')