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
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; | |
import static com.github.tomakehurst.wiremock.client.WireMock.matchingXPath; | |
import static org.junit.jupiter.api.Assertions.assertFalse; | |
import static org.junit.jupiter.api.Assertions.assertTrue; | |
import java.util.HashMap; | |
import java.util.Map; | |
import org.junit.jupiter.api.Test; |
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
git log --all --full-history -- "**/*.xml" |
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
telnet smtp.mydomain.com 25 | |
ehlo mydomain.com | |
mail from: from@mydomain.com | |
rcpt to: to@foreigndomain.com | |
data | |
subject: My subject | |
blah blah | |
blah blah | |
. |
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 ch.keller.test.extension; | |
import com.unboundid.ldap.listener.InMemoryDirectoryServer; | |
import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig; | |
import com.unboundid.ldap.listener.InMemoryListenerConfig; | |
import com.unboundid.ldif.LDIFReader; | |
import org.junit.jupiter.api.extension.AfterAllCallback; | |
import org.junit.jupiter.api.extension.BeforeAllCallback; | |
import org.junit.jupiter.api.extension.ExtensionContext; | |
import org.slf4j.Logger; |
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
# Standard error is redirected to standard output, so both are redirected to debug.log | |
perl test.pl > debug.log 2>&1 | |
# Standard output goes to out.log, and standard error to err.log | |
perl test.pl 1>out.log 2>err.log |
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
echo "console.log('Hello, World')" > index.ts | |
tsc index.ts | |
node index.js |
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
echo "Stream.of(0b01001000,0b01100001,0b01110000,0b01110000,0b01111001,0b00100000,0b01000010,0b01101001,0b01110010,0b01110100,0b01101000,0b01100100,0b01100001,0b01111001).map(Character::toChars).forEach(System.out::print)" | jshell - |
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
// Take sub-string before first space ' ' if there is any or else take the whole string | |
private static Expression<String> nameSplit( | |
Root<Person> root, | |
CriteriaBuilder builder, | |
SingularAttribute<Person, String> str | |
) { | |
Expression<Integer> indexStart = builder.literal(1); | |
Expression<Integer> indexOfFirstSpace = builder.locate(root.get(str), " "); | |
Expression<Integer> stringLength = builder.length(root.get(str)); | |
// if indexOfFirstSpace = 0, then no space ' ' is found |
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
// https://stackoverflow.com/questions/52797992/which-rxjs-operator-to-choose-to-handle-http-errors-tap-or-catcherror/61836193#61836193 | |
// "tap" is to cause side effects and it doesn't modify the chain at all, "catchError" is to catch errors in a stream and try to handle them. | |
http.get('https://test.com/').pipe( | |
tap( | |
() => { | |
// 200, awesome!, no errors will trigger it. | |
}, | |
(error: HttpErrorResponse) => { | |
// error is here, but we can only call side things. | |
}, |
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 static String catchStdout(Runnable runnable) { | |
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); | |
System.setOut(new PrintStream(outputStream)); | |
runnable.run(); | |
return outputStream.toString(); | |
} | |
@Test | |
void testCatchStdout() { | |
String s = "Hello, World"; |