Inspired by dannyfritz/commit-message-emoji
See also gitmoji.
Commit type | Emoji |
---|---|
Initial commit | 🎉 :tada: |
Version tag | 🔖 :bookmark: |
New feature | ✨ :sparkles: |
Bugfix | 🐛 :bug: |
Inspired by dannyfritz/commit-message-emoji
See also gitmoji.
Commit type | Emoji |
---|---|
Initial commit | 🎉 :tada: |
Version tag | 🔖 :bookmark: |
New feature | ✨ :sparkles: |
Bugfix | 🐛 :bug: |
String bytesToHex(byte[] bytes) { | |
char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); | |
char[] hexChars = new char[bytes.length * 2]; | |
for (int j = 0; j < bytes.length; j++) { | |
int v = bytes[j] & 0xFF; | |
hexChars[j * 2] = HEX_ARRAY[v >>> 4]; | |
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; | |
} | |
return new String(hexChars); | |
} |
lazy val foo = project.in(file("foo")) | |
.settings( | |
scalaVersion := "3.0.0", | |
libraryDependencies += | |
("com.typesafe.akka" %% "akka-actor-typed" % "2.6.15") | |
.cross(CrossVersion.for3Use2_13) | |
) |
// https://www.viralpatel.net/basic-authentication-spring-webclient/ | |
@Bean | |
public WebClient webClient() { | |
var httpClient = trustStore == null || trustStore.isEmpty() ? | |
reactor.netty.http.client.HttpClient.create().compress(true) : | |
reactor.netty.http.client.HttpClient.create().compress(true) | |
.secure(sslCtxSpec -> sslCtxSpec.sslContext(createSslContext())); | |
return WebClient.builder() | |
.baseUrl(baseUrl) | |
.defaultHeaders(header -> header.setBasicAuth(username, password)) |
// https://stackoverflow.com/questions/55923326/conditional-repeat-or-retry-on-mono-with-webclient-from-spring-webflux | |
private Either<Fault, String> poll(final String id) { | |
JobResponse jr = webClient | |
.get() | |
.uri(baseUrl + "/jobs/" + id + "?f=json") | |
.retrieve() | |
.bodyToMono(JobResponse.class) | |
.filter(JobResponse::done) | |
.repeatWhenEmpty( | |
Repeat.onlyIf(ctx -> true).timeout(Duration.ofSeconds(10L)) |
// No dependencies, NIO 2.0 | |
public String read(final String resource) { | |
var in = getClass().getClassLoader().getResource(resource); | |
return new String(Files.readAllBytes(Paths.get(in.toURI()))); | |
} | |
// IOUtils + Vavr, Apache Commons | |
public String read() { | |
return Option.of(getClass().getClassLoader().getResourceAsStream(fn)) | |
.flatMap(in -> Try.of(() -> IOUtils.toString(in, StandardCharsets.UTF_8)).toOption()) |
I hereby claim:
To claim this, I am signing this object:
scala> case class Auth(u: String) | |
defined class Auth | |
scala> val auth = headerOption("Auth").withDefault("anon").as[Auth].mapOutput { a => | |
| if (a.u == "foo") Ok(a) else Unauthorized(new Exception("wrong credentials")) | |
| } | |
scala> val e = get("foo" :: auth).map(_.u) | |
e: io.finch.Endpoint[String] = GET /foo/header(Auth) |
package com.example.app | |
import org.scalatra._ | |
import servlet.{SizeConstraintExceededException, FileUploadSupport} | |
import scalate.ScalateSupport | |
import java.io.ByteArrayInputStream | |
import org.apache.poi.ss.usermodel.WorkbookFactory | |
import org.apache.poi.ss.usermodel.Cell | |
import org.apache.poi.ss.usermodel.DataFormatter | |
import org.apache.poi.ss.usermodel.DateUtil |