Skip to content

Instantly share code, notes, and snippets.

View mcupak's full-sized avatar

Miro Cupak mcupak

View GitHub Profile
@mcupak
mcupak / devoxx-exploring-reactive.jsh
Created November 19, 2020 03:55
Export of my JShell session from the Exploring reactive programming in Java talk at Devoxx Ukraine 2019.
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 November 19, 2020 03:53
Export of my JShell session from the Local variable type inference - Will it compile? talk at Devoxx Ukraine 2019.
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 March 3, 2020 22:07
Export of my JShell session from the Exploring the last year of Java talk at ConFoo 2020.
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 March 3, 2020 22:06
Export of my JShell session from the Local variable type inference - Will it compile? talk at ConFoo 2020.
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 March 3, 2020 22:05
Export of my JShell session from The Good, the Bad and the Ugly of Java API design talk at DevNexus 2020.
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 October 6, 2019 20:36
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.
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 October 6, 2019 20:36
Export of my JShell session from the Exploring reactive programming in Java talk at Java Dev Day Mexico 2019.
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 October 6, 2019 20:35
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.
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 June 28, 2019 17:11
JShell session from the Pub Quiz: Local Variable Type Inference talk at TJUG.
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 June 1, 2019 22:25
Export of my JShell session from The good, the bad, and the ugly of Java API design talk at Voxxed Days Minsk 2019.
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