Skip to content

Instantly share code, notes, and snippets.

View mcupak's full-sized avatar

Miro Cupak mcupak

View GitHub Profile
@mcupak
mcupak / confoo-reactive.jsh
Created March 14, 2019 18:22
Export of my JShell session for the Exploring reactive programming in Java session at ConFoo 2019.
Thread = new Thread(() -> System.out.println("hello confoo"))
Thread t = new Thread(() -> System.out.println("hello confoo"))
t.start()
ExecutorService e = Executors.newSingleThreadExecutor()
Future<String> f = e.submit(() -> "hello confoo")
f
f.get()
ExecutorService e = ForkJoinPool.commonPool()
Future<String> f = e.submit(() -> "hello confoo")
f.get()
@mcupak
mcupak / confoo-clean-code.jsh
Created March 14, 2019 18:21
Export of my JShell session for the Writing clean code with modern Java session at ConFoo 2019.
List<Integer> list = new ArrayList<Integer>()
list.add(1)
list.add(2)
list.add(3)
list = Collections.unmodifiableList(list)
List<Integer> list2 = new ArrayList<Integer>(list)
List<Integer> list2 = Collections.unmodifiableList(new ArrayList<Integer>(list))
List<Integer> list = List.of(1,2,3)
list.add(4)
list.getClass()
@mcupak
mcupak / devnexus.jsh
Created March 7, 2019 17:09
Export of my JShell session from Exploring what's new in Java 10 and 11 (and 12) talk at DevNexus 2019.
List<Integer> list = new ArrayList<Integer>()
list.add(1)
list.add(2)
list.add(3)
list = Collections.unmodifiableList(list)
List<Integer> list2 = new ArrayList<Integer>(list)
List<Integer> list2 = Collections.unmodifiableList(new ArrayList<Integer>(list))
List<Integer> list = List.of(1,2,3)
list.add(4)
List<Integer> list2 = List.copyOf(list)
@mcupak
mcupak / .travis.yml
Last active February 20, 2019 20:44
language: java
dist: trusty
sudo: false
jdk:
- openjdk8
env:
- GH_URL=https://raw.githubusercontent.com VALIDATOR_URL=http://localhost:8080/validator/debug?url FILE_TO_VALIDATE=openapi.yaml URL_TO_VALIDATE=$GH_URL/${TRAVIS_PULL_REQUEST_SLUG:-$TRAVIS_REPO_SLUG}/${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}/$FILE_TO_VALIDATE
before_install:
# Build and start validator-badge. This setup will not be needed once the online version of validator-badge supports OAS 3.0. Until then we'll need to set up a local version.
- git clone --branch=v2.0.0 https://github.com/swagger-api/validator-badge.git
script:
# validate
- echo "Validating $URL_TO_VALIDATE:"
- VALIDATION_OUTPUT=`curl -sS "$VALIDATOR_URL=$URL_TO_VALIDATE"`
# print validation errors
- echo $VALIDATION_OUTPUT
# check if the validation output ignoring warnings is an empty array
- VALIDATION_ERROR_COUNT=`echo "$VALIDATION_OUTPUT" |jq -c '.schemaValidationMessages // [] | map(select(.level != "warning"))' |jq length`
before_install:
# Build and start validator-badge. This setup will not be needed once the online version of validator-badge supports OAS 3.0. Until then we'll need to set up a local version.
- git clone --branch=v2.0.0 https://github.com/swagger-api/validator-badge.git
- cd validator-badge
- mvn package -q -DskipTests=true -Dmaven.javadoc.skip=true -B -V jetty:run &
- cd ..
- sleep 60
env:
- GH_URL=https://raw.githubusercontent.com VALIDATOR_URL=http://localhost:8080/validator/debug?url FILE_TO_VALIDATE=openapi.yaml URL_TO_VALIDATE=$GH_URL/${TRAVIS_PULL_REQUEST_SLUG:-$TRAVIS_REPO_SLUG}/${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}/$FILE_TO_VALIDATE
language: java
dist: trusty
sudo: false
jdk:
- openjdk8
@mcupak
mcupak / .travis.yml
Last active January 24, 2019 22:31
Obtaining a URL to a file in a GitHub repository in a Travis CI build
env:
- FILE_URL=https://raw.githubusercontent.com/${TRAVIS_PULL_REQUEST_SLUG:-$TRAVIS_REPO_SLUG}/${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}/{FILE_PATH}
@mcupak
mcupak / codemotion.jsh
Created November 30, 2018 12:13
JShell transcript from my Exploring what's new in Java 10 and 11 session at Codemotion Milan 2018.
List<Integer> list = new ArrayList<Integer>()
list.add(1)
list.add(2)
list.add(3)
list = Collections.unmodifiableList(list)
List<Integer> list2 = new ArrayList<Integer>(list)
list2.add(4)
List<Integer> list2 = Collections.unmodifiableList(new ArrayList<Integer>(list))
List<Integer> list = List.of(1,2,3)
list.add(4)