Nice input box with a lot of styling based on sibling selectors and psuedo classes.
CSS only, and WCAG 2.0 AA compliant!
A Pen by Andrew Tunnecliffe on CodePen.
Nice input box with a lot of styling based on sibling selectors and psuedo classes.
CSS only, and WCAG 2.0 AA compliant!
A Pen by Andrew Tunnecliffe on CodePen.
/* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, version 3. | |
* | |
* This program is distributed in the hope that it will be useful, but | |
* WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
* General Public License for more details. | |
* |
fun incrementalAverage(previousAverage: Double, value: Double, iterationIndex: Int): Double { | |
return (value - previousAverage) / (iterationIndex + 1) + previousAverage | |
} |
/** | |
* Transform an Integer to a Byte Array. | |
* | |
* @param value the Integer | |
* | |
* @return the Byte Array | |
*/ | |
internal fun getByteArrayFromInt(value: Int): ByteArray { | |
val mask = 0xFF // binary 1111 1111 |
/* | |
Yoshua Bengio: | |
My preferred style of moving average is the following. Let's say you | |
have a series x_t and you want to estimate the mean m of previous | |
(recent) x's: | |
m <-- m + (2/t) (x_t - m) | |
Note that with (1/t) learning rate instead of (2/t) you get the exact |
/** | |
* Split text into substrings of [size] characters. | |
* | |
* @param size the split size. | |
* @return an array of the split text. | |
*/ | |
private fun String.splitToNChar(size: Int): List<String> { | |
val parts = ArrayList<String>() | |
val length = this.length |
/** | |
* Return the list if it is not empty, otherwise null | |
*/ | |
private fun <T>List<T>.notEmptyOrNull(): List<T>? = if (this.isEmpty()) null else this |
import com.rabbitmq.client.Connection | |
import com.rabbitmq.client.ConnectionFactory | |
/** | |
* Create a RabbitMQ Connection. | |
* | |
* @param host the host | |
* @param port the port | |
* @param username the username (can be null) | |
* @param password the username (can be null) |
/** | |
* @param resource the path to the resource to load | |
* | |
* @return the content of the resource | |
*/ | |
fun loadResource(resource: String): String = | |
try { | |
object {}.javaClass.getResource(resource).readText(Charsets.UTF_8) | |
} catch (all: Exception) { | |
throw RuntimeException("Failed to load resource=$resource!", all) |
/** | |
* Returns the combinations of the elements in this list as a list of pairs. | |
* | |
* The returned list is empty if this collection contains less than two elements. | |
* | |
* @return the combinations of the elements | |
*/ | |
fun <E>List<E>.combine(): List<Pair<E, E>> = this.foldIndexed(mutableListOf()) { i, acc, element -> | |
for (j in i + 1 until this.size) { |