반응형

저녁 먹으러 다녀온 사이에 컴퓨터가 재부팅 되어 있고, STS를 실행시켜도 컴퓨터에 아무런 반응이 없었습니다.

정말 아무 창이나 경고도 없이 '무반응' 이었습니다.


해결방법은 STS.ini 파일을 열어서 아래 처럼 빨간색 2줄을 추가합니다.

아마 자바 환경설정에 변화가 있었던 것 같습니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-startup
plugins/org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.401.v20161122-1740
-product
org.springsource.sts.ide
--launcher.defaultAction
openFile
-vm
C:\Program Files\Java\jdk1.8.0_144\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Xms1200m
-Dosgi.module.lock.timeout=10
-Xverify:none
-Dorg.eclipse.swt.browser.IEVersion=10001
-Xmx1200m
 



반응형
반응형

엑셀에서 날짜를 텍스트로 변환하면 이상한 숫자가 나오게 됩니다.

날짜 형식의 테이터를 순수한 텍스트로 변환 하려면 Text 함수를 이용해야 합니다.

=Text(A1, "yyyy-mm-dd")

반응형
반응형

현재 작업중인 네트워크의 outbound port 방화벽을 확인해야하는 경우가 있습니다.

이 때, 해당 포트가 열려있는 서버가 있으면 telnet 명령어나 'java-telnet-대신-포트-방화벽-확인하기' 를 이용해서 해당 IP PORT를 찔러보면 바로 알 수 있습니다.

하지만, 해당 포트를 리슨하고 있는 서버가 없을 경우 확인해 볼 방법이 없습니다.

이런 경우 아래 간단한 java 소스를 통해서 서버에서 원하는 포트를 Listen하고 있도록 만들 수 있습니다.


컴파일 : javac PortListen.java

실행 : java PortListen [포트번호] 

1
2
3
4
5
6
7
8
9
10
11
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
 
public class PortListen {
  public static void main(String[] args) throws IOException {
    ServerSocket serverSocket = new ServerSocket(Integer.parseInt(args[0]));
    Socket socket = serverSocket.accept();
  }
}
 



실행 후 해당 포트가 Listen 중인지 확인하는 방법 입니다.

리눅스 : netstat -an|grep 포트번호

윈도우 : netstat -an|findstr 포트번호


더 이상 방화벽이 열린 건지 아닌 건지 헤매지 맙시다.

반응형
반응형

엑셀을 이용하다보면 어떠한 이유에서인지는 알수 없지만 갑자기 '파일이 손상되어 열 수 없습니다.' 라는 메시지가 뜨면서 작업된 파일들을 열 수가 없는 사태가 발생하곤 합니다.


이 때, 실제로 파일이 손상되거나 파일권한문제 윈도우 계정의 권한 문제등을 제외하고는 아래 방법으로 해결이 가능합니다.


1. 엑셀 파일을 열지말고 엑셀 프로그램을 실행합니다. 

 - 시작 버튼을 눌러서 엑셀을 찾아서 열거나

 - 윈도우키+R 누른 후 excel 엔터 하셔도 됩니다.


2. 엑셀이 열리면 아래 캡쳐이미지 처럼 상단의 파일 메뉴를 클릭하며 나오는 메뉴에서 2번 옵션을 메뉴를 클릭합니다.


2. 그러면 아래처럼 화면이 나오는데 1번 '보안센터'를 클릭 후 2번 '보안 센터 설정' 을 클릭 합니다.


3. 그러면 아래 화면이 나옵니다. 여기서 1번 '제한된 보기'를 클릭 후 2번 처럼 체크박스를 모두 '해제' 합니다. 그리고 3번 '확인'을 클릭합니다.


4. 이제 엑셀을 닫고 열리지 않았던 엑셀 파일을 다시 열어 봅니다.


5. 그래도 안되면 '여기' 를 참조하세요.


반응형
반응형

/dev/random

위키의 정의 : 유닉스 계열 운영 체제에서 차단 방식의 유사난수 발생기의 역할을 수행하는 특수 파일이다. 장치 드라이버와 기타 소스로부터 모은 환경적 노이즈로의 접근을 허용한다.


/dev/urandom 도 /dev/random 과 동일한 방식으로 난수를 생성하지만 다른 점은 아래와 같다고 합니다.

