Skip to content

Instantly share code, notes, and snippets.

View Stwissel's full-sized avatar

Stephan H. Wissel Stwissel

View GitHub Profile
@Stwissel
Stwissel / Dockerfile
Last active May 4, 2024 18:22
Dev Container with docker-compose.yml
FROM mcr.microsoft.com/devcontainers/javascript-node:1-20-bullseye
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# [Optional] Uncomment if you want to install an additional version of node using nvm
# ARG EXTRA_NODE_VERSION=10
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
@Stwissel
Stwissel / AsyncInputStream.java
Last active April 17, 2024 14:12
Wrapping an InputStream into a ReadStream<Buffer> for vert.x
# ==========================================================================
# Copyright (C) 2017-2024 NotesSensei ( https://www.wissel.net/ )
# All rights reserved.
# ==========================================================================
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. You may obtain a
# copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
@Stwissel
Stwissel / AsyncInputStream.java
Last active March 11, 2024 10:21
AsyncInputStream for vert.x - Take 2
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import io.vertx.core.AsyncResult;
import io.vertx.core.Context;
import io.vertx.core.Future;
import io.vertx.core.Handler;
@Stwissel
Stwissel / WSDL2Swagger.xslt
Last active December 20, 2023 22:10
Transform a Salesforce WSDL into an OpenAPI 2.0 Swagger YAML file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:w="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="urn:enterprise.soap.sforce.com"
xmlns:fns="urn:fault.enterprise.soap.sforce.com"
xmlns:ens="urn:sobject.enterprise.soap.sforce.com"
exclude-result-prefixes="xs"
@Stwissel
Stwissel / sinon.demo.spec.ts
Created July 31, 2023 19:46
SInon mocking NodeJS 18 fetch
import chai, { expect } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import sinon from 'sinon';
import { afterEach } from 'mocha';
chai.use(chaiAsPromised);
const urlToResultMapping = new Map<string, any>();
@Stwissel
Stwissel / TestMain.java
Created July 10, 2023 17:10
Getting mvn and log4j2 to work nicely
package com.example.starter;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class TestMain {
@Stwissel
Stwissel / .mocharc.js
Last active June 4, 2023 09:38
TypeScript project setup
'use strict';
module.exports = {
spec: ['test/**/*.spec.ts'],
};
@Stwissel
Stwissel / index.css
Last active February 7, 2023 04:49
Simple CSS /JS for TOTP Demo site
html {
font-family: 'Futura', Roboto, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
margin: 0;
font-family: 'Futura', 'Jetbrains Mono', Roboto, 'Segoe UI', Tahoma, Geneva,
Verdana, sans-serif;
background: white;
}
@Stwissel
Stwissel / couchDBStream.js
Created October 16, 2021 10:18
Streaming couchDB using NodeJS stream API and nano
const Nano = require("nano");
const { Writable, Transform } = require("stream");
const exportOneDb = (couchDBURL, resultCallback) => {
const nano = Nano(couchDBURL);
nano
.listAsStream({ include_docs: true })
.on("error", (e) => console.error("error", e))
.pipe(lineSplitter())
.pipe(jsonMaker())
@Stwissel
Stwissel / HttpServerTest.java
Created November 3, 2022 12:43
Sample JUnit5 test using the vert.x test extension to run asynchronous tests
package com.notessensei.demo;
import static org.junit.jupiter.api.Assertions.*;
import java.util.stream.Stream;
import com.hcl.tests.UnitTest;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;