Skip to content

Instantly share code, notes, and snippets.

@eungju
eungju / JsonPropertiesPersister.java
Created October 5, 2011 02:48
JsonPropertiesPersister for Spring
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@eungju
eungju / binary-response.patch
Created October 31, 2011 02:56
A patch for the binary response body decoding problem
diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor
index 7f99c62..8d1b996 100644
--- a/basis/http/client/client.factor
+++ b/basis/http/client/client.factor
@@ -162,7 +162,8 @@ ERROR: download-failed response ;
: http-request ( request -- response data )
[ [ % ] with-http-request ] B{ } make
- over content-encoding>> decode check-response-with-body ;
+ over content-encoding>> dup binary = [ drop ] [ decode ] if
@eungju
eungju / gist:1789606
Created February 10, 2012 13:13
test.html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<body id="container">
<script type="text/javascript">
function drawPaths(canvas) {
var ctx = canvas.getContext('2d');
ctx.rect(0, 0, 256, 256);
ctx.fillStyle = "#FFFFFF";
ctx.fill();
ctx.strokeStyle = "#FF0000";
@eungju
eungju / skia-macosx-x86_64.patch
Created March 16, 2012 10:56
Skia Mac OS X 64 patch
Index: src/ports/SkFontHost_mac_coretext.cpp
===================================================================
--- src/ports/SkFontHost_mac_coretext.cpp (revision 3410)
+++ src/ports/SkFontHost_mac_coretext.cpp (working copy)
@@ -1948,7 +1948,7 @@
int count = CFArrayGetCount(cfArray);
if (tags) {
for (int i = 0; i < count; ++i) {
- tags[i] = (SkFontTableTag)CFArrayGetValueAtIndex(cfArray, i);
+ tags[i] = (SkFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(cfArray, i);
@eungju
eungju / gist:2352121
Created April 10, 2012 15:26
수익율계산
: standard-deposit ( a r t -- a ) swap 1 + swap ^ * ;
: regular-deposit ( a r n t -- a ) over [ / ] [ * ] 2bi* iota [ 2over rot 1 + standard-deposit ] map sum 2nip ;
@eungju
eungju / p1_2.erl
Created August 31, 2012 07:31
문제로 풀어보는 알고리즘 149쪽 문제 3.c 풀이
-module(p1_2).
-compile(export_all).
s([_]=L) ->
[[L]];
s([A|L]) ->
S = s(L),
lists:append([lists:map(fun(X) -> [[A]|X] end, S)|lists:map(fun(X) -> each_append(A,X) end, S)]).
each_append(_, [], _, Acc) ->
@eungju
eungju / p1_3.erl
Created September 5, 2012 10:55
코딩 인터뷰 완전 분석 210쪽 17.3 변형 문제 풀이
-module(p1_3).
-compile(export_all).
-include_lib("eunit/include/eunit.hrl").
% 주어진 자연수 n의 팩토리얼을 구해서 마지막에 붙은 연속된 0의 개수와 연속된 0 바로 앞에 나오는 숫자를 구하는 문제이다. 우선 문제 설명대로 팩토리얼을 구하고 마지막 연속된 0의 갯수를 세고, 마지막 연속된 0을 제외한 마지막 자리수를 구한다.
% 팩토리얼을 구한다.
factorial(1, Acc) ->
Acc;
@eungju
eungju / p2_2.erl
Created September 14, 2012 14:19
코딩 인터뷰 완전 분석 215쪽 문제 18.10 풀이
-module(p2_2).
-compile(export_all).
-include_lib("eunit/include/eunit.hrl").
% 두 단어가 주어지면 첫 단어를 한 번에 한 문자씩만 다른 단어로 바꾸는 것을 반복하여 두 번째 단어를 만드는 과정을 출력하는 문제이다. 입력으로는 사전 파일과 단어 두 개가 주어진다.
% 우선 사전 파일에서 단어를 읽는다.
read_words(FileName) ->
{ok, Device} = file:open(FileName, [read]),
@eungju
eungju / StaticResources.java
Created November 16, 2012 09:15
Servlet Assets Helper
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletContext;
import com.google.common.base.Preconditions;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.hash.HashFunction;
@eungju
eungju / README.md
Created November 25, 2012 08:17
LivePreview: watchr + Chrome LivePage Extension

LivePreview: watchr + Chrome LivePage Extension

마크업 언어로 문서를 작성할 때 HTML로 변환한 결과를 바로 확인하고 싶을 때가 많다. Mou, Marked 등 이런 문제를 해결해주는 도구가 있지만 대부분 맥에서만 쓸 수 있고, 문서 처리 과정을 완전히 통제하지 못하는 등 다른 제약들도 있다. watchr과 크롬 LivePage를 이용하면 이 문제를 간편하게 해결할 수 있어서 소개한다.

watchr

watchr은 특정 파일이 변경됐을 때 어떤 동작을 취하도록 프로그램할 수 있다. 주로 Continous Testing 도구로 사용되지만, 파일 변경에 따른 처리 결과를 빠르게 알고 싶은 모든 경우에 아주 유용하다. 루비 gem으로 간단하게 설치할 수 있다.

$ gem install watchr