Skip to content

Instantly share code, notes, and snippets.

@yusuke2255
yusuke2255 / build.gradle
Last active Aug 23, 2017
Jmockit + gradle test
View build.gradle
configurations { jmockit }
dependencies {
jmockit ('com.googlecode.jmockit:jmockit:1.7')
testCompile ('junit:junit:4.11')
}
test {
// jmockitがjunitよりも前にclasspathが通ってる必要があるので下記の対応を行っています
View gist:5eb3b439410c99b28dd1517f4167cfc7
https://beroux.com/english/articles/kubernetes/?part=3
@yusuke2255
yusuke2255 / HogeController.java
Last active Dec 20, 2015
Spring3.2でJsonを返すコントローラを作成。(servlet3.0でweb.xmlは使わなかったバージョン)
View HogeController.java
package jp.test.hoge.controller;
import jp.test.hoge.model.HogeModel;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HogeController {
View jstemplate-sample.js
var myJson1 = {title:"タイトル_1_ですよ。",detail:"このデータはlistデータを持ってるのです。",list:[{listTitle:"1個目なのです",attrChecked:true,attrName:"name_1"},{listTitle:"2個目なのです",attrChecked:false,attrName:"name_2"}]};
var myJson2 = {title:"タイトル_2_ですよ。",detail:"このデータはlistデータを持ってないのです。"};
function showTitle(title) {
alert(title);
};
function setTemplateData(type) {
// テンプレートの取得
var t = jstGetTemplate('template');
@yusuke2255
yusuke2255 / ReduceTest.java
Created Aug 5, 2015
[Java8] Stream reduce sample
View ReduceTest.java
import java.util.Arrays;
import java.util.Optional;
public class ReduceTest {
public static void main(String[] args) {
Optional<Sum> summary = Arrays.asList(new Sum(1, 10),new Sum(2, 15),new Sum(3, 5)).stream().reduce((sum1,sum2) -> {
if (Optional.ofNullable(sum1).isPresent() == false) {
System.out.println("Sum1 is empty.");
return sum2;
@yusuke2255
yusuke2255 / file0.java
Created May 5, 2015
【メモ】Dropwizardで複数のデータベース(HibernateBundle)を使う ref: http://qiita.com/Kawata/items/872368226388204b02b3
View file0.java
package jp.hoge;
import java.util.HashMap;
import java.util.Map;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonProperty;
@yusuke2255
yusuke2255 / build.gradle
Created Mar 20, 2015
【メモ】DropwizardでCookieのsession idで認証してみる ref: http://qiita.com/Kawata/items/2e8453ac149e365f762a
View build.gradle
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '1.2.0'
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'application'
@yusuke2255
yusuke2255 / aws-init-setting.yml
Created Mar 3, 2015
【メモ】ansibleでAWSのEC2インスタンスの基本設定をするplaybook ref: http://qiita.com/Kawata/items/d34dda5de93564873ae7
View aws-init-setting.yml
- hosts: '{{host_name}}'
sudo: yes
roles:
- common
- aws/common
- aws/amazon-linux-init
@yusuke2255
yusuke2255 / file0.txt
Created Feb 27, 2015
【メモ】Hibernateでinsert時にprimary keyでauto incrementを指定している時 ref: http://qiita.com/Kawata/items/62cbe83789b5a3c94bf7
View file0.txt
ERROR [2015-02-27 11:01:38,781] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: ef46ad41b77903a3
! com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'hoge.hibernate_sequence' doesn't exist
! at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_20]
@yusuke2255
yusuke2255 / file0.xml
Created Feb 25, 2015
【メモ】Dropwizardのmigrationでカラムにcharasetを指定する ref: http://qiita.com/Kawata/items/834dce601aacbef9cc67
View file0.xml
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
<changeSet id="1" author="y.hoge">
<createTable tableName="hoges">
<column name="id" type="int(11)" autoIncrement="true">
<constraints primaryKey="true" nullable="false" />
</column>