Skip to content

Instantly share code, notes, and snippets.

public class NamedParamStatement {
public NamedParamStatement(Connection conn, String statementWithNames) throws SQLException {
Pattern findParametersPattern = Pattern.compile("(?<!')(:[\\w]*)(?!')");
Matcher matcher = findParametersPattern.matcher(statementWithNames);
while (matcher.find()) {
fields.add(matcher.group().substring(1));
}
prepStmt = conn.prepareStatement(statementWithNames.replaceAll(findParametersPattern.pattern(), "?"));
}
@ruseel
ruseel / a.clj
Created December 2, 2016 05:25
clj-http로 keep-alive를 이용해서 요청하기
(time (doseq [conn-mgr [(clj-http.conn-mgr/make-reusable-conn-manager {})]]
(dotimes [_ 2]
(clj-http.client/request {:method :get
:url "https://www.valuepotion.com/"
:connection-manager conn-mgr})
nil)))
@ruseel
ruseel / a.clj
Created November 24, 2016 07:30
(defmacro qb [cnt & body]
`(let [s# (System/currentTimeMillis)]
(dotimes [_# ~cnt] ~@body)
(prn (/ (- (System/currentTimeMillis) s#) ~cnt))))
(qb 1e2 (d/pull (d/db conn) '[*] [:bernice.host/domain "localhost"]))
@ruseel
ruseel / scaling.md
Last active October 24, 2016 06:24

가끔씩 무언가를 만들 때면 대체 용량(problem size, latency, throughput) 을 어디까지 처리하도록 하는 것이 좋을까, 내가 처한 상황에서 적절한 것인가 고민스러울 때가 많습니다.

그 부분에 대해서 Jeff Dean이나 Louis Von Ahn 이 말하는 것을 들어본 적이 있는데 대충 기억나는 대로 적어보면, Louis Von Ahn은 한 인터뷰에서 https://www.youtube.com/watch?v=vafLtAoIYoE "학부때 석사과정에서 한 교수님이 사이즈가 커지면 원래 생각하던 거랑 전혀 다른 구조가 필요해. 그리고 그것을 먼저 상상하기는 힘들어. 게다가 사이즈가 작을 때 필요한 구조랑 클 때 필요한 구조랑 전혀 달라. 라는 이야기를 들었을 때 그래도 나는 미리 예상해서 잘 만들 수 있을거야 라고 생각했는데, 몇 년 지나고 나서 보니 그 이야기가 참 맞는 것 같다"고 한 적이 있습니다.

Jeff Dean은 2010년도에 학부생을 상대로 한 강연에서 1998년도부터 2010년까지의 경험을 시간순대로 설명하고 거기서 얻은 정리된 교훈을 알려주는데 여기서도 "디자인을 할 때 ~5x ~50x 에 대해서 고려하는 것은 적절하지만 ~100x 에 대해서는 전혀 다른 구조가 필요하니 그러지 마셈"이라고 이야기 했던 적이 있습니다.

Building Software Systems At Google and Lessons Learned https://www.youtube.com/watch?v=modXC5IWTJI

아마 Jeff Dean이 말하는 ~5x ~50x와 ~100x는 1000만건의 문서를 검색하는 문제를 해결할 때와 10억건의 문서를 처리할 때 아주 다른 아키텍쳐가 필요하다는 말일 겁니다. 그래도 비디오에 여러가지 도움이 되는 말들이 많았습니다. 강추합니다.

@ruseel
ruseel / clojure-logging-level-with-log4j.md
Last active July 17, 2017 13:30
clojure.logging - set to DEBUG level if using log4j
# log4j 
(.setLevel 
  (org.apache.log4j.Logger/getRootLogger) 
  org.apache.log4j.Level/DEBUG)

(.setLevel
     (org.apache.log4j.Logger/getLogger "com.amazonaws")
     org.apache.log4j.Level/ERROR)
@ruseel
ruseel / readme.md
Last active July 17, 2016 02:10
youtube download for iOS offline play.
@ruseel
ruseel / gist:b3a3a2ff29ca09014576b5352aa400a6
Created July 14, 2016 05:43
relational database(rdb) browsing, sql tool
http://dbeauty.sourceforge.net/
dbeauty가 참 멋지게 잘 만든 sql tool 입니다.
@ruseel
ruseel / wishes.md
Last active June 29, 2016 11:03
개발자가 디자이너에게 바라는 바
@ruseel
ruseel / css-pixel.md
Created June 14, 2016 08:49
모바일웹에서의 pixel, hardware pixel, css pixel, point, dp ...

개념을 잡기에 좋았던 글이, 첫째로 여기였는데

  http://blog.fluidui.com/designing-for-mobile-101-pixels-points-and-resolutions/

여기서 pixel이란 single dot 이라는 개념이고 hardware 와 직접 관련된 개념이라는 것, 그리고 points는 iOS에서 사용하는 추상 척도(abstract measurement), density independent pixel는 Android에서 사용하는 추상척도라는 것을 알 수 있었다.

둘째로 iPhone에서 point와 pixel 간의 관계에 대해서 iPhone2G 시절부터 최근까지 잘 정리해 놓은 여기가 어떤 변화가 있었는지 알아보기 좋았다.

@ruseel
ruseel / js_tip.md
Last active June 13, 2016 08:45
(promisify xhr) and (xml parsing in js)

XHR을 쓰는데 Native Promise를 쓰고 싶다. framework를 쓰고 싶은 것은 아니다. 어떻게 하면 좋을까?

http://stackoverflow.com/a/30008115/262425


String으로 XML을 가지고 있다. 어떻게 하면 DOM을 얻을 수 있을까?