(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| #!/usr/bin/env bash | |
| # https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/ | |
| # https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c | |
| # http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver | |
| # http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception | |
| # http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal | |
| # http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04 | |
| # Versions | |
| CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` |
#Intro
Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3
Kotlin project website is at kotlin.jetbrains.org.
All the codes here can be copied and run on Kotlin online editor.
Let's get started.
"The trick is to catch exceptions at the proper layer, where your program can either meaningfully recover from the exception and continue without causing further errors, or provide the user with specific information, including instructions on how to recover from the error. When it is not practical for a method to do either of these, simply let the exception go so it can be caught later on and handled at the appropriate level."
Advantages of Exceptions
Excellent example of separating error-handling code from program logic
Three Rules for Effective Exception Handling
Longer explanation and case study of exception use, including the basic principles of "throw early" and "catch late". Clear and thorough.
| import java.io.File; | |
| import java.io.FileNotFoundException; | |
| import java.io.IOException; | |
| import java.util.InputMismatchException; | |
| import java.util.Random; | |
| import java.util.Scanner; | |
| public class Exceptions { | |
| // An exception is an event that occurs during the execution of a program |
| import java.time.*; | |
| import java.time.format.DateTimeFormatter; | |
| import java.time.format.FormatStyle; | |
| import java.time.temporal.ChronoUnit; | |
| import java.time.temporal.TemporalAdjusters; | |
| import java.util.*; | |
| import static java.time.temporal.TemporalAdjusters.*; | |
| public class Java8DateTimeExamples { |
| import com.petebevin.markdown.MarkdownProcessor | |
| import org.xhtmlrenderer.pdf.ITextRenderer | |
| import org.ccil.cowan.tagsoup.Parser | |
| import org.apache.xalan.xsltc.trax.SAX2DOM | |
| import org.xml.sax.InputSource | |
| buildscript{ | |
| repositories { | |
| mavenCentral() | |
| maven { |
| @Test | |
| public void postMessage() | |
| { | |
| driver.get("https://csc510-fall16.slack.com/"); | |
| // Wait until page loads and we can see a sign in button. | |
| WebDriverWait wait = new WebDriverWait(driver, 30); | |
| wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("signin_btn"))); | |
| // Find email and password fields. |
| import os | |
| import sys | |
| # constants, configure to match your environment | |
| HOST = 'http://localhost:9200' | |
| INDEX = 'test' | |
| TYPE = 'attachment' | |
| TMP_FILE_NAME = 'tmp.json' | |
| # for supported formats, see apache tika - http://tika.apache.org/1.4/formats.html | |
| INDEX_FILE_TYPES = ['html','pdf', 'doc', 'docx', 'xls', 'xlsx', 'xml'] |
| import static org.junit.Assert.*; | |
| import static org.hamcrest.CoreMatchers.is; | |
| import static org.mockito.Mockito.*; | |
| import static org.mockito.BDDMockito.*; | |
| import org.hamcrest.BaseMatcher; | |
| import org.hamcrest.Description; | |
| import org.hamcrest.Matcher; |