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
package net.susanpotter.algdt | |
sealed trait Order { | |
def execute: Unit // ignore that Unit return type is not a great idea... | |
} | |
case class MarketOrder extends Order { | |
def execute { | |
println "executing market order" | |
} |
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
// shared datastructures | |
data class ResponseModel(val value: String) | |
data class JsonResponse(val jsonValue: String) | |
// example 1 | |
interface FooUseCase { | |
fun <T> T doSomething(presenter: (ResponseModel -> 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 java.util.zip.* | |
String zipFileName = "file.zip" | |
String inputDir = "logs" | |
def outputDir = "zip" | |
//Zip files | |
ZipOutputStream zipFile = new ZipOutputStream(new FileOutputStream(zipFileName)) | |
new File(inputDir).eachFile() { file -> |
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
(1..150).each { | |
def command = ["openssl", "req", "-nodes", "-newkey", "rsa:2048", "-keyout", "/tmp/csr/example${it}.key", "-out", "/tmp/csr/csr_example_${it}.csr", "-subj", "/C=GB/ST=London/L=London/O=Global Security/OU=IT Department/CN=example${it}.com"] | |
def sout = new StringBuilder(), serr = new StringBuilder() | |
def proc = command.execute() | |
proc.consumeProcessOutput(sout, serr) | |
proc.waitFor() | |
println "out> $sout\nerr> $serr" | |
} |
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
def cert = "-----BEGIN CERTIFICATE-----\n" + | |
"MIIDojCCAoqgAwIBAgIUE6k0hxK8Iy2XJYZK8fVJaQGLIHIwDQYJKoZIhvcNAQEL\n" + | |
"BQAwUDELMAkGA1UEBhMCRlIxGTAXBgNVBAgMEMODwo5sZS1kZS1GcmFuY2UxDjAM\n" + | |
"BgNVBAcMBVBhcmlzMRYwFAYDVQQKDA1NeSBDb21wYW55IEluMB4XDTIwMTEyNDA4\n" + | |
"NDMwMloXDTIxMTEyNDA4NDMwMlowUDELMAkGA1UEBhMCRlIxGTAXBgNVBAgMEMOD\n" + | |
"wo5sZS1kZS1GcmFuY2UxDjAMBgNVBAcMBVBhcmlzMRYwFAYDVQQKDA1NeSBDb21w\n" + | |
"YW55IEluMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArZng3abWPwQp\n" + | |
"EB7u3qFhVctDhdY2eo1PxNZ0rbc7SSOUEBsoZTZHmO/tExmHx8FOtRthFa1RTjYH\n" + | |
"SNBR6pYiOUiSE7xDrkvNSNdtQWbP8fpK53m0eWqtjXoyl7nbJ+r5tQaFmisuGlBe\n" + | |
"3AVQvs9nxRtHQ7iTZD0sG0BSyh0lLRDKbLP9C88sIh0jO8PtqAzSMKERts4bj7OZ\n" + |
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
version: '2.1' | |
networks: | |
monitor-net: | |
driver: bridge | |
volumes: | |
prometheus_data: {} | |
grafana_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
//http://chrisbroadfoot.id.au/2008/08/06/groovy-threads/ | |
//http://docs.groovy-lang.org/latest/html/gapi/groovy/transform/Synchronized.html | |
//https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/findOfflineSlaves.groovy | |
import java.util.concurrent.locks.ReentrantLock | |
ReentrantLock.metaClass.withLock = { | |
lock() | |
try { | |
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 org.apache.http.client.HttpClient; | |
import org.apache.http.client.config.CookieSpecs; | |
import org.apache.http.client.config.RequestConfig; | |
import org.apache.http.impl.client.CloseableHttpClient; | |
import org.apache.http.impl.client.HttpClients; | |
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | |
import org.springframework.boot.context.properties.EnableConfigurationProperties; | |
import org.springframework.boot.web.client.RestTemplateCustomizer; |
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
http --cert=mycert.crt --cert-key=mykey.key --verify=ca-bundle POST https://example.test/api < /path/to_file.json |
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.fasterxml.jackson.databind.ObjectMapper; | |
import com.fasterxml.jackson.module.jsonSchema.JsonSchema; | |
import com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator; | |
import com.fasterxml.jackson.module.jsonSchema.customProperties.ValidationSchemaFactoryWrapper; | |
import lombok.Data; | |
@Data | |
class MyClass { | |
@Size(min=14, max=14) |
NewerOlder