Skip to content

Instantly share code, notes, and snippets.

package org.humanizer.jvm
import org.junit.Test as Test
import kotlin.test.assertEquals
import java.util.Calendar
import java.util.Date
public class DateHumanizerTests() {
fun humanizeDatAssert(difference: Int, expected: String)
package org.humanizer.jvm.tests
import org.junit.Test as Test
import kotlin.test.assertEquals
import java.util.ArrayList
import java.util.HashMap
import org.spek.*
import org.humanizer.jvm.humanize
import java.util.Calendar
import java.util.Date
val data = listOf(
-1 to "one second ago",
-10 to "10 seconds ago",
-59 to "59 seconds ago",
-60 to "a minute ago",
1 to "one second from now",
10 to "10 seconds from now",
59 to "59 seconds from now",
60 to "a minute from now"
)
fun String.pluralize() : String{
val rules = listOf(
"$" to "s",
"s$"to "s",
"(ax|test)is$" to "$1es",
"us$" to "i",
"(octop|vir)us$" to "$1i",
"(octop|vir)i$" to "$1i",
"(alias|status)$" to "$1es",
"(bu)s$" to "$1ses",
I have an enum
enum class ShowQuantityAs
{
None
Numeric
Words
}
I use it like this
package org.humanizer.jvm.tests
import org.spek.Spek
import org.spek.givenData
import org.humanizer.jvm.humanize
import org.spek.shouldEqual
import org.humanizer.jvm.dehumanize
import org.humanizer.jvm.milliSecondsToTimespan
public class TimeSpanTests(): Spek() {
Imports Nest
Imports Dapper
Module Module1
Sub Main()
Dim setting = New ConnectionSettings(New Uri("http://texsrv7:9200")).SetDefaultIndex("cases")
Dim client = New ElasticClient(setting)
Console.WriteLine("Indexing")
Dim stopwatch = New Stopwatch
Imports System
Public Module modmain
Sub Main()
Console.WriteLine ("Hello World using Visual Basic!")
End Sub
End Module
# download the package
Write-Host "Downloading $url to $file"
$cred = get-credential
$proxy = New-Object System.Net.WebProxy("proxyserver")
$proxy.credentials = $cred.GetNetworkCredential();
$downloader = new-object System.Net.WebClient
$downloader.proxy = $proxy
$downloader.DownloadFile($url, $file)
# variables
$url = "http://packages.nuget.org/v1/Package/Download/Chocolatey/0.9.8.4"
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "chocInstall"
if (![System.IO.Directory]::Exists($tempDir)) {[System.IO.Directory]::CreateDirectory($tempDir)}
$file = Join-Path $tempDir "chocolatey.zip"
# download the package
Write-Host "Downloading $url to $file"
$downloader = new-object System.Net.WebClient