Skip to content

Instantly share code, notes, and snippets.

View Stwissel's full-sized avatar

Stephan H. Wissel Stwissel

View GitHub Profile
@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 / 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;
@Stwissel
Stwissel / Starter.java
Created August 3, 2022 04:06
Sidestart vert.x in its own thread and call an async operation in a sync block
package com.notessensei.legacy.sync_async;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.Vertx;
import io.vertx.core.eventbus.Message;
@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 / SimpleXMLDoc.java
Created April 13, 2020 14:39
Utility class to generate valid XML in Java, streaming style, see https://wissel.net/blog/2020/04/simplexmldoc-revisited.html for details
/**
* ========================================================================= *
* Copyright (C) 2006, 2007 TAO Consulting Pte <http://www.taoconsulting.sg/> *
* Copyright (C) 2011 IBM Corporation ( http://www.ibm.com/ ) *
* Copyright (C) 2020 HCL ( http://www.hcl.com/ ) *
* 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 *
@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 / README.md
Last active April 26, 2019 04:36
Custom Action for Salesforce Marketing Cloud

Marketing Cloud Custom Action

The flow provides a boilerplate to create a custom action for consumption in Salesforce Marketing Cloud. The flow outputs the data received from marketing cloud in a debug node. So you need to add whatever you want to do at the level of that debug node

Setup

  • You need to open the the Test JWT node and edit the secret. Better: remove it and set the environment variable as described in the node's documentation
  • the endpoint path is /endpoints/demo. If you want to change that you need to edit 2 nodes: config.json and Action Node

Feedback