Skip to content

Instantly share code, notes, and snippets.

Avatar

Sanghyuk Jung benelog

View GitHub Profile
View ConnectionMonitor.java
import static com.sun.btrace.BTraceUtils.*;
import com.sun.btrace.BTraceUtils.Aggregations;
import com.sun.btrace.BTraceUtils.Sys;
import com.sun.btrace.aggregation.Aggregation;
import com.sun.btrace.aggregation.AggregationFunction;
import com.sun.btrace.annotations.BTrace;
import com.sun.btrace.annotations.Duration;
import com.sun.btrace.annotations.Kind;
import com.sun.btrace.annotations.Location;
import com.sun.btrace.annotations.OnEvent;
View gist:1335412
total = 0
for i in range (1,11):
total += pow(i-1,2) + pow(i,2)
print total
View NaverWebClient.java
/*
* @(#)NaverWebClient.java 1.0 2011. 7. 15
*/
package testsupport;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.Cookie;
View header.jsp
<%@ page contentType="text/html; charset=UTF-8" session="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
View fmt.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<fmt:message key="main_hello">
<fmt:param>benelog</fmt:param>
</fmt:message>
@benelog
benelog / LogAspect.java
Created Jan 17, 2012
AspectJ expression Test with Spring 3.1
View LogAspect.java
package edu.tdd.aop;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
@Aspect
public class LogAspect {
private LogRepository repository;
View RankFinder.java
package net.benelog.quiz;
import java.util.ArrayList;
import java.util.List;
public class RankFinder<T extends Comparable<T>> {
private List<T> topValues;
private int rankToFind;
@benelog
benelog / dateEdit.xml
Created Apr 18, 2012
Spring value parsing
View dateEdit.xml
<bean id="dateEditor" class="org.springframework.beans.propertyeditors.CustomDateEditor">
<constructor-arg>
<bean class="java.text.SimpleDateFormat">
<constructor-arg value="yyyy/MM/dd HH:mm:ss" />
</bean>
</constructor-arg>
<constructor-arg value="true" />
</bean>
@benelog
benelog / one-ftpserver.md
Created May 16, 2012
one-ftpserver 설명
View one-ftpserver.md

배경

서버 작업을 하다보면, PC에 있는 파일을 서버에 올리거나, 서버에 있는 로그파일을 PC로 받고 싶을 때가 있습니다. 그런 용도로 저는 다운로드를 할 때는 Winstone을, 업로드를 할 때는 간단한 웹애플리케이션인 만든 Uploader 를 사용합니다.

제 블로그의 아래 포스트를 통해서 그 방법을 설명했었습니다.

또는 파이썬이 설치되어 있아면 'python -m SimpleHTTPServer'를 실행하면 간단한 웹서버를 띄울 수도 있습니다.

View BatchUpdateTest.java
@Test
public void batchUpdateTest(){
SqlParameterSource[] source = new SqlParameterSource[]{new MapSqlParameterSource("id", 1), new MapSqlParameterSource("id", 2),new MapSqlParameterSource("id", 3)};
int[] updated = simpleJdbcTemplate.batchUpdate("update perform set id=:id where id = :id", source);
System.out.println(Arrays.toString(updated));
}