getViewport = function() {
var $w = $(window);
return {
l: $w.scrollLeft(),
t: $w.scrollTop(),
w: $w.width(),
h: $w.height()
}
}
参考リンク
http://stackoverflow.com/questions/10324753/jquery-function-to-get-the-curren-viewport
2014年11月7日金曜日
d3でcssのクラスを複数追加するには
d3.selectAll(".someDiv").attr("test1 test2");
参考リンク
http://stackoverflow.com/questions/13188125/d3-add-multiple-classes-with-function
参考リンク
http://stackoverflow.com/questions/13188125/d3-add-multiple-classes-with-function
MavenでWeb Applicationプロジェクトの作成方法
1.mvnコマンドで以下をEclipseのworkspaceで実行
$ mvn archetype:generate -DgroupId=com.test
-DartifactId=TestApp
-DarchetypeArtifactId=maven-archetype-webapp
-DinteractiveMode=false
2.WTPプロジェクトに変換
$ mvn eclipse:eclipse -Dwtpversion=2.0
3.pom.xml、web.xmlを自分用に編集していく
参考リンク
http://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/
$ mvn archetype:generate -DgroupId=com.test
-DartifactId=TestApp
-DarchetypeArtifactId=maven-archetype-webapp
-DinteractiveMode=false
2.WTPプロジェクトに変換
$ mvn eclipse:eclipse -Dwtpversion=2.0
3.pom.xml、web.xmlを自分用に編集していく
参考リンク
http://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/
ラベル:
Eclipse WTP,
Maven,
Spring MVC
Spring MVCでreCaptchaを使うには?
1.GoogleでreCaptchを使用するのに必要なプライベートキー、パブリックキーを取得。
http://www.google.com/recaptcha
2.pom.xmlに追加。
3.JSPでタグを追加。
4.コントローラー(サーブレット)でのパラメータと認証。
参考リンク
http://www.javacodegeeks.com/2012/11/use-recaptcha-in-a-spring-mvc-web-application.html
https://code.google.com/p/recaptcha/wiki/HowToSetUpRecaptcha#Java/JSP
http://www.google.com/recaptcha
2.pom.xmlに追加。
<dependency>
<groupId>net.tanesha.recaptcha4j<groupId>
<artifactId>recaptcha4j<artifactId>
<version>0.0.7<version>
<dependency>
3.JSPでタグを追加。
<tags:captcha privateKey='XXXX' publicKey='YYYY'><tags:captcha>
4.コントローラー(サーブレット)でのパラメータと認証。
@RequestMapping(value='', method=RequestMethod.POST)
public String submitForm(@ModelAttribute('userInfo') UserInfo userInfo, @RequestParam('recaptcha_challenge_field') String challangeField, @RequestParam('recaptcha_response_field') String responseField, ServletRequest servletRequest) {
String remoteAddress = servletRequest.getRemoteAddr();
ReCaptchaResponse reCaptchaResponse = this.reCaptcha.checkAnswer(remoteAddress, challangeField, responseField);
if(reCaptchaResponse.isValid()) {
return 'success';
} else {
return 'fail';
}
}
参考リンク
http://www.javacodegeeks.com/2012/11/use-recaptcha-in-a-spring-mvc-web-application.html
https://code.google.com/p/recaptcha/wiki/HowToSetUpRecaptcha#Java/JSP
2014年10月14日火曜日
Tomcatでベーシック認証
tomcat-users.xml
<tomcat-users>
<role rolename="aaaa" />
<user username="bbb" password="ccc" roles="aaaa" />
</tomcat-users>
web.xml
<web-app>
<security-constraint>
<web-resource-collection>
<web-resource-name>
Authentication of BasicAuth
</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>basic</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ProtectedRealm</realm-name>
</login-config>
</web-app>
参考リンク
http://www.javaroad.jp/opensource/js_tomcat9.htm
http://www.coderanch.com/t/465990/java-Web-Component-SCWCD/certification/HTTP-Status-Access-requested-resource
<tomcat-users>
<role rolename="aaaa" />
<user username="bbb" password="ccc" roles="aaaa" />
</tomcat-users>
web.xml
<web-app>
<security-constraint>
<web-resource-collection>
<web-resource-name>
Authentication of BasicAuth
</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>basic</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ProtectedRealm</realm-name>
</login-config>
</web-app>
参考リンク
http://www.javaroad.jp/opensource/js_tomcat9.htm
http://www.coderanch.com/t/465990/java-Web-Component-SCWCD/certification/HTTP-Status-Access-requested-resource
2014年10月8日水曜日
JavaMailでsmtp-authでメールを送信する方法
Properties props = new Properties();
props.put("mail.transport.protocol", "smtp"); <----25か587のサブミッションポートでもok
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.auth", "true")
Authenticator auth = new SMTPAuthenticator();
Session mailSession = Session.getDefaultInstance(props, auth);
// パスワード認証のプライベートクラス
private class SMTPAuthenticator extends javax.mail.Authenticator {
public PasswordAuthentication getPasswordAuthentication() {
String username = SMTP_AUTH_USER;
String password = SMTP_AUTH_PWD;
return new PasswordAuthentication(username, password);
}
}
http://www.rgagnon.com/javadetails/java-0538.html
2014年10月4日土曜日
Postfixで587のサブミッションポートでsmtp-auth設定をした上で、25ポートでのsmtp-authをさせないように設定するには。
Postfixで587のサブミッションポートでsmtp-auth設定をした上で、25ポートでのsmtp-authをさせないように設定するには、/etc/postfix/master.cfを以下のように編集。
smtp inet n - - - - smtpd
-o smtpd_sasl_auth_enable=no <---------- ここをno
submission inet n - - - - smtpd
-o smtpd_sasl_auth_enable=yes <---------- ここをyes
参考リンク:
登録:
投稿 (Atom)