This file contains hidden or 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
| @Entity | |
| @NamedEntityGraph(name = "graph.AuthorBooks", attributeNodes = @NamedAttributeNode("books")) | |
| public class Author implements Serializable { | |
| … | |
| EntityGraph graph = entityManager.getEntityGraph("graph.AuthorBooks"); | |
| List<Author> authorsWithBooks = entityManager | |
| .createQuery("SELECT DISTINCT a FROM Author a", Author.class) |
This file contains hidden or 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 java.util.ArrayList; | |
| import java.util.List; | |
| /** | |
| * | |
| * @author Märt Bakhoff | |
| */ | |
| public class GenerateGarbage { | |
| private static final String loremIpsum = "" + |
This file contains hidden or 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 org.shelajev; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| public class LukasChallenge { | |
| public static void main(String[] args) { | |
| LukasChallenge lukasChallenge = new LukasChallenge(); | |
| List<Pair> aaa = lukasChallenge.subPalindromes("ababa"); |
This file contains hidden or 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.shelajev.updates; | |
| import rubah.Rubah; | |
| public class Component { | |
| private static DataHolder data = new DataHolder(0); | |
| public String wrangle(int i, String s) { | |
| Rubah.update("wrangle"); |
This file contains hidden or 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
| $ js | |
| > 1 + 2 | |
| 3 | |
| > print(“undefined is not a function”) | |
| undefined is not a function |
This file contains hidden or 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
| library(ggplot2) | |
| data <<- numeric(100) | |
| function(v) { | |
| svg() | |
| data <<- c(data[2:100], v) | |
| plot <- ggplot(data = data.frame(systemLoad = data, time = -99:0), | |
| aes(x=time, y=systemLoad, group=1)) + | |
| geom_line(color="orange") + | |
| expand_limits(x=0, y=0) | |
| print(plot) |
This file contains hidden or 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
| @Bean | |
| public Context getGraalVMContext() { | |
| return Context.newBuilder().allowAllAccess(true).build(); | |
| } |
This file contains hidden or 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
| @Value(value = "classpath:plot.R") | |
| private Resource rSource; | |
| @Bean | |
| Function<Double, String> getPlotFunction(@Autowired Context ctx) | |
| throws IOException { | |
| Source source = Source.newBuilder("R", rSource.getURL()).build(); | |
| return ctx.eval(source).as(Function.class); | |
| } |
This file contains hidden or 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(value = "/load", produces = "image/svg+xml") | |
| public ResponseEntity<String> load() { | |
| HttpHeaders responseHeaders = new HttpHeaders(); | |
| responseHeaders.set("Refresh", "1"); | |
| return new ResponseEntity<String>( | |
| plotFunction.apply( | |
| ManagementFactory.getOperatingSystemMXBean() | |
| .getSystemLoadAverage()), | |
| responseHeaders, | |
| HttpStatus.OK); |
This file contains hidden or 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 LogHolder { | |
| private static final Log LOG = | |
| LogFactory.getLog(SpringRApplication.class); | |
| public static void log(double value, Object... args) { | |
| LOG.info(String.format("Logging (value = %s): %s", value, | |
| Arrays.toString(args))); | |
| } | |
| } |