urandom이 random보다 난수를 대충만들어서 속도는 더 빠르지만 훌륭한 난수는 되지 못한다. 뭐 대충 이런 내용입니다.

urandom이 예측하기 쉬운 난수가 만들어질 수 있어서 보안에 취약해 질수 있다고는 하지만,

예측하기 쉬운 난수가 만들어지는 OS  환경이라면 random의 경우 매우 느려지거나 아예 락이 걸려서 난수를 생성하지 못할 수 있다고 하니 어떤 녀석을 써야할까요?

If you want random data in a Linux/Unix type OS, the standard way to do so is to use /dev/random or /dev/urandom. These devices are special files. They can be read like normal files and the read data is generated via multiple sources of entropy in the system which provide the randomness.


/dev/random will block after the entropy pool is exhausted. It will remain blocked until additional data has been collected from the sources of entropy that are available. This can slow down random data generation.


/dev/urandom will not block. Instead it will reuse the internal pool to produce more pseudo-random bits.


/dev/urandom is best used when:


You just want a large file with random data for some kind of testing.

You are using the dd command to wipe data off a disk by replacing it with random data.

Almost everywhere else where you don’t have a really good reason to use /dev/random instead.

/dev/random is likely to be the better choice when:


Randomness is critical to the security of cryptography in your application – one-time pads, key generation.


참고 : ora11g jdbc connection reset 


반응형
반응형


소스트리가 실행되는데 'Pull' 을 실행 했더니 "git-remote-https.exe 시작 지점 없음" 오류가 뜨면서 실행되지 않습니다.


아래와 같이 했더니 해결이 됩니다.


1. C:\Users\사용자\AppData\Local\Atlassian\SourceTree\git_local\mingw32\bin 이동


2. dll 파일들만 복사


3. C:\Users\사용자\AppData\Local\Atlassian\SourceTree\git_local\mingw32\libexec\git-core 이동


4. 붙여넣기


5. 재시작




반응형
반응형

Spring boot 이용해서 Scheduler 를 작업할 때, 부분적인 단위 테스트를 하기가 어렵습니다.


내가 원하는 Job만 선택적으로 실행할 수 있는 테스트 코드입니다.


도움이 되시길 바랍니다.


-- SearchScheduler --

1
2
3
4
5
6
7
8
@Component
public class SearchScheduler {
 
  @Scheduled(fixedDelay = 3000)
  public void searchTest() {
 
  }
}


-- StatScheduler --

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
@Component
public class StatScheduler {
  private static Logger prettyLogger = LoggerFactory.getLogger(Constants.PRETTY_LOGGER_NAME);
 
  // cron 문법 참조
  // http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger
  @Scheduled(cron = "*/3 * * * * *")
  public void test3() {
    PrettyLog prettyLog = new PrettyLogImpl("StatScheduler.test3-클래스명.메서드명");
    // TODO
    prettyLog.stop();
    prettyLogger.info(prettyLog.prettyPrint());
  }
 
  @Scheduled(cron = "* * * * * *")
  public void test1() {
    PrettyLog prettyLog = new PrettyLogImpl("StatScheduler.test1");
    prettyLog.append("When""1초마다 돌지요");
    prettyLog.stop();
    prettyLogger.info(prettyLog.prettyPrint());
  }
}



-- 테스트 코드 --

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
 
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
 
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.CronTask;
import org.springframework.scheduling.config.IntervalTask;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.ScheduledMethodRunnable;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
 
 
@RunWith(SpringRunner.class)
@SpringBootTest
public class StatSchedulerTest {
 
  @Test
  public void test() {
    PrettyLog prettyLog = new PrettyLogImpl("test");
    try {
      TimeUnit.SECONDS.sleep(10);
    } catch (Exception e) {
      if (e != null) {
        prettyLog.append("ERROR", e.toString());
      }
      e.printStackTrace();
    } finally {
      prettyLog.stop();
      System.out.println(prettyLog.prettyPrint());
    }
  }
 
  @TestConfiguration
  static class SchedulingTestConfig implements SchedulingConfigurer {
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
      PrettyLog prettyLog = new PrettyLogImpl("SchedulingTestConfig");
      List<IntervalTask> taskList = taskRegistrar.getFixedDelayTaskList();
      List<CronTask> cronTaskList = taskRegistrar.getCronTaskList();
      List<IntervalTask> newTaskList = new ArrayList<>();
      List<CronTask> newCronTaskList = new ArrayList<>();
 
