This file contains 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:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="http://maven.apache.org/POM/4.0.0" | |
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> | |
<artifactId>kslides-maven</artifactId> | |
<groupId>org.example</groupId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>jar</packaging> |
This file contains 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
// Out-of-the-box require() stmts | |
fun increment1(x: Int): Int { | |
require(x > 0) { "value must be positive" } | |
return (x + 1).also { require(it > 0) { "result is positive" } } | |
} | |
// Consolidate the post also/require() stmts into ensure() | |
fun increment2(x: Int): Int { | |
require(x > 0) { "value must be positive" } | |
return (x + 1).ensure({ it > 0 }) { "result is positive" } |
This file contains 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
public String frontBack(String str) { | |
if (str.length() < 2) | |
return str; | |
String b = str.substring(0, 1); | |
String e = str.substring(str.length() - 1, str.length()); | |
String m = str.substring(1, str.length() - 1); | |
return e + m + b; | |
} |
This file contains 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 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
void main() => runApp(SwitchDisplayApp()); | |
class SwitchDisplayApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) => MaterialApp(home: SwitchDisplay()); | |
} |
This file contains 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
val Any.typeParameterCount: Int | |
get() = | |
when { | |
this is Array<*> -> 1 | |
!javaClass.genericSuperclass.javaClass.kotlin.isSubclassOf(ParameterizedType::class) -> 0 | |
else -> (javaClass.genericSuperclass as ParameterizedType).actualTypeArguments.size | |
} | |
4.typeParameterCount shouldEqual 0 | |
"dd".typeParameterCount shouldEqual 0 |
This file contains 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
class IncClass(var i: Int = 9) { | |
fun inc() { | |
i++ | |
} | |
override fun toString() = "Value: $i" | |
} | |
fun main() { | |
KtsScript() |
This file contains 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
# Add these to your .zshrc or .cshrc files | |
j8='export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home; java -version' | |
j11='export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.5.jdk/Contents/Home; java -version' | |
j13='export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home; java -version' |
This file contains 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
package org.athenian.select | |
import kotlinx.coroutines.delay | |
import kotlinx.coroutines.launch | |
import kotlinx.coroutines.runBlocking | |
import kotlinx.coroutines.selects.select | |
import kotlinx.coroutines.sync.Mutex | |
fun selectOnUnlock() { | |
// Initialize mutexes as locked |
This file contains 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
fun main(args: Array<String>) { | |
val nonnNullStr = "Str-" | |
val nullStr: String? = null | |
println(nonnNullStr.nullableConcat("1")) | |
println(nullStr.nullableConcat("2")) | |
println(nonnNullStr.nonnullableConcat("3")) | |
// Why is this legal? |
This file contains 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
public static void main(String[] args) | |
throws Exception { | |
// Create a JmxProxyLauncher | |
JmxProxyLauncher jmxProxyLauncher = | |
new JmxProxyLauncher.Builder() | |
.setUserName("pambrose") | |
.setPassword("topsecret") | |
.build(); |