todokr
- “Hello world” の出力をを通じて、Javaについての基本を理解します
| package com.example | |
| import java.nio.file.{Files, Path} | |
| class HotLoader(classFilePath: Path, targetClassName: String) extends ClassLoader { | |
| override def findClass(name: String): Class[_] = { | |
| if (name == targetClassName) { | |
| val bytes = Files.readAllBytes(classFilePath) | |
| val clazz = defineClass(name, bytes, 0, bytes.length) |
Javaアプリケーションの起動を高速化する技術として、Application CDSやGraalVM Native ImageによるAOTコンパイルなどがあります。
CRaC(Coordinated Restore at Checkpoint) は実行中のJavaアプリケーションの状態をスナップショットとして保存し、スナップショットからアプリケーションを復元することで起動を高速化する技術です。
今回はCRaCを用いてSpring Bootアプリケーションのスナップショットを作成し、スナップショットからアプリケーションを起動してみます。
| /** An util for Railway Oriented Programming | |
| * | |
| * @example | |
| * import { pipe } from "./pipe.ts"; | |
| * | |
| * const DB = { | |
| * write: (_: unknown) => {}, | |
| * }; | |
| * | |
| * const validate = (input: unknown): Result<number, "NOT_AN_INTEGER"> => { |
| import java.util.Date | |
| def main(args: Array[String]): Unit = { | |
| implicit val discountPolicy: DiscountPolicy = new ComplexDiscountPolicy | |
| val price = Price(1000) | |
| val quantity = Quantity(25) | |
| println(s"price: $price") | |
| println(s"quantity: $quantity") | |
| val sales = SalesOrder( |
| import Models._ | |
| import eu.timepit.refined.api._ | |
| import eu.timepit.refined.boolean.{And, Or} | |
| import eu.timepit.refined.collection._ | |
| import eu.timepit.refined.numeric._ | |
| import eu.timepit.refined.string._ | |
| import io.circe._ | |
| import io.circe.generic.semiauto._ | |
| import io.circe.parser._ | |
| import io.estatico.newtype.Coercible |
| hoge |
| import java.time.LocalDate | |
| val today = LocalDate.now | |
| println(s"today is $today") | |
| /** 2つの指定日とその間の日からなるLocalDateのシーケンス(昇順)を返す */ | |
| def rangeDays(from: LocalDate, to: LocalDate): Seq[LocalDate] = | |
| Iterator.iterate(from)(_.plusDays(1)).takeWhile(!_.isAfter(to)).toSeq | |
| rangeDays(today, today.plusDays(5)).foreach(println) |
| (use-package auto-insert-mode) | |
| (auto-insert-mode t) | |
| ;; テンプレート置き場 | |
| (setq auto-insert-directory "~/.emacs.d/insert/") | |
| ;; "~nippo.md"というファイルをテンプレートの挿入対象に設定 | |
| (define-auto-insert "_nippo\\.md$" "nippo-template.md") | |
| ;; 日報の雛形をいい感じに生成するぞ! |
| { | |
| "title": "Thinkpad keyboard", | |
| "rules": [ | |
| { | |
| "description": "Button3 => Cmd + Button3", | |
| "manipulators": [ | |
| { "type": "basic", | |
| "from": { | |
| "pointing_button": "button3" | |
| } |