Skip to content

Instantly share code, notes, and snippets.

@adashrod
adashrod / parseDecimal.xslt
Created September 7, 2025 00:53
An XSLT function to parse strings as decimal numbers that might have extra chars like "$100", "50%", "(+33)"
<!--
Extracts a number from a string, ignoring invalid characters. If a string contains multiple numbers, the first
will be returned. If no number can be extracted, this can be detected like: test="not(normalize-space($result))"
@param {string} input a string to parse for a number
-->
<xsl:function name="fun:LenientParseDecimal">
<xsl:param name="input"/>
<xsl:call-template name="lenientParseDecimalHelper">
<xsl:with-param name="str" select="$input"/>
</xsl:call-template>
@adashrod
adashrod / MockitoWeirdness.java
Created November 27, 2019 05:34
I ran into a weird problem with Mockito and JUnit 5. A test passed in IntelliJ, but failed at the command line.
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
@adashrod
adashrod / CamelCaseRant.md
Last active June 25, 2025 21:02
A rant about how to properly camel-case acronyms and abbreviations

Why using all-caps acronyms/abbreviations in camel case names is wrong

or, write MyUrlClass, not MyURLClass

Camel case

General Rules:

  • Each word is capitalized
  • no spaces
  • only alphanumeric characters

Upper Camel Case (aka Pascal case)