Skip to content

Instantly share code, notes, and snippets.

View milgner's full-sized avatar
🖖
Greetings, fellow traveler of the universe!

Marcus Ilgner milgner

🖖
Greetings, fellow traveler of the universe!
View GitHub Profile
@milgner
milgner / builder.ts
Created May 5, 2019 11:13
Auto-generated builder pattern in TypeScript
class Builder<T> {
static ctor = undefined;
static propertyNames: Array<string> = undefined;
protected properties = {};
build(): T {
const builderDef = Object.getPrototypeOf(this).constructor;
const instance = new builderDef.ctor();
for (const prop of builderDef.propertyNames) {
@milgner
milgner / ReadModbusPal.kt
Last active February 17, 2022 10:26
PLC4X Kotlin
fun main() {
PlcDriverManager().getConnection("modbus://localhost:5002").use { conn ->
if (!conn.metadata.canRead()) {
println("Cannot read!!")
return
}
val builder = conn.readRequestBuilder()
builder.addItem("value-1", "coil:1")
builder.addItem("value-2", "coil:3[4]")
@milgner
milgner / faktory.kt
Last active December 7, 2020 09:59
An idea for a simple factory in Kotlin
import kotlin.reflect.KCallable
import kotlin.reflect.KClass
import kotlin.reflect.KFunction
import kotlin.reflect.KProperty
interface IFaktory<T: Any> {
fun build() : T
}
// the P generic type doesn't work as of yet
@milgner
milgner / index.html.j2
Last active February 20, 2020 14:21
Auto-generate Podlove Web Player from MP3 folder
<html>
<body>
<script src="https://cdn.podlove.org/web-player/embed.js"></script>
{% for episode in episodes %}
<div id="player{{ loop.index0 }}"></div>
<script>
podlovePlayer('#player{{ loop.index0 }}', {
title: '{{ episode.title }}',
publicationDate: '{{ episode.publication_date }}',
poster: '{{ episode.poster_url }}',
@milgner
milgner / ssce_issue_23.go
Created March 5, 2016 22:29
Reproduces issue #23 from radix.v2
package main
import (
"github.com/mediocregopher/radix.v2/pool"
"github.com/op/go-logging"
"errors"
)
var logger = logging.MustGetLogger("issue23_ssce")
@milgner
milgner / ValidationResultToJunit.xsl
Created February 22, 2013 17:21
XSL to transform a validation result XML from the Windows Application Certification Kit into a JUnit XML which can be parsed by common Continuous Integration systems such as Jenkins. Copyright (C)2013 doo GmbH, licensed under MIT License. See https://github.com/doo/metro-driver for a tool which can install appx packages for automatic processing …
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:template match="REPORT">
<testsuites>
<xsl:apply-templates select="REQUIREMENTS/REQUIREMENT"/>
</testsuites>
</xsl:template>
@milgner
milgner / pkcs5.rb
Last active December 10, 2015 08:48
Basic PKCS5 support in JRuby
require 'java'
module OpenSSL
class PKCS5
java_import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator
java_import org.bouncycastle.crypto.digests.SHA1Digest
# it should probably support a non-bouncy-castle-digest as its 5th param, but nevermind
def self.pbkdf2_hmac(pass, salt, iter, keylen, digest)
generator = PKCS5S2ParametersGenerator.new
### Keybase proof
I hereby claim:
* I am milgner on github.
* I am milgner (https://keybase.io/milgner) on keybase.
* I have a public key whose fingerprint is AEEE AC81 5481 C57A A2A6 C3AD E31D 682E 2F71 FB99
To claim this, I am signing this object:
@milgner
milgner / broadcom_on_fedora_20.patch
Created July 11, 2014 19:54
Broadcom Driver on Fedora 20
diff -r a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
2074c2074
< cfg80211_ibss_joined(ndev, (u8 *)&wl->bssid, GFP_KERNEL);
---
> cfg80211_ibss_joined(ndev, (u8 *)&wl->bssid, &wl->conf->channel, GFP_KERNEL);
@milgner
milgner / gitlab_ssl_verify.patch
Created April 30, 2014 11:11
Gitlab CI: optional SSL certificate validation
--- a/app/models/network.rb
+++ b/app/models/network.rb
@@ -7,6 +7,7 @@ class Network
opts = {
body: api_opts.to_json,
headers: {"Content-Type" => "application/json"},
+ verify: verify?
}
endpoint = File.join(url, API_PREFIX, 'session.json')