Skip to content

Instantly share code, notes, and snippets.

View HeartSaVioR's full-sized avatar
🏠
Working from home

Jungtaek Lim HeartSaVioR

🏠
Working from home
View GitHub Profile
@HeartSaVioR
HeartSaVioR / test-bulk-insert-normal-key.py
Created August 5, 2012 13:41
Redis bulk insert test - normal keys
# -*- encoding: utf-8 -*-
import sys
if len(sys.argv) < 3:
print "usage: %s [start] [end]" % sys.argv[0]
sys.exit(1)
start = int(sys.argv[1])
end = int(sys.argv[2])
@HeartSaVioR
HeartSaVioR / test-bulk-insert-set-key.py
Created August 5, 2012 13:47
Redis bulk insert test - set
# -*- encoding: utf-8 -*-
import sys
#print sys.argv
if len(sys.argv) < 3:
print "usage: %s [start] [end]" % sys.argv[0]
sys.exit(1)
start = int(sys.argv[1])
@HeartSaVioR
HeartSaVioR / test-bulk-insert-hash-key.py
Created August 5, 2012 13:51
Redis bulk insert test - hash
# -*- encoding: utf-8 -*-
import sys
if len(sys.argv) < 3:
print "usage: %s [start] [end]" % sys.argv[0]
sys.exit(1)
start = int(sys.argv[1])
end = int(sys.argv[2])
@HeartSaVioR
HeartSaVioR / redis-in-action-chap1.py
Created October 13, 2012 02:50
Redis in action, chapter 1, StackOverflow mini functionality
#!/usr/bin/python2.6
import redis
import time
import random
ONE_WEEK_IN_SECONDS = 7 * 86400
VOTE_SCORE = 432
ARTICLES_PER_PAGE = 25
@HeartSaVioR
HeartSaVioR / redis-in-action-chap2.py
Created October 13, 2012 09:11
Redis in action, chapter 2
#!/usr/bin/env python2.6
import time
#
# token cookie
#
def check_token(conn, token):
return conn.hget('login:', token)
@HeartSaVioR
HeartSaVioR / JUnitTest.java
Last active December 17, 2015 23:59
JUnit 관련 snippet
import org.junit.Before;
import org.junit.After;
import static org.junit.Assert.*;
import org.junit.Test;
public class JUnitTest {
@Before
public void setUp() throws Exception {
}
@HeartSaVioR
HeartSaVioR / JUnitExceptionTest.java
Last active December 17, 2015 23:59
JUnit : assert Exception
import org.junit.Test;
import org.junit.Rule;
import org.junit.rules.ExpectedException;
public class JUnitExceptionTest {
@Rule
public ExpectedException exception = ExpectedException.none();
@Test
@HeartSaVioR
HeartSaVioR / TestMockito.java
Last active December 18, 2015 00:19
Mockito 사용 예제
package test;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@HeartSaVioR
HeartSaVioR / Model.java
Last active December 18, 2015 00:19
Podam 의 아주 단순한 "생성" 기능을 담은 Snippet 입니다. 더 상세한 설정은 http://home.btconnect.com/jemosAgile//projects/podam/ 를 참고하세요.
package test;
public class Model {
private String hello;
private String world;
public Model() {
}
@HeartSaVioR
HeartSaVioR / GsonObjectMapper.java
Created June 13, 2013 15:20
기본 설정의 Gson 객체를 통해 Model -> JSON 을 변환하게 되면 Model 내 Date 필드의 밀리초 단위가 사라지게 됩니다 (결과적으로 JSON <-> Model 간의 데이터가 일치하지 않게 됩니다) 이를 방지하기 위해, Model -> JSON 변환 시 Date 필드를 밀리초 단위까지 뽑아내도록 포맷을 변경할 수 있습니다 위의 내용은 https://gist.github.com/leviwilson/2495636 를 참고하였습니다
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public class GsonObjectMapper {
public static String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
private Gson gson;
public GsonObjectMapper() {