Skip to content

Instantly share code, notes, and snippets.

@SAMMY7th
SAMMY7th / build.gradle
Created November 5, 2019 09:36
Spring-boot 2.1.9 build.gradle
plugins {
id 'org.springframework.boot' version '2.1.9.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
@SAMMY7th
SAMMY7th / scalakb20190523.md
Last active November 30, 2019 01:59
2019/05 Scala導入を検討したい人に向けた情報をまとめてみた

2019/05 Scala導入を検討したい人に向けた情報をまとめてみた

Scalaとは?

  • The Scala Programming Language
    • 開発元はLightbend 社 と EPFL(Odersky先生がいるスイスの大学)
    • 2019/05 現在、最新バージョンは 2.12
  • Dottyと呼ばれる新しいScalaコンパイラが開発されている
    • Scala3
  • 2019/05 現在0.15.0-RC1
@SAMMY7th
SAMMY7th / FizzBuzz.scala
Created March 4, 2019 05:21
就活GeekHub 提出ページ例です。 (例:ScalaでFizzBuzz)
object FizzBuzz extends App {
val result = (1 to 100).map {
case x if x % 3 == 0 && x % 5 == 0 => "FizzBuzz"
case x if x % 3 == 0 => "Fizz"
case x if x % 5 == 0 => "Buzz"
case x => x
}
result.foreach(println)
@SAMMY7th
SAMMY7th / sbt_error.log
Created June 8, 2018 09:50
sbtを2重起動しようとした際に発生するエラー
% sbt (git)-[develop]
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
/usr/local/Cellar/sbt/1.1.6/libexec/bin/sbt-launch-lib.bash: 58 行: 1934 Abort trap: 6 "$@"
play.api.UnexpectedException: Unexpected exception[CreationException: Unable to create injector, see the following errors:
1) Error injecting constructor, java.lang.NoSuchMethodError: scalikejdbc.NamedDB$.apply$default$2()Lscalikejdbc/SettingsProvider;
at scalikejdbc.PlayFixture.<init>(PlayFixtureModule.scala:38)
at scalikejdbc.PlayFixtureModule.bindings(PlayFixtureModule.scala:29):
Binding(class scalikejdbc.PlayFixture to self eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
while locating scalikejdbc.PlayFixture
1 error]
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:170)
[info] hello-scalikejdbc:hello-scalikejdbc_2.11:0.1 [S]
[info] +-com.github.tototoshi:play-json4s-native_2.11:0.5.0 [S]
[info] | +-com.github.tototoshi:play-json4s-api_2.11:0.5.0 [S]
[info] | | +-org.json4s:json4s-core_2.11:3.3.0 [S]
[info] | | +-com.thoughtworks.paranamer:paranamer:2.8
[info] | | +-org.json4s:json4s-ast_2.11:3.3.0 [S]
[info] | | +-org.json4s:json4s-scalap_2.11:3.3.0 [S]
[info] | | +-org.scala-lang.modules:scala-xml_2.11:1.0.5 [S]
[info] | |
[info] | +-com.github.tototoshi:play-json4s-core_2.11:0.5.0 [S]

フリーランスエンジニアやっていてよく聞かれる質問に答えていくよ

自己紹介

import scala.annotation.tailrec
import scala.collection.immutable.TreeMap
val lines = List(
"- 2018年02月08日 木曜日 20:51",
"今日は仕事をしました",
"お昼にパスタをつくりました",
"- 2018年02月09日 金曜日 20:51",
"お出かけしました"
)

ScalaのOptionとmap

val name: Option[String] = Some("きの子")
val greet = name.map(n => s"${n}さんこんにちは")  // greet: Option[String] = Some(きの子さんこんにちは)
greet.getOrElse("なまえがないよ")  // Optionから値をとりだした。 res1: String = きの子さんこんにちは

KotlinのNullableとlet

@SAMMY7th
SAMMY7th / javajo_scala_20170513.md
Created June 17, 2017 13:26
【東京】【女性/女性同伴男性限定】Java x Scala 交流会 - Java女子部 (https://javajo.doorkeeper.jp/events/59755) での登壇資料です。

副作用と参照透過性

自己紹介

  • Abe Asami “きの子 ”
  • フリーランスプログラマ
  • http://nocono.net/
  • @aa7th
  • Scala、Andorid(Java/Kotlin)