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
VarHandle intHandle = MemoryHandles.varHandle(int.class, | |
ByteOrder.nativeOrder()); | |
try (MemorySegment segment = MemorySegment.allocateNative(100)) { | |
MemoryAddress base = segment.baseAddress(); | |
for (int i = 0; i < 25; i++) { | |
intHandle.set(base.addOffset(i * 4), i); | |
} | |
} |
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 void localRecord() { | |
String persons = """ | |
Java,Developer,29 | |
Python,Developer,25 | |
John,Doe,65 | |
"""; | |
record LocalPerson(String firstName, String lastName, int age) { | |
LocalPerson(String[] data) { | |
this(data[0], data[1], Integer.parseInt(data[2])); |
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
<?php | |
add_action('login_enqueue_scripts', function() { ?> | |
<style type="text/css"> | |
#login h1 a, .login h1 a { | |
background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/logo.png); | |
width: 185px; | |
height: 185px; | |
background-size: initial; | |
} | |
</style> |
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 void sendHtmlEmail(String to, String subject, String content) { | |
MimeMessage mail = javaMailSender.createMimeMessage(); | |
try { | |
MimeMessageHelper helper = new MimeMessageHelper(mail, true); | |
helper.setTo(to); | |
helper.setFrom("Blog example <from@email.com>"); | |
helper.setSubject(subject); | |
helper.setText(content, true); | |
} catch (MessagingException e) { | |
e.printStackTrace(); |
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
@RequestMapping("/path/{id}") | |
@ResponseBody | |
public String pathVariable(@PathVariable String id) { | |
return String.format("Wartość zmiennej id = %s", id); | |
} |
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
@SpringBootApplication | |
@Controller | |
public class Main { | |
@RequestMapping("/") | |
@ResponseBody | |
public String mainPage() { | |
return "Hello World!"; | |
} |
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
@Service | |
public class HelloService { | |
public String getHello() { | |
return "World"; | |
} | |
} |
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
@EnableAutoConfiguration | |
@ComponentScan | |
@EnableJpaRepositories(basePackageClasses = TaskRepository.class) | |
public class Main { | |
public static void main(String[] args) { | |
SpringApplication.run(Main.class, args); | |
} | |
} |
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 | |
if [ -z "${CODEBUILD_RESOLVED_SOURCE_VERSION:-}" ]; then | |
{ | |
echo "Error: CODEBUILD_RESOLVED_SOURCE_VERSION is not set" | |
} >&2 | |
exit 1 | |
else | |
echo "Resolved hash: ${CODEBUILD_RESOLVED_SOURCE_VERSION}" | |
fi |
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
String formatted = | |
switch (obj) { | |
case Integer i -> String.format("int %d", i); | |
case Byte b -> String.format("byte %d", b); | |
case Long l -> String.format("long %d", l); | |
case Double d -> String.format("double %f", d); | |
case String s -> String.format("String %s, s); | |
default -> String.format("Object %s", obj); | |
}; |