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
@Test | |
public void testSortUnsortedStream() { | |
Person kenThompson = new Person("Ken", "Thompson"); | |
Person edgerDijkstra = new Person("Edger", "Dijkstra"); | |
Person simonThompson = new Person("Simon", "Thompson"); | |
Set<Person> people = Set.of( | |
edgerDijkstra, | |
kenThompson, | |
simonThompson | |
); |
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
package com.mrbear.parameters; | |
import org.testng.annotations.Test; | |
import static org.assertj.core.api.Assertions.assertThat; | |
/** | |
* Parameters in Java are call-by-value. Which means you cannot replace a parameter of a method with another object. | |
* Sure, you can replace the <i>content/state</i> of an object, but it will remain the same object. | |
* So, java is call-by-value, and object references provided in parameters are thus <i>also</i> call-by-value. |
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
@Test | |
public void testStreamMax() { | |
Optional<Item> foundItem = items.stream() | |
.min(Comparator.comparing(Item::getPrice)); | |
assertThat(foundItem).contains(items.get(4)); | |
} |
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
@Test | |
public void testForEachLoopMax() { | |
Optional<Item> foundItem = Optional.empty(); | |
for (Item item: items) { | |
if (foundItem.isEmpty() || | |
foundItem.get().getPrice().isGreaterThan(item.getPrice())) { | |
foundItem = Optional.of(item); | |
} | |
} | |
assertThat(foundItem).contains(items.get(4)); |
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
public class Item { | |
private final String name; | |
private final MonetaryAmount price; | |
private Item(String name, MonetaryAmount price) { | |
this.name = name; | |
this.price = price; | |
} | |
public MonetaryAmount getPrice() { |
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
[INFO] mrbear:portal:war:2.0.11-SNAPSHOT | |
[INFO] +- mrbear:portalentities:jar:1.0.7-SNAPSHOT:compile | |
[INFO] | +- javax.xml.bind:jaxb-api:jar:2.3.0:compile | |
[INFO] | +- com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:jar:20180219.1:compile | |
[INFO] | \- commons-validator:commons-validator:jar:1.4.0:compile | |
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.8.3:compile | |
[INFO] | +- commons-digester:commons-digester:jar:1.8:compile | |
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile | |
[INFO] +- org.eclipse.microprofile:microprofile:pom:2.2:provided | |
[INFO] | +- javax.enterprise:cdi-api:jar:2.0:provided |
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
#!/bin/bash | |
timevar=`date +%Y-%m-%d_%H.%M.%S` | |
process_name='java' | |
echo "$timevar Renew certificates" >> /home/jelastic/crontabs/log.txt | |
certbot renew | |
cd /home/jelastic | |
echo "$timevar Import new certificates" >> /home/jelastic/crontabs/log.txt | |
./letsencrypt_certificate.sh |
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
# Example of job definition: | |
# .---------------- minute (0 - 59) | |
# | .------------- hour (0 - 23) | |
# | | .---------- day of month (1 - 31) | |
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ... | |
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat | |
# | | | | | | |
# * * * * * user-name command to be executed | |
0 0 14 03 * /home/jelastic/crontabs/certificate_renew.sh |
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
@startuml | |
' hide the spot | |
hide circle | |
' avoid problems with angled crows feet | |
skinparam linetype ortho | |
entity "Guild" as Guild { | |
*guildnr : number <<generated>> |
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
/** | |
* use "?.let" to create a lambda in which we're sure there's no problem. | |
* Is a very nice solution, if possible. | |
*/ | |
@Test | |
fun mutablePropertyCouldHaveChanged4() { | |
name?.let { assertThat(it.length).isNotZero() } | |
} |
NewerOlder