Skip to content

Instantly share code, notes, and snippets.

View NomadBlacky's full-sized avatar

Takumi Kadowaki NomadBlacky

View GitHub Profile
@NomadBlacky
NomadBlacky / file0.txt
Last active September 28, 2016 06:48
【git】 authorを間違えてcommitした上で、pushしてしまった時の対処法と再発防止策 ref: http://qiita.com/NomadBlacky/items/51d39ab83e0118c0cd4a
$ git rebase -i 【間違えたコミットのひとつ前のコミット】
package org.nomadblacky.oreoretemplate
import xsbti.{ AppConfiguration, MainResult }
import scala.reflect.io.File
/**
* Created by blacky on 17/05/02.
*/
case class Config(variablesFile: File = File("variables"), templateDirectory: File = File("templates"))
scala> Some("a").map(_ == "a").getOrElse(false)
res5: Boolean = true
scala> Some("a").exists(_ == "a")
res6: Boolean = true
scala> Some("a").contains("a")
res7: Boolean = true
scala> val a = doc >> elements("rect") >> attrs("data-date")
a: Iterable[String] = List(2016-06-05, 2016-06-06, 2016-06-07, 2016-06-08, 2016-06-09, 2016-06-10, 2016-06-11, 2016-06-12, 2016-06-13, 2016-06-14, 2016-06-15, 2016-06-16, 2016-06-17, 2016-06-18, 2016-06-19, 2016-06-20, 2016-06-21, 2016-06-22, 2016-06-23, 2016-06-24, 2016-06-25, 2016-06-26, 2016-06-27, 2016-06-28, 2016-06-29, 2016-06-30, 2016-07-01, 2016-07-02, 2016-07-03, 2016-07-04, 2016-07-05, 2016-07-06, 2016-07-07, 2016-07-08, 2016-07-09, 2016-07-10, 2016-07-11, 2016-07-12, 2016-07-13, 2016-07-14, 2016-07-15, 2016-07-16, 2016-07-17, 2016-07-18, 2016-07-19, 2016-07-20, 2016-07-21, 2016-07-22, 2016-07-23, 2016-07-24, 2016-07-25, 2016-07-26, 2016-07-27, 2016-07-28, 2016-07-29, 2016-07-30, 2016-07-31, 2016-08-01, 2016-08-02, 2016-08-03, 2016-08-04, 2016-08-05, ...
scala> a.filter(_ == "2017-06-01")
res1: Iterable[String] = List(2017-06-01)
scala> doc >> elements("rect") >/~ validator(attr("data-date"))(_ == "2017-06-01")
res2: Either[Unit,net.ruip
@NomadBlacky
NomadBlacky / foo.scala
Last active August 13, 2018 06:08
scala.reflect.ClassTag
@ def foo[T: scala.reflect.ClassTag](obj: Any): Unit = obj match {
case t: T => println(t.getClass.getName)
case _ => println("ng")
}
defined function foo
@ foo[Int](1)
java.lang.Integer
@ val options = List(None, None, Some(1), None, Some(2))
options: List[Option[Int]] = List(None, None, Some(1), None, Some(2))
@ options.collectFirst {
case Some(v) => v
}
res4: Option[Int] = Some(1)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import com.typesafe.scalalogging.StrictLogging
import net.logstash.logback.marker.Markers
import org.slf4j.Marker
import play.api.libs.ws.StandaloneWSResponse
import play.api.libs.ws.ahc.{StandaloneAhcWSClient, StandaloneAhcWSRequest}
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{Failure, Success}
@NomadBlacky
NomadBlacky / dialog.scala
Created March 7, 2019 10:32
何度閉じてもダイアログが出てくるScalaスクリプト
import java.awt._, event._
import javax.swing._
import scala.util.Random
val (screenCenterW, screenCenterH) = {
val ss = Toolkit.getDefaultToolkit().getScreenSize
(ss.getWidth.toInt / 2, ss.getHeight.toInt / 2)
}
@NomadBlacky
NomadBlacky / shellsession.txt
Created April 24, 2019 02:33
Terraform on Docker with aws-vault
$ aws-vault exec admin-profile -- docker run -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_DEFAULT_REGION -e AWS_SESSION_TOKEN -e AWS_SECURITY_TOKEN -it -v $PWD:/app/ -w /app/ hashicorp/terraform:0.11.8 init
Initializing the backend...
Backend configuration changed!
Terraform has detected that the configuration specified for the backend
has changed. Terraform will now check for existing state in the backends.
Error inspecting states in the "s3" backend: