블루투쓰 마우스/터치 패드를 사용할 때 마우스 포인터가 날아다니는 현상이 있었다. 

이 이슈는 맥의 NVRAM/SMC 기능 이상이었다.


맥에 아래 동작을 하니 정상으로 돌아왔다. (윈도우의 bios 초기화와 비슷한 기능이다)


1. SMC 이상 해결 : shift-control-option 키를 누른 다음 전원 버튼를 길게 누른다.

2. NVRAM 이상 해결 :option, command, P 및 R 키를 동시에 20초 동안 누른다. 

(자세한 내용은 아래 링크를 참조한다)





참고

https://support.apple.com/ko-kr/HT201295


Mac 노트북의 SMC를 재설정하는 방법

우선 배터리를 분리할 수 있는지 확인합니다. 구형 Mac 노트북의 배터리는 대부분 분리할 수 있습니다. 배터리를 분리할 수 없는 Mac 노트북으로는 MacBook Pro (Early 2009) 및 이후 모델, MacBook Air 모든 모델, MacBook (Late 2009), MacBook (Retina, 12-inch, Early 2015) 및 이후 모델이 있습니다. Mac 노트북 배터리에 관하여 자세히 알아봅니다.

배터리를 분리할 수 없는 경우 다음을 수행합니다.

  1. Mac을 종료합니다.
  2. 내장 키보드를 사용하여 키보드 왼쪽에 있는 shift-control-option 키를 누른 다음 전원 버튼을 동시에 누릅니다. shift-control-option 키와 전원 버튼을 10초 동안 길게 누릅니다.
    Touch ID 기능이 있는 MacBook Pro의 경우 Touch ID 버튼을 전원 버튼으로도 사용할 수 있습니다.
  3. 모든 키에서 손을 뗍니다.
  4. 전원 버튼을 다시 눌러 Mac을 켭니다.


참고

https://support.apple.com/ko-kr/HT204063

NVRAM을 재설정하는 방법

Mac을 종료했다가 다시 켠 후 즉시 option, command, P 및 R 키를 동시에 20초 동안 길게 누릅니다. 키를 누르고 있는 동안 Mac이 재시동되는 것처럼 보일 수 있습니다. (전원을 켤 때 시동음이 들리는 Mac을 사용하는 경우 두 번째 시동음이 들린 후 키를 놓으면 됩니다.)

option+command+P+R

Mac의 시동이 완료되면 시스템 환경설정을 열고 사운드 음량, 디스플레이 해상도, 시동 디스크 선택, 시간대 등 재설정된 설정을 조정할 수 있습니다.

Mac에서 펌웨어 암호를 사용하는 경우 이러한 키 조합을 사용하면 Mac이 디스크 대신 macOS 복구로 시동됩니다. NVRAM을 재설정하기 전에 펌웨어 암호를 끄십시오.



참고 

http://macnews.tistory.com/742

https://support.apple.com/ko-kr/HT204063

Posted by '김용환'
,


scala에서 elatic4s에서 복합 쿼리(compound query)를 실행하는 예제이다. 

should 다음에 바로 뒤에 query를 사용하면 문제가 생긴다.



쿼리가 하나 손실되는 예제


shoud {

 matchQuery

 rangeQuery

}




appendShould 예제를 잘 사용하는 것을 추천한다. 


search(searchData.serviceTag / DEFAULT_TYPE).
query {
bool {
must {
matchQuery("message", searchData.grep)
} appendMust {
rangeQuery("@timestamp").gte(searchData.startDateTime).lte(searchData.endDateTime)
}
}
}.size(searchData.size).sortByFieldDesc("@timestamp")


요청 json은 다음과 같다. 



 
   "query": 
      "bool": 
         "should": 
             
               "match": 
                  "message": 
                     "query":"*HTTP*"
                  }
               }
            },
             
               "range": 
                  "@timestamp": 
                     "gte":"2017-11-14T14:00:00+09:00",
                     "lte":"2017-11-14T15:00:00+09:00"
                  }
               }
            }
         ]
      }
   },
   "size":10,
   "sort": 
       
         "@timestamp": 
            "order":"desc"
         }
      }
   ]
}


이 두개의 짝을 잘 맞춰 개발할 필요가 있다. 

should->appendShould

must->mustShould

Posted by '김용환'
,



elasticsearch 4s에서 json 쿼리 요청을 보려면 다음과 같이 사용한다.

(5.2.0이후부터 됨)



val json = search("music" / "bands") query "coldplay"

println("xxxxxxxx " + client.show(json))



결과는 다음과 같다.


xxxxxxxx {"query":{"query_string":{"query":"coldplay"}}}


Posted by '김용환'
,



elasticsearch의 connection pool을 만들고 slick이나 play2처럼 자원 객체를 열고 닫는 불편함을 줄이고 싶었다.


보통 java/spring을 사용한 경우라면 val connection = connectionPool.getObject() 한 후,

코드 작업 후에 connectionPool.returnObjejct()를 호출해서 자원을 반환하는 구조를 사용하는 것이 일반적인 패턴이다. (사실 이게 귀찮으면 interceptor(asepectJ)를 사용하기도 한다)




다음은 es pool 예제이다. apache pool과 elastic4s(https://github.com/sksamuel/elastic4s)를 사용했다. 

object ElasticsearchPoolManager {
val poolConfig: ElasticsearchPoolConfig = new ElasticsearchPoolConfig()
lazy val pool: ElasticsearchPool = new ElasticsearchPool(poolConfig, "googles")

def getObject(): ElasticsearchConnectionSource = {
pool.getResource()
}

def returnObject(esSource: ElasticsearchConnectionSource) = {
pool.returnResource(esSource)
}

def withES[A](block: ElasticsearchConnectionSource => A): A = {
val source = getObject()
try { block(source) }
finally { returnObject(source)}
}
}



withES를 사용함으로서 코드 블록을 감싸게 했고.. 자동으로 getObject와 returnObject 코드를 사용하지 않도록 했다.


@Singleton
class ElasticsearchDAO {
val SIZE = 10
val INDEX_DEFULT_TYPE = "fluentd"
import com.sksamuel.elastic4s.http.ElasticDsl._

def getData(searchData: SearchData): Unit = {
import elasticsearch.pool.KemiElasticsearchPoolManager._
withES { es =>
val client = es.client
val result = client.execute {
search(searchData.serviceTag / INDEX_DEFULT_TYPE).query {
rangeQuery("@timestamp") .gte(searchData.startDateTime).lte(searchData.endDateTime)
}.size(SIZE).sortByFieldDesc("@timestamp")
}.await

result.hits.hits.foreach { println }
}
}
}



아.. 이전보다는 깔끔하다..






Posted by '김용환'
,


apache phoenix에서 테이블 정보(mysql의 경우 show tables)와 테이블 속성(mysql의 경우 describe table)을 보려면 !tables와 !descrie를 사용하면 되낟.



> !tables

+------------+--------------+------------------+---------------+----------+------------+----------------------------+-----------------+--------------+-+

| TABLE_CAT  | TABLE_SCHEM  |    TABLE_NAME    |  TABLE_TYPE   | REMARKS  | TYPE_NAME  | SELF_REFERENCING_COL_NAME  | REF_GENERATION  | INDEX_STATE  | |

+------------+--------------+------------------+---------------+----------+------------+----------------------------+-----------------+--------------+-+

|            | SYSTEM       | CATALOG          | SYSTEM TABLE  |          |            |                            |                 |              | |

|            | SYSTEM       | FUNCTION         | SYSTEM TABLE  |          |            |                            |                 |              | |

|            | SYSTEM       | SEQUENCE         | SYSTEM TABLE  |          |            |                            |                 |              | |

|            | SYSTEM       | STATS            | SYSTEM TABLE  |          |            |                            |                 |              | |



> !describe google.log

+------------+--------------+------------------+--------------+------------+------------+--------------+----------------+-----------------+------------+

| TABLE_CAT  | TABLE_SCHEM  |    TABLE_NAME    | COLUMN_NAME  | DATA_TYPE  | TYPE_NAME  | COLUMN_SIZE  | BUFFER_LENGTH  | DECIMAL_DIGITS  | NUM_PREC_R |

...

Posted by '김용환'
,



double transformation을 무엇이라 번역할까 했는데..


http://www.showme.com/sh/?h=wVJLsSu


이 동영상을 보니.


역 변형이 올바른 번역인 듯 하다.



Posted by '김용환'
,


scala와 jodatime 예제이다. 사실 상 자바이긴 한데..



build.sbt 파일에 의존성 라이브러리를 추가한다.

libraryDependencies ++= Seq(

  "joda-time" % "joda-time" % "2.3",

  "org.joda" % "joda-convert" % "1.6"

)




간단하게 오늘 시간 정보를 출력한다.

import org.joda.time.DateTime
import org.joda.time.format._

val dateTime = new DateTime()
val dateString = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").print(dateTime)
print(dateString)

결과는 다음과 같다.


2017-11-20 19:37:02





import org.joda.time.{DateTime, DateTimeZone}
import org.joda.time.format._
val dateTime = new DateTime()
val dateString = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss") .print(dateTime.withZone(DateTimeZone.UTC))
print(dateString)


출력은 다음과 같다.


2017-11-20 10:39:24





ISO8601 문자열을 테스트하는 예제이다.



import org.joda.time.{DateTime}
import org.joda.time.format._
val dt = ISODateTimeFormat.dateTimeNoMillis().print(new DateTime())
print(dt)


결과는 다음과 같다. ISO8601 스펙대로 출력한다.


2017-11-20T19:56:28+09:00





다음은 ISO8601 utc 타임이다. 

import org.joda.time.{DateTime, DateTimeZone}
import org.joda.time.format._
val dt = ISODateTimeFormat.dateTimeNoMillis().print(
    new DateTime().withZone(DateTimeZone.UTC))
print(dt)


결과는 다음과 같다. ISO8601 utc 스펙대로 출력한다.


2017-11-20T10:57:34Z








Posted by '김용환'
,

[python] datetime 예제

python 2017. 11. 20. 11:35


파이썬에는 datetime 클래스를 통해 시간을 제어할 수 있다.


현재 시간을 확인하려면 now()를 호출한다.


>>> import datetime

>>> datetime.datetime.now()

datetime.datetime(2017, 11, 20, 11, 27, 46, 820594)



크리스마스까지의 남은 시간을 구하는 예제이다. 현재 시간에서 12월 25일까지의 시간을 


>>> datetime.datetime.now() - datetime.datetime(2017, 12, 25)

datetime.timedelta(-35, 41357, 474997)


사실 이는 정확치 않다. 직접 날짜를 지정하면 된다.


>>> datetime.datetime(2017,12,25)-datetime.datetime(2017,11,20)

datetime.timedelta(35)



timestamp를 구하고 싶다면 timestamp()를 호출한다.


>>> datetime.datetime.now().timestamp()

1511145029.058472




일주일 전 날을 알고 싶다면 datetime.timedelta를 사용한다.


>>> datetime.datetime.now()- datetime.timedelta(days=7)

datetime.datetime(2017, 11, 13, 11, 35, 24, 933742)


Posted by '김용환'
,


scala의 REPL에서 main 클래스/함수를 실행시킬 수 있다. 


예제는 다음과 같다. 



scala> object Main {

     |   def main(args: Array[String]) {

     |     println("Hello World")

     |   }

     | }

defined object Main




scala> Main.main(Array())

Hello World



Posted by '김용환'
,

https://mesosphere.github.io/marathon/docs/ports.html


https://mesosphere.com/blog/networking-docker-containers/


https://stackoverflow.com/questions/36265502/difference-between-ports-and-service-ports





Posted by '김용환'
,