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() {