Skip to content

Instantly share code, notes, and snippets.

@need4spd
need4spd / TestPool.java
Last active February 13, 2019 14:21
TestPool
import org.apache.commons.pool2.impl.GenericObjectPool;
public class TestPool {
public static void main(String[] args) throws Exception {
for(int i = 0; i < 10; i++) {
GenericObjectPool genericObjectPool = new GenericObjectPool(new MyPoolableObjectFactory());
MyPoolableObject obj = (MyPoolableObject)genericObjectPool.borrowObject();
System.out.println("i : " + i);
@need4spd
need4spd / MyPoolableObjectFactory.java
Created February 13, 2019 14:20
MyPoolableObjectFactory
import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
public class MyPoolableObjectFactory extends BasePooledObjectFactory<MyPoolableObject> {
@Override
public MyPoolableObject create() {
return new MyPoolableObject();
@need4spd
need4spd / MyPoolableObject.java
Created February 13, 2019 14:19
MyPoolableObject
public class MyPoolableObject {
private static int id = 0;
public MyPoolableObject() { id++; }
public int getId() { return id; }
}
@need4spd
need4spd / Test.java
Created February 13, 2019 13:48
Callable and Future sample
import java.util.concurrent.*;
public class FutureAndCallableExample {
public static void main(String[] args) throws InterruptedException, ExecutionException {
System.out.println("Main : " + Thread.currentThread().getName());
ExecutorService executorService = Executors.newSingleThreadExecutor();
Callable<String> callable = () -> {
System.out.println("Entered Callable");
find . -name build | xargs rm -rf
@need4spd
need4spd / ubunt.txt
Last active January 5, 2016 11:16
Ubuntu and software
-- create install usb on OSX
http://computers.tutsplus.com/tutorials/how-to-create-a-bootable-ubuntu-usb-drive-for-pc-on-a-mac--cms-21187
http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-mac-osx
-- 한영전환
http://blog.daum.net/bagjunggyu/154
-- install vmware horizon client
http://vdisage.blogspot.kr/2015/01/installing-horizon-view-320-client-on.html
// create file:
sudo vim /usr/share/applications/intellij.desktop
// add the following
[Desktop Entry]
Version=13.0
Type=Application
Terminal=false
Icon[en_US]=/home/rob/.intellij-13/bin/idea.png
Name[en_US]=IntelliJ
@need4spd
need4spd / Listest.java
Last active August 29, 2015 14:07
List Test
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import lombok.Data;
import org.junit.Before;
import org.junit.Test;
import javax.annotation.Nullable;
import java.util.List;
@need4spd
need4spd / jpastudy
Created June 11, 2014 00:44
JPA Study - Chapter 2
1. Obtaining an Entity Manager and Persisting an Entity
EntityManagerFactory emf = Persistence.createEntityManagerFactory("EmployeeService");
EntityManager em = emf.createEntityManager();
Employee emp = new Employee(130);
em.persist(emp);
persist가 완료되면 emp 객체는 entity manager의 persistence context에의해 관리된다.
2. Finding an Entity
Employee emp = em.find(Employee.class, 130);
@need4spd
need4spd / DateTime.java
Last active August 29, 2015 14:01
Joda DateTime parse
//String to DateTime
//05/28/2014 11:31
DateTimeFormatter fmt = DateTimeFormat.forPattern("MM/dd/yyyy HH:mm");
fmt.parseDateTime("05/28/2014 11:31");
//Date to String
DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm");
String sqlTimeString = fmt.print(DateTime.now());