Skip to content

Instantly share code, notes, and snippets.

View moriya9n's full-sized avatar

Seiji MORIYA moriya9n

View GitHub Profile
@moriya9n
moriya9n / gist:790ef652bafe95d2d7d5ab94b5301a4d
Created January 19, 2018 05:22
spring-framework 日付欄に空白を許可
// 日付欄に空白を許可
// https://stackoverflow.com/questions/4806033/converting-empty-string-to-null-date-object-with-spring
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
@moriya9n
moriya9n / gist:2b56a09b9c1b40e530b22133fa7d1974
Last active January 19, 2018 05:38
Java 関連でよく見るリファレンス
JSP/JSTL (よくまとまってる)
http://struts.wasureppoi.com/jstl/00_jstl.html
Spring Framework (ver4)
https://docs.spring.io/spring/docs/4.3.13.RELEASE/spring-framework-reference/htmlsingle/
Spring Security
https://docs.spring.io/spring-security/site/docs/4.2.3.RELEASE/reference/htmlsingle/
Validator 関連
@moriya9n
moriya9n / gist:c49afce1d72113feab68b4311319977a
Last active January 19, 2018 06:35
spring web null skip validation
あってるかどうか知らん
stackoverflow かどこかで見つけたやつ?
空欄のときに validation をスキップさせたい時に使った。
@InitBinder
public void initBinder(WebDataBinder binder) {
// 入力値が空の場合は null をセットしてバリデータをスキップする
binder.registerCustomEditor(String.class, "field_name", new StringTrimmerEditor(true));
}
考え方(私見)
Javascriptを多用するページには合わないかもしれないが。。。
作成、表示、更新、削除(CRUD)
URL
http[s]://なんたらかんたら/id
GET http[s]://なんたらかんたら/new
GET http[s]://なんたらかんたら/id
https://stackoverflow.com/questions/2751603/how-to-get-error-text-in-controller-from-bindingresult
@moriya9n
moriya9n / gist:69e38ad7c09a70fb0b2691f68741a9b3
Created January 22, 2018 06:55
spring / static メソッドから MessageSource などにアクセスする
class 何かのクラス implements xxxAware {
public static 型 なんちゃらメソッド();
}
xxx には ApplicationContext / Environment / MessageSource など
@moriya9n
moriya9n / awsmonero.md
Last active April 29, 2018 01:40
aws monero cpu mining on spot instance without installation
#!/usr/bin/env python
import requests
import csv
# list
r = requests.get('https://www.mizuhobank.co.jp/retail/takarakuji/loto/loto6/csv/loto6.csv')
r.encoding='cp932'
loto6_list = [i[1:5] for i in r.text.splitlines() if i.startswith('第')]
@moriya9n
moriya9n / loto6_latest.py
Last active May 5, 2018 04:20
loto6 最新
#!/usr/bin/env python
import requests
import csv
# list
r = requests.get('https://www.mizuhobank.co.jp/retail/takarakuji/loto/loto6/csv/loto6.csv')
r.encoding='cp932'
loto6_list = [i[1:5] for i in r.text.splitlines() if i.startswith('第')]
@moriya9n
moriya9n / gist:d0317ee7545083252518f9570bb562be
Last active May 14, 2018 01:29
しょうもないTIPS: 英語版のwindows serverでopenjdk+tomcatを立ち上げる時に日本語関係で悩まされないための設定
setenv.bat に以下のように書いて、startup.bat を実行する。
JAVA_OPTS=の後ろには "" 不要。
set JAVA_OPTS=-Duser.language=ja -Duser.country=JP -Dspring.profiles.active=dev -Dfile.encoding=UTF-8