This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copied from <a href="https://stackoverflow.com/questions/2474017/using-reflection-to-change-static-final-file-separatorchar-for-unit-testing/2474242#2474242">Stack Overflow</a> | |
* Do exercise extreme caution with this technique. | |
* Devastating consequences aside, the following actually works: | |
* <pre>{@code | |
* setFinalStatic(Boolean.class.getField("FALSE"), true); | |
* System.out.format("Everything is %s", false); // "Everything is true"}</pre> | |
*/ | |
static void setFinalStatic(Field field, Object newValue) throws Exception { | |
field.setAccessible(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# regex to validate in commit msg | |
# https://regex101.com/r/VTEL5G/3 | |
commit_regex='(Merge(.*)|([A-Z_]+-[0-9]+)|((\d+\.)?(\d+\.)?(\d+).(RELEASE|SNAPSHOT)))' | |
error_msg="Commit message must start with JIRA issue (eg. 'MME-xxx', 'INC-xxx'), 'x.x.x.RELEASE', 'x.x.x-SNAPSHOT' or 'Merge(d)'" | |
echo "#!/usr/bin/env bash | |
commit_regex='$commit_regex' | |
error_msg=\"$error_msg\" | |
if ! grep -qE \"\$commit_regex\" \"\$1\"; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C# 10 | |
namespace Helpers; | |
public static class CantorPairCalculator | |
{ | |
/// <summary>Calculates the cantor pair of input parameters a & b | |
/// Commutative operation, the lowest input parameter is assigned to x, the highest to y | |
/// </summary> | |
/// <returns>Returns a cantor pair integer</returns> | |
public static int CalculateCommutativeCantorPair(this int a, int b) |