Skip to content

Instantly share code, notes, and snippets.

Avatar

Miro Cupak mcupak

View GitHub Profile
@mcupak
mcupak / devoxx-exploring-reactive.jsh
Created Nov 19, 2020
Export of my JShell session from the Exploring reactive programming in Java talk at Devoxx Ukraine 2019.
View devoxx-exploring-reactive.jsh
Thread t = new Thread(() -> System.out.println("hello guadalajara"))
t.start()
ExecutorService e = Executors.newSingleThreadExecutor()
Future<String> f = e.submit(() -> "hello guadalajara")
f
f.get()
ExecutorService e = ForkJoinPool.commonPool()
Future<String> f = e.submit(() -> "hello guadalajara")
f.get()
CompletableFuture<String> cf = new CompletableFuture<String>()
@mcupak
mcupak / devoxx-type-inference.jsh
Last active Nov 19, 2020
Export of my JShell session from the Local variable type inference - Will it compile? talk at Devoxx Ukraine 2019.
View devoxx-type-inference.jsh
var x = "hello"
/v x
var list = new ArrayList<String>()
/v list
int x
var x
var x = null
var x = (Integer) null
int x=0, y=0
var x=0, y=0
@mcupak
mcupak / confoo-exploring-java.jsh
Created Mar 3, 2020
Export of my JShell session from the Exploring the last year of Java talk at ConFoo 2020.
View confoo-exploring-java.jsh
HttpHandler handler = he -> {
String body = "hello confoo";
he.sendResponseHeaders(200, body.length());
try (OutputStream os = he.getResponseBody()) {
os.write(body.getBytes());
}
}
/l handler
HttpServer hs = HttpServer.create(new InetSocketAddress(8000), 0)
@mcupak
mcupak / confoo-type-inference.jsh
Created Mar 3, 2020
Export of my JShell session from the Local variable type inference - Will it compile? talk at ConFoo 2020.
View confoo-type-inference.jsh
var x = "hello"
/v x
var list = new ArrayList<String>()
/v list
int x
var x
var x = null
var x = (Integer) null
int x=0, y=0
var x=0, y=0
@mcupak
mcupak / devnexus.jsh
Created Mar 3, 2020
Export of my JShell session from The Good, the Bad and the Ugly of Java API design talk at DevNexus 2020.
View devnexus.jsh
Set<Integer> set = new HashSet<Integer>()
set.add(1)
set.add(2)
set.add(3)
set = Collections.unmodifiableSet(set)
Collections.unmodifiableSet(new HashSet<>Arrays.asList(1,2,3)))
Collections.unmodifiableSet(new HashSet<>Arrays.asList(1,2,3))
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(1,2,3)))
Collections.unmodifiableSet(new HashSet<Integer>() {{ add(1); add(2); add(3); }})
ImmutableSet.of(1,2,3)
@mcupak
mcupak / djug.jsh
Created Oct 6, 2019
Export of my JShell session from the The good, the bad, and the ugly of Java API design talk at Detroit Java User Group 2019.
View djug.jsh
List<Integer> list = new ArrayList<Integer>()
list.add(1)
list.add(2)
list.add(3)
list = Collections.unmodifiableList(list)
Collections.unmodifiableList(Arrays.asList(1,2,3))
Collections.unmodifiableList(Stream.of(1,2,3).collect(toList()))
Collections.unmodifiableList(new ArrayList<Integer>() {{ add(1); add(2); add(3); }})
/env -class-path guava-27.1-jre.jar
import com.google.common.collect.ImmutableList
@mcupak
mcupak / javadevdaymx-reactive.jsh
Created Oct 6, 2019
Export of my JShell session from the Exploring reactive programming in Java talk at Java Dev Day Mexico 2019.
View javadevdaymx-reactive.jsh
Thread t = new Thread(() -> System.out.println("hello guadalajara"))
t.start()
ExecutorService e = Executors.newSingleThreadExecutor()
Future<String> f = e.submit(() -> "hello guadalajara")
f
f.get()
ExecutorService e = ForkJoinPool.commonPool()
Future<String> f = e.submit(() -> "hello guadalajara")
f.get()
CompletableFuture<String> cf = new CompletableFuture<String>()
@mcupak
mcupak / javadevdaymx-api-design.jsh
Created Oct 6, 2019
Export of my JShell session from the The good, the bad, and the ugly of Java API design talk at Java Dev Day Mexico 2019.
View javadevdaymx-api-design.jsh
List<Integer> list = new ArrayList<Integer>()
list.add(1)
list.add(2)
list.add(3)
list = Collections.unmodifiableList(list)
Collections.unmodifiableList(Arrays.asList(1,2,3))
Collections.unmodifiableList(Stream.of(1,2,3).collect(toList()))
Collections.unmodifiableList(new ArrayList<Integer>() {{ add(1); add(2); add(3); }} )
/env -class-path guava-27.1-jre.jar
import com.google.common.collect.ImmutableList
@mcupak
mcupak / tjug.jsh
Created Jun 28, 2019
JShell session from the Pub Quiz: Local Variable Type Inference talk at TJUG.
View tjug.jsh
var x = "hello"
/v x
var list = new ArrayList<String>()
/v list
int x
var x
var x = null
var x = (Integer) null
int x=0, y=0
var x=0, y=0
@mcupak
mcupak / voxxed-minsk-api-design.jsh
Created Jun 1, 2019
Export of my JShell session from The good, the bad, and the ugly of Java API design talk at Voxxed Days Minsk 2019.
View voxxed-minsk-api-design.jsh
List<Integer> list = new ArrayList<Integer>()
list.add(1)
list.add(2)
list.add(3)
list = Collections.unmodifiableList(list)
Collections.unmodifiableList(new ArrayList<>(Arrays.asList(1,2,3)))
Collections.unmodifiableList(Stream.of(1,2,3).collect(toList()))
Collections.unmodifiableList(new ArrayList<Integer>() {{ add(1); add(2); add(3); }})
/env -class-path guava-27.1-jre.jar
import com.google.common.collect.ImmutableList