본문 바로가기

전체 글155

Klaytn 블록체인 애플리케이션 만들기 예제 Klaytn 블록체인 애플리케이션 예제 Klaytn 테스트넷 Baobab에 간단한 블록체인 애플리케이션을 만들어보는 예제 덧셈 예제 프로젝트로 주어진 시간 안에 덧셈 문제의 정답을 맞추면 클레이를 지급 받는다. 예제 프로젝트는 인프런 강의를 학습하고 정리한 것입니다. 자세한 설명은 인프런 강의를 참고해주세요. 개발 환경 설정 Node.js 설치 npm install Install Truffle sudo npm install -g truffle@4.1.15 Git 설치 Visual Studio Code 설치 소스코드 가져오기 git clone https://github.com/jayden-lee/klaytn-example.git Baobab 테스트넷 계정 생성 Klaytn TestNet에서 계정을 생성한다.. 2019. 7. 25.
Thymeleaf 에서 현재 로케일 값 출력하기 쿠키값에 따라 로케일 해석 CookieLocaleResolver 클래스는 사용자 브라우저의 쿠키값에 따라 로케일을 해석한다. 해당 쿠키가 없으면, accept-language 헤더로 기본 로케일을 설정한다. LocaleChangeInterceptor 클래스는 Http 요청에 특정한 매개변수 값이 존재하는지 확인하고, 해당 값으로 사용자 로케일을 변경한다. @Configuration public class WebMvcConfiguration implements WebMvcConfigurer { private static final Locale DEFAULT_LOCALE = new Locale("en"); @Override public void addInterceptors(InterceptorRegistry.. 2019. 7. 25.
JDBC 드라이버에서 MySQL 데이터베이스 문자 인코딩 설정 JDBC 드라이버를 이용해서 MySQL 데이터베이스에 연결할 때, 프로퍼티에 따로 값을 설정하지 않으면 문자 인코딩(characterEncoding) 값은 자동으로 감지합니다. 연결 프로퍼티에 문자 인코딩 설정 Properties properties = new Properties(); properties.put("user", "USER_NAME"); properties.put("password", "PASSWORD"); properties.put("characterEncoding", "UTF-8"); Connection connection = DriverManager.getConnection("JDBC_URL", properties); MySQL to Java Encoding Name Translatio.. 2019. 6. 23.
데이터 암호화를 위한 JPA Attribute Converter User 클래스에서 juminNumber 속성 값을 테이블에 저장할 때 암호화하는 예제입니다. User Entity 생성 @Entity @Table(name = "USER") @DynamicInsert @DynamicUpdate @Getter public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(name = "NAME", length = 50, nullable = false) private String name; @Column(name = "JUMIN_NUMBER", length = 100, nullable = false) @Convert(converter = StringCryp.. 2019. 6. 10.
Python 리스트 크기 구하기 listA = [1,2,3,4,5] listB = [6,7,8] listC = listA + listB size = len(listC) print(size) 2019. 6. 7.
Python 두 개의 리스트 합치기 listA = [1,2,3,4,5] listB = [6,7,8] listC = listA + listB print(listC) 2019. 6. 7.
Python에서는 &&, || 연산자 대신 and, or 사용 Python 논리연산자는 and, or 이다. 논리연산자의 경우에 두 개 이상의 조건식을 조합하여 표현할 때 주로 사용한다. and 논리 연산자 if i in dictA and i in dictB: print('i 값이 dictA와 dictB 딕셔너리에 키 값으로 존재합니다.'); or 논리 연산자 if i in dictA or i in dictB: print('i 값이 dictA 또는 dictB 딕셔너리에 키 값으로 존재합니다.'); 2019. 6. 7.
Python에서 printf 함수처럼 print 함수 사용하는 방법 % 스타일 포맷팅 print("%d %s" % (10000, 'lelecoder'), end='') {} 스타일 포맷팅 print("number={0}, name={1}".format(10000, 'lelecoder')) 2019. 6. 6.
리팩토링 - 객체 간의 기능 이동 메서드 이동 (Move Method) 메서드가 자신의 클래스에 있는 기능보다 다른 클래스의 기능을 더 많이 사용하는 경우에 메서드가 많이 사용하는 클래스에 비슷한 내용의 새 메서드를 작성하자. 기존 메서드는 대리 메서드로 전환 또는 삭제하자. 수정전 코드 class Account { private AccountType type; private int daysOverdrawn; double overdraftCharge() { if (type.isPremium()) { double result = 10; if (daysOverdrawn > 7) { result += (daysOverdrawn - 7) * 0.85; } return result; } else { return daysOverdrawn * 1.7.. 2019. 6. 6.