This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.google.common.collect.ImmutableList | |
| import com.google.common.collect.ImmutableListMultimap | |
| import com.google.common.collect.ImmutableMap | |
| import com.google.common.collect.ImmutableSet | |
| import io.reactivex.Flowable | |
| import io.reactivex.Observable | |
| fun <T> Observable<T>.toImmutableList() = | |
| collect( { ImmutableList.builder<T>() }, { b,t -> b.add(t) }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.google.common.collect.ImmutableList | |
| import com.google.common.collect.ImmutableListMultimap | |
| import com.google.common.collect.ImmutableMap | |
| import com.google.common.collect.ImmutableSet | |
| fun <T> Sequence<T>.toImmutableList(): ImmutableList<T> { | |
| val builder = ImmutableList.builder<T>() | |
| forEach { builder.add(it) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import io.reactivex.Observable | |
| fun main(args: Array<String>) { | |
| val sources = listOf( | |
| Observable.just(1, 2, 3, 4, 5), | |
| Observable.just(10, 20, 30, 40, 50), | |
| Observable.just(100, 200, 300, 400, 500) | |
| ) | |
| var cartesianProduct: Observable<List<Int>>? = null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| thomas@thomas-galago ~ $ sudo lshw | |
| [sudo] password for thomas: | |
| thomas-galago | |
| description: Notebook | |
| product: Galago Pro (Not Applicable) | |
| vendor: System76 | |
| version: galp2 | |
| serial: Not Applicable | |
| width: 64 bits | |
| capabilities: smbios-3.0 dmi-3.0 vsyscall32 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bring in Google Guava as a dependency | |
| // compile 'com.google.guava:guava:22.0' | |
| import com.google.common.base.CaseFormat | |
| import java.sql.ResultSet | |
| fun ResultSet.toDataClass(): String { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import io.reactivex.Observable | |
| import java.time.LocalTime | |
| import java.util.concurrent.TimeUnit | |
| fun main(args: Array<String>) { | |
| val source = Observable.interval(5, TimeUnit.SECONDS) | |
| .startWith(0) | |
| .map { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- ========================================= | |
| -- simple year-over-year | |
| -- ========================================= | |
| SELECT | |
| SUM(CASE WHEN year = 2008 THEN precipitation ELSE 0 END) AS cy_precipitation, | |
| SUM(CASE WHEN year = 2009 THEN precipitation ELSE 0 END) AS py_precipitation, | |
| SUM(CASE WHEN year = 2008 THEN precipitation ELSE 0.0 END) / SUM(CASE WHEN year = 2009 THEN precipitation ELSE 0.0 END) - 1.0 as change | |
| FROM station_data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setwd('c:\\git') | |
| library(DBI) | |
| library(RSQLite) | |
| db <- dbConnect(SQLite(), dbname='rexon_metals.db') | |
| myQuery <- dbSendQuery(db, "SELECT * FROM CUSTOMER") | |
| my_data <- dbFetch(myQuery, n = -1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.time.LocalDate | |
| import java.time.temporal.ChronoUnit | |
| import org.apache.commons.math3.linear.Array2DRowRealMatrix | |
| import org.apache.commons.math3.linear.RealMatrix | |
| fun main(args: Array<String>) { | |
| val matrix = patients.toMatrix( | |
| { it.age }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| <modelVersion>4.0.0</modelVersion> | |
| <groupId>com.oreilly</groupId> | |
| <artifactId>kotlinproject</artifactId> | |
| <version>1.0</version> |