Skip to content

Instantly share code, notes, and snippets.

Avatar

Miro Cupak mcupak

View GitHub Profile
@mcupak
mcupak / confoo-reactive.jsh
Created Mar 14, 2019
Export of my JShell session for the Exploring reactive programming in Java session at ConFoo 2019.
View confoo-reactive.jsh
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 Mar 14, 2019
Export of my JShell session for the Writing clean code with modern Java session at ConFoo 2019.
View confoo-clean-code.jsh
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 Mar 7, 2019
Export of my JShell session from Exploring what's new in Java 10 and 11 (and 12) talk at DevNexus 2019.
View devnexus.jsh
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)
View .travis.yml
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
View .travis-script.yml
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`
View .travis-before-install.yml
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
View .travis-env.yml
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
View .travis-intro.yml
language: java
dist: trusty
sudo: false
jdk:
- openjdk8
@mcupak
mcupak / .travis.yml
Last active Jan 24, 2019
Obtaining a URL to a file in a GitHub repository in a Travis CI build
View .travis.yml
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 Nov 30, 2018
JShell transcript from my Exploring what's new in Java 10 and 11 session at Codemotion Milan 2018.
View codemotion.jsh
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)