Skip to content

Instantly share code, notes, and snippets.

View rmcdouga's full-sized avatar

Rob McDougall rmcdouga

View GitHub Profile
@rmcdouga
rmcdouga / designer.html
Created October 5, 2014 12:06
designer
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../paper-ripple/paper-ripple.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@rmcdouga
rmcdouga / BrianTest.java
Last active April 5, 2018 00:08
Combat Results Test
package com.github.rmcdouga.cow.combat_simulator;
import java.util.Random;
import java.util.StringJoiner;
import com.github.rmcdouga.cow.CombatResultsTable;
import com.github.rmcdouga.cow.units.UnitType;
import com.github.rmcdouga.cow.units.UnitTypes;
public class BrianTest {
@rmcdouga
rmcdouga / LambdaExceptionUtil.java
Created March 14, 2019 14:27 — forked from jomoespe/LambdaExceptionUtil.java
Utility class to handle checked exceptions from
/**
* Utility class to handle checked exceptions in lambdas.
* <p>
* From <a href="http://stackoverflow.com/questions/27644361/how-can-i-throw-checked-exceptions-from-inside-java-8-streams">How can I throw CHECKED exceptions from inside Java 8 streams?</a>.
* This class helps to handle checked exceptions with lambdas. Example, with Class.forName method, which throws checked exceptions:
* </p>
* <pre>
* Stream.of("java.lang.Object", "java.lang.Integer", "java.lang.String")
* .map(rethrowFunction(Class::forName))
* .collect(Collectors.toList());
private <T> void setIfNotNull(final Consumer<T> setter, final T value) {
if (value != null) {
setter.accept(value);
}
}
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
package com.github.rmcdouga.gist;
import java.io.Serializable;
/**
* <p>A convenience class to represent name-value pairs.</p>
*
* Code was blatantly stolen from javafx.util.Pair class
*
* @param <K>
@rmcdouga
rmcdouga / HtmlFormDocument.java
Last active September 1, 2022 20:59
Utilities for testing outputs (Pdf.java uses Apache PDFBox to validate a PDF in tests and HtmlFormDocument uses JSoup to parse HTML)
package com.github.rmcdouga;
import static org.junit.jupiter.api.Assertions.*;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.List;
@rmcdouga
rmcdouga / .gitignore
Last active May 14, 2022 12:42
.gitignore for an Eclipse Maven project
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
@WireMockTest
class SampleTest {
private static final boolean WIREMOCK_RECORDING = false; // true tells WIREMOCK to call AEM and record the result
private static final boolean SAVE_RESULTS = false; // true saves the resuts in the actualResults directory
@BeforeEach
void setUp(WireMockRuntimeInfo wmRuntimeInfo) throws Exception {
underTest = new Sample(createAemConfig("localhost", wmRuntimeInfo.getHttpPort()));
if (WIREMOCK_RECORDING) {

JBang Commands that are useful

Playwright

Downloads and installs the browsers required to run playwright jbang -m com.microsoft.playwright.CLI com.microsoft.playwright:playwright:RELEASE install

Launches browser and records session as Java code jbang -m com.microsoft.playwright.CLI com.microsoft.playwright:playwright:RELEASE codegen -o Example.java