      prettyLog.start("IntervalTask");
      for (IntervalTask task : taskList) {
        ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
        String methodName = runnable.getMethod().getName();
        Object target = runnable.getTarget();
 
        if (target instanceof SearchScheduler) {
          if (methodName.equals("searchTest")) {
            prettyLog.append("method",
                target.getClass().getSimpleName() + "." + methodName + "(" + task.getInterval() + "ms)");
            newTaskList.add(new IntervalTask(runnable, task.getInterval(), task.getInitialDelay()));
          }
        }
      }
      prettyLog.stop();
 
      prettyLog.start("CronTask");
      for (CronTask task : cronTaskList) {
        ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
        Method method = runnable.getMethod();
        String methodName = method.getName();
        Object target = runnable.getTarget();
        if (target instanceof StatScheduler) {
          if (methodName.equals("test1")) {
            prettyLog.append("method",
                target.getClass().getSimpleName() + "." + methodName + "(" + task.getExpression() + ")");
            newCronTaskList.add(new CronTask(runnable, task.getExpression()));
          }
        }
      }
      prettyLog.stop();
 
      taskRegistrar.setFixedDelayTasksList(newTaskList);
      taskRegistrar.setCronTasksList(newCronTaskList);
      prettyLog.stop();
      System.out.println(prettyLog.prettyPrint());
    }
  }
}




-- 설정 부분 로그 --


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+---------------------------------------------------
|START                : 2037-09-19 04:54:33,195
|ID                   : SchedulingTestConfig
| +---------------------------------------------------
| |START                : 2037-09-19 04:54:33,196
| |ID                   : IntervalTask
| |method               : SearchScheduler.searchTest(3000ms)
| |ELAPSED              : 0 ms
| +---------------------------------------------------
| +---------------------------------------------------
| |START                : 2037-09-19 04:54:33,201
| |ID                   : CronTask
| |method               : StatScheduler.test1(* * * * * *)
| |ELAPSED              : 0 ms
| +---------------------------------------------------
|ELAPSED              : 13 ms
+---------------------------------------------------
cs


반응형
반응형

Netty 4.0 이전 버전과 이후 버전의 가장 큰 차이점 입니다.

참고하세요.


IoBuffervsChannelBuffer
get()readByte()
get(byte[])readBytes(byte[])
remaining()readableBytes()
put(byte[])writeBytes(byte[])
put(byte)writeByte(byte)
flip()resetReaderIndex() 
allocate(int)ChannelBuffers.buffer(int)
setAutoExpanddynamicBuffer
skip(int)skipBytes(int)
position()readerIndex()


반응형
반응형

행으로 나오는 쿼리 결과를 열로 합쳐서 보고 싶을 경우 오라클에서는 LISTAGG 함수를 이용하면 행렬 피벗을 할 수 있습니다.


1
2
3
4
5
6
7
8
-- table for our logging
create table log_table
  id varchar2(10),
  message varchar2(200)
)
//
 



아래 쿼리 처럼 이용하시면 됩니다.


1
2
3
4
5
6
7
8
9
10
11
insert into log_table (id, message) values ('goni''hi');
insert into log_table (id, message) values ('goni''hello');
insert into log_table (id, message) values ('goni''ok');
insert into log_table (id, message) values ('goni''good');
 
 
SELECT
    id, LISTAGG(message, ',') within group (order by message) message
FROM
    log_table
group by id;



결과 값


IDMESSAGE
gonigood,hello,hi,ok



http://sqlfiddle.com/#!4/b62beb/18/4  <===여기서 바로 확인해 볼 수 있습니다 !! 

반응형
반응형

가끔 개발환경이 구축되지 않은 곳에서 쿼리 테스트를 해야하는 경우가 있습니다.

이럴 때 유용한 사이트를 소개합니다.


URL : http://sqlfiddle.com/



처음 접속하면 아래와 같은 화면이 나옵니다.


1번을 클릭하면 DB 종류를 선택할 수 있습니다.


2번을 클릭하면 아래 화면처럼 샘플 코드를 만들어 줍니다.





아래 화면의 


1번을 클릭하면 테이블이나 프로시져 등을 생성할 수 있습니다.

2번을 클릭하면 조회, 수정, 삭제, 입력, 프로시져 실행등이 가능 합니다.




신기한 사이트가 정말 많군요 @.@


반응형

+ Recent posts