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
<!-- 릴리즈시 의존라이브러리 포함 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
@HeartSaVioR
HeartSaVioR / JedisPoolFactoryBean.java
Created June 29, 2013 14:54
JedisPool 의 생성자는 host, port 입력까지는 Config 객체를 받지 않다가, timeout, password, db number 등을 추가로 입력할 때에는 Config 객체를 명시적으로 입력받습니다. Spring 을 통해 JedisPool bean 을 생성할 때, 이런 생성자 전달인자 차이는 bean 생성에 불편하게 작용합니다. 이를 피하기 위해, FactoryBean 을 정의하고 bean 에 설정되는 정보에 맞게 JedisPool 객체를 만들도록 구현하였습니다.
package net.heartsavior.spring.jedis;
import org.apache.commons.pool.impl.GenericObjectPool.Config;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.Protocol;
public class JedisPoolFactoryBean extends AbstractFactoryBean<JedisPool> {
package storm.starter;
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.TopologyBuilder;
import backtype.storm.topology.base.BaseRichBolt;
import urllib
from time import sleep
url_template = "https://m.mypeople.daum.net/img/i1.daumcdn.net/air21.sticker/pc/still_img/sticker_%03d.png"
start_range=0
end_range=1500 # 2013/08/14 last id : 1457
sleep_for_crawl_success = 1
sleep_for_crawl_fail = 2
for sticker_id in range(start_range, end_range+1):
var randomized_words = [ 'anguilliform', 'concenter', 'ciao', 'kyloe', 'psychologize',
'paddywhack', 'misshaping', 'fleshless', 'invigilated', 'jointless',
'circumambulation', 'adown', 'avaunt', 'cachinnate', 'protistan', 'alkanet',
'extravagate', 'ochone', 'ta', 'meristematic', 'keck', 'unremunerative',
'frapping', 'anent', 'concertize', 'bechance', 'nontaxable', 'bhindi', 'olearia',
'transduce', 'humph', 'malamute', 'barhopping', 'triangulate', 'premandibular',
'stodge', 'crankle', 'souk', 'cose', 'ligate', 'brava', 'syne', 'chez', 'biomass',
'blithesome', 'trinomially', 'appetence', 'kindheartedly', 'venge', 'annulation',
'trophallactic', 'semiautomatically', 'particulate', 'valleculate', 'dewan', 'exudation',
'lavolta', 'coze', 'goodby', 'vitrified', 'outpace', 'putaminous', 'orthopteran',
@HeartSaVioR
HeartSaVioR / pipelined_transaction_workaround.java
Last active August 29, 2015 13:56
Jedis pipelined transaction sync() errors workaround
Jedis j = new Jedis(HOSTNAME, PORT);
j.set("foo", "314");
Pipeline p = j.pipelined();
p.multi();
Response<String> r = p.get("foo");
Response<String> multiResp = p.exec();
p.sync();
multiResp.get(); // to achieve r.get()
System.out.println(r.get());
@HeartSaVioR
HeartSaVioR / JedisPubSubTest.java
Last active August 29, 2015 13:56
JedisPubSubTest with Redis Cluster (include node down)
package net.heartsavior.dev;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
package net.heartsavior.dev;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.exceptions.JedisConnectionException;
public class JedisConnectionSuddenlyBrokenTest {
public static void main(String[] args) throws InterruptedException {
Jedis jedis = new Jedis("127.0.0.1", 6379);
@HeartSaVioR
HeartSaVioR / BlpopTest.java
Last active August 29, 2015 14:00
Blpop with forcing waiting thread to interrupt
public class ListCommandsTest extends JedisCommandTestBase {
public void blpopWithForceKill() throws InterruptedException {
Thread th = new Thread(new Runnable() {
@Override
public void run() {
jedis.blpop(100, "foo");
}
});
th.start();
@HeartSaVioR
HeartSaVioR / TestShardedJedisWithMultiThreaded.java
Created June 19, 2014 13:09
Testing ShardedJedisPool with try-with-resource
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedis;
import redis.clients.jedis.ShardedJedisPool;
import redis.clients.jedis.exceptions.JedisConnectionException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;