Skip to content

Instantly share code, notes, and snippets.

View Java16ToList.java
@Test
void testToList() {
List<String> list = Stream.of("a", "b").map(String::toUpperCase).toList();
assertEquals("[A, B]", list.toString());
}
View Java16Records.java
record FullName(String firstName, String lastName) {}
@Test
void testRecords() {
var fullName = new FullName("Mitsuyuki", "Shiiba");
assertEquals("Mitsuyuki", fullName.firstName());
assertEquals("Shiiba", fullName.lastName());
assertEquals("FullName[firstName=Mitsuyuki, lastName=Shiiba]", fullName.toString());
}
View Java16PatternMatchingForInstanceof.java
@Test
void testInstanceof1() {
Object o = "";
if (o instanceof String s) {
assertTrue(s.isEmpty());
return;
}
fail("ここには来ないよ");
}
View Java15TextBlocks.java
@Test
void testTextBlocks1() {
String html1 = "<html>\n" +
" <body>\n" +
" <p>Hello, world</p>\n" +
" </body>\n" +
"</html>\n";
String html2 = """
<html>
View Java14SwitchExpressions.java
int switchSample1(DayOfWeek dayOfWeek) {
return switch (dayOfWeek) {
case MONDAY, TUESDAY:
yield 1;
case WEDNESDAY, THURSDAY, FRIDAY:
yield 2;
case SATURDAY:
yield 3;
case SUNDAY:
yield 4;
View Java14HelpfulNullPointerExceptions.java
@Test
void testHelpfulNullPointerExceptions() {
NullPointerException npe = assertThrows(NullPointerException.class, () -> {
Object o = null;
o.toString();
});
assertEquals("Cannot invoke \"Object.toString()\" because \"o\" is null", npe.getMessage());
}
View helloweb-certificate.yaml
apiVersion: networking.gke.io/v1beta1
kind: ManagedCertificate
metadata:
name: helloweb-certificate
spec:
domains:
- gke.shiiba.dev
View envoy.yaml
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address:
protocol: TCP
address: 127.0.0.1
port_value: 9901
static_resources:
listeners:
- name: listener_0
View FizzBuzz.java
public class FizzBuzz {
public static void main(String[] args) {
for (int i = 1; i <= 30; i++) {
int a =(int)Math.pow(0, i % 3);
int b =(int)Math.pow(0, i % 5);
System.out.print("Fizz".repeat(a));
System.out.print("Buzz".repeat(b));
System.out.println(Integer.toString(i).repeat((a ^ 1) * (b ^ 1)));
}
}
View Chart.yaml
apiVersion: v1
name: istio
version: 0.8.0
description: Helm chart for all istio components
keywords:
- istio
- security
- sidecarInjectorWebhook
- mixer
- pilot