This is a JPA @ManyToMany sample.
@Entity
public class Link {
...
@ManyToMany
@JoinTable(
name = "link_tag",
joinColumns = @JoinColumn(name = "link_id"),
inverseJoinColumns = @JoinColumn(name = "tag_id"))
private List<Tag> tags;
...
}
@Entity
public class Tag {
...
@ManyToMany
@JoinTable(
name = "link_tag",
joinColumns = @JoinColumn(name = "tag_id"),
inverseJoinColumns = @JoinColumn(name = "link_id"))
private List<Link> links;
...
}
Reference:
http://www.java2s.com/Code/Java/JPA/ManyToManyJoinedTable.htm
Tuesday, December 30, 2014
Exclude @ToString in @Data in Lombok
I guess there is no way to exclude @ToString in @Data in Lombok.
@Data is equivalent to
@Getter
@Setter
@RequiredArgsConstructor
@ToString
@EqualsAndHashCode
So instead of @Data, you can just use the following annotations:
@Getter
@Setter
@RequiredArgsConstructor
@EqualsAndHashCode
@Data is equivalent to
@Getter
@Setter
@RequiredArgsConstructor
@ToString
@EqualsAndHashCode
So instead of @Data, you can just use the following annotations:
@Getter
@Setter
@RequiredArgsConstructor
@EqualsAndHashCode
JsRender remote template sample
This is a JsRender remote template sample.
https://github.com/izeye/samples-javascript/tree/master/samples/jsrender/remote_template
Reference:
http://www.jsviews.com/#samples/jsr/composition/remote-tmpl
https://github.com/izeye/samples-javascript/tree/master/samples/jsrender/remote_template
Reference:
http://www.jsviews.com/#samples/jsr/composition/remote-tmpl
JavaScript multiline string
To use multiline string in JavaScript,
you can use '\' as follows:
$.templates("personTemplate",
' \
<tr> \
<td>{{>name}}</td> \
<td>{{>age}}</td> \
</tr> \
'
);
Reference:
http://stackoverflow.com/questions/805107/creating-multiline-strings-in-javascript
you can use '\' as follows:
$.templates("personTemplate",
' \
<tr> \
<td>{{>name}}</td> \
<td>{{>age}}</td> \
</tr> \
'
);
Reference:
http://stackoverflow.com/questions/805107/creating-multiline-strings-in-javascript
Monday, December 29, 2014
Create a self-signed test certificate in Linux
To create a self-signed test certificate in Linux,
you can use the following command:
openssl req -new -x509 -key server.key -out server.crt
You can find the meaning of options in man page.
From 'man openssl':
openssl - OpenSSL command line tool
req X.509 Certificate Signing Request (CSR) Management.
From 'man req':
-new
this option generates a new certificate request. It will prompt the
user for the relevant field values. The actual fields prompted for
and their maximum and minimum sizes are specified in the
configuration file and any requested extensions.
If the -key option is not used it will generate a new RSA private
key using information specified in the configuration file.
-x509
this option outputs a self signed certificate instead of a
certificate request. This is typically used to generate a test
certificate or a self signed root CA. The extensions added to the
certificate (if any) are specified in the configuration file.
Unless specified using the set_serial option 0 will be used for the
serial number.
-key filename
This specifies the file to read the private key from. It also
accepts PKCS#8 format private keys for PEM format files.
-out filename
This specifies the output filename to write to or standard output
by default.
To create a self-signed test certificate with a CSR in Linux,
you can use the following command:
openssl req -in ../csr/cert.csr -x509 -key ../private_key/rsa/privkey.pem -out cacert.pem -days 1095
You can find the meaning of options in man page.
From 'man req':
-in filename
This specifies the input filename to read a request from or
standard input if this option is not specified. A request is only
read if the creation options (-new and -newkey) are not specified.
-days n
when the -x509 option is being used this specifies the number of
days to certify the certificate for. The default is 30 days.
Reference:
https://www.openssl.org/docs/HOWTO/certificates.txt
you can use the following command:
openssl req -new -x509 -key server.key -out server.crt
You can find the meaning of options in man page.
From 'man openssl':
openssl - OpenSSL command line tool
req X.509 Certificate Signing Request (CSR) Management.
From 'man req':
-new
this option generates a new certificate request. It will prompt the
user for the relevant field values. The actual fields prompted for
and their maximum and minimum sizes are specified in the
configuration file and any requested extensions.
If the -key option is not used it will generate a new RSA private
key using information specified in the configuration file.
-x509
this option outputs a self signed certificate instead of a
certificate request. This is typically used to generate a test
certificate or a self signed root CA. The extensions added to the
certificate (if any) are specified in the configuration file.
Unless specified using the set_serial option 0 will be used for the
serial number.
-key filename
This specifies the file to read the private key from. It also
accepts PKCS#8 format private keys for PEM format files.
-out filename
This specifies the output filename to write to or standard output
by default.
To create a self-signed test certificate with a CSR in Linux,
you can use the following command:
openssl req -in ../csr/cert.csr -x509 -key ../private_key/rsa/privkey.pem -out cacert.pem -days 1095
You can find the meaning of options in man page.
From 'man req':
-in filename
This specifies the input filename to read a request from or
standard input if this option is not specified. A request is only
read if the creation options (-new and -newkey) are not specified.
-days n
when the -x509 option is being used this specifies the number of
days to certify the certificate for. The default is 30 days.
Reference:
https://www.openssl.org/docs/HOWTO/certificates.txt
Create a CSR (Certificate Signing Request) in Linux
To create a CSR in Linux,
you can use the following command:
openssl req -newkey rsa:2048 -nodes -keyout server.key -out server.csr
You can find the meaning of options in man page.
From 'man openssl':
openssl - OpenSSL command line tool
req X.509 Certificate Signing Request (CSR) Management.
From 'man req':
req - PKCS#10 certificate request and certificate generating utility.
-newkey arg
this option creates a new certificate request and a new private
key. The argument takes one of two forms. rsa:nbits, where nbits is
the number of bits, generates an RSA key nbits in size.
dsa:filename generates a DSA key using the parameters in the file
filename.
-nodes
if this option is specified then if a private key is created it
will not be encrypted.
-keyout filename
this gives the filename to write the newly created private key to.
If this option is not specified then the filename present in the
configuration file is used.
-out filename
This specifies the output filename to write to or standard output
by default.
To create a CSR with a private key in Linux,
you can use the following command:
openssl req -new -key ../private_key/rsa/privkey.pem -out cert.csr
You can find the meaning of options in man page.
From 'man req':
-new
this option generates a new certificate request. It will prompt the
user for the relevant field values. The actual fields prompted for
and their maximum and minimum sizes are specified in the
configuration file and any requested extensions.
If the -key option is not used it will generate a new RSA private
key using information specified in the configuration file.
-key filename
This specifies the file to read the private key from. It also
accepts PKCS#8 format private keys for PEM format files.
References:
http://en.wikipedia.org/wiki/Certificate_signing_request
https://www.digicert.com/csr-creation-apache.htm
https://www.openssl.org/docs/HOWTO/certificates.txt
you can use the following command:
openssl req -newkey rsa:2048 -nodes -keyout server.key -out server.csr
You can find the meaning of options in man page.
From 'man openssl':
openssl - OpenSSL command line tool
req X.509 Certificate Signing Request (CSR) Management.
From 'man req':
req - PKCS#10 certificate request and certificate generating utility.
-newkey arg
this option creates a new certificate request and a new private
key. The argument takes one of two forms. rsa:nbits, where nbits is
the number of bits, generates an RSA key nbits in size.
dsa:filename generates a DSA key using the parameters in the file
filename.
-nodes
if this option is specified then if a private key is created it
will not be encrypted.
-keyout filename
this gives the filename to write the newly created private key to.
If this option is not specified then the filename present in the
configuration file is used.
-out filename
This specifies the output filename to write to or standard output
by default.
To create a CSR with a private key in Linux,
you can use the following command:
openssl req -new -key ../private_key/rsa/privkey.pem -out cert.csr
You can find the meaning of options in man page.
From 'man req':
-new
this option generates a new certificate request. It will prompt the
user for the relevant field values. The actual fields prompted for
and their maximum and minimum sizes are specified in the
configuration file and any requested extensions.
If the -key option is not used it will generate a new RSA private
key using information specified in the configuration file.
-key filename
This specifies the file to read the private key from. It also
accepts PKCS#8 format private keys for PEM format files.
References:
http://en.wikipedia.org/wiki/Certificate_signing_request
https://www.digicert.com/csr-creation-apache.htm
https://www.openssl.org/docs/HOWTO/certificates.txt
Sunday, December 28, 2014
Jenkins build triggered by Git push
To build by Git push in Jenkins,
you can set a project configuration as follows:
Configure -> Build Triggers -> Poll SCM -> Schedule -> H/5 * * * *
Now Jenkins will poll the repository for checking any change every 5 minutes.
You can check the polling log at 'Git Polling Log' menu.
As you can see, it's not really event-based but polling-based.
I haven't tried event-based approach yet.
you can set a project configuration as follows:
Configure -> Build Triggers -> Poll SCM -> Schedule -> H/5 * * * *
Now Jenkins will poll the repository for checking any change every 5 minutes.
You can check the polling log at 'Git Polling Log' menu.
As you can see, it's not really event-based but polling-based.
I haven't tried event-based approach yet.
Campfire for group chat
For group chat, you can use Campfire.
It's web-based and provides iOS app.
It's basically paid service but free for groups which have less than 5 people.
Unfortunately, I prefer application rather than web and use Android.
References:
https://campfirenow.com/
https://campfirenow.com/signup
It's web-based and provides iOS app.
It's basically paid service but free for groups which have less than 5 people.
Unfortunately, I prefer application rather than web and use Android.
References:
https://campfirenow.com/
https://campfirenow.com/signup
How to use a snapshot version of Spring Boot
To use a snapshot version of Spring Boot,
modify build.gradle as follows:
buildscript {
repositories {
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/libs-milestone" }
maven { url "http://repo.spring.io/libs-release" }
mavenCentral()
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.1.BUILD-SNAPSHOT")
}
}
repositories {
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/libs-milestone" }
maven { url "http://repo.spring.io/libs-release" }
mavenCentral()
mavenLocal()
}
Reference:
http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/
modify build.gradle as follows:
buildscript {
repositories {
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/libs-milestone" }
maven { url "http://repo.spring.io/libs-release" }
mavenCentral()
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.1.BUILD-SNAPSHOT")
}
}
repositories {
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/libs-milestone" }
maven { url "http://repo.spring.io/libs-release" }
mavenCentral()
mavenLocal()
}
Reference:
http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/
Web-based IRC client
You can use web-based IRC client, KiwiIRC at:
https://kiwiirc.com/client
Reference:
https://kiwiirc.com/
https://kiwiirc.com/client
Reference:
https://kiwiirc.com/
How to use MariaDB in Spring Boot
To use MariaDB in Spring Boot,
you can set the following datasource properties in application.properties:
spring.datasource.url=jdbc:mariadb://localhost:3306/db_wic
spring.datasource.username=wic
spring.datasource.password=1234
spring.datasource.driverclassName=org.mariadb.jdbc.Driver
and add the following JDBC dependency in build.gradle:
compile("org.mariadb.jdbc:mariadb-java-client:1.1.7")
Reference:
https://mariadb.com/kb/en/mariadb/client-libraries/mariadb-java-client/about-the-mariadb-java-client/
you can set the following datasource properties in application.properties:
spring.datasource.url=jdbc:mariadb://localhost:3306/db_wic
spring.datasource.username=wic
spring.datasource.password=1234
spring.datasource.driverclassName=org.mariadb.jdbc.Driver
and add the following JDBC dependency in build.gradle:
compile("org.mariadb.jdbc:mariadb-java-client:1.1.7")
Reference:
https://mariadb.com/kb/en/mariadb/client-libraries/mariadb-java-client/about-the-mariadb-java-client/
How to execute initialization SQLs in Spring Boot
To execute initialization SQLs,
put the SQLs in 'data.sql' located in the root of the classpath.
You can turn off the feature with the following property in application.properties:
spring.datasource.initialize=false
Reference:
http://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html
put the SQLs in 'data.sql' located in the root of the classpath.
You can turn off the feature with the following property in application.properties:
spring.datasource.initialize=false
Reference:
http://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html
Error: Cannot write to /usr/local/Cellar
You can see the following error with a brew command like 'brew install mariadb':
Error: Cannot write to /usr/local/Cellar
To fix, change the owner of the directory:
sudo chown $USER /usr/local/Cellar/
Reference:
http://stackoverflow.com/questions/4804169/installing-in-homebrew-errors
Error: Cannot write to /usr/local/Cellar
To fix, change the owner of the directory:
sudo chown $USER /usr/local/Cellar/
Reference:
http://stackoverflow.com/questions/4804169/installing-in-homebrew-errors
How to install MariaDB in Mac
To install MariaDB in Mac,
you can do the following command:
brew install mariadb
You can create default databases with the following command:
sudo mysql_install_db --user=mysql --datadir=/Users/izeye/mysql/data
You should replace '/Users/izeye/mysql/data' with your 'datadir'.
You can run MariaDB server with the following commands:
cd '/usr/local/Cellar/mariadb/10.0.15'
sudo /usr/local/Cellar/mariadb/10.0.15/bin/mysqld_safe --datadir='/Users/izeye/mysql/data'
You can also use mysql.server script.
Open the script with the following command:
vi /usr/local/bin/mysql.server
Set your 'datadir':
datadir=/Users/izeye/mysql/data
Start the script:
sudo mysql.server start
Be careful with your previous MySQL data.
You'd better backup your MySQL data before trying to install MariaDB.
References:
https://mariadb.com/kb/en/mariadb/documentation/getting-started/compiling-mariadb-from-source/building-mariadb-on-mac-os-x-using-homebrew/
http://dev.mysql.com/doc/refman/5.0/en/mysql-install-db.html
you can do the following command:
brew install mariadb
You can create default databases with the following command:
sudo mysql_install_db --user=mysql --datadir=/Users/izeye/mysql/data
You should replace '/Users/izeye/mysql/data' with your 'datadir'.
You can run MariaDB server with the following commands:
cd '/usr/local/Cellar/mariadb/10.0.15'
sudo /usr/local/Cellar/mariadb/10.0.15/bin/mysqld_safe --datadir='/Users/izeye/mysql/data'
You can also use mysql.server script.
Open the script with the following command:
vi /usr/local/bin/mysql.server
Set your 'datadir':
datadir=/Users/izeye/mysql/data
Start the script:
sudo mysql.server start
Be careful with your previous MySQL data.
You'd better backup your MySQL data before trying to install MariaDB.
References:
https://mariadb.com/kb/en/mariadb/documentation/getting-started/compiling-mariadb-from-source/building-mariadb-on-mac-os-x-using-homebrew/
http://dev.mysql.com/doc/refman/5.0/en/mysql-install-db.html
Saturday, December 27, 2014
How to give sudo permission to a user in Mac
To give sudo permission to a user in Mac,
you can do the following command:
sudo visudo
and add the following line:
wic ALL=(ALL) ALL
'wic' should be replaced with your username.
Reference:
http://mithunme.wordpress.com/2013/02/10/adding-a-standard-user-to-etcsudoers-in-mac-os-x/
you can do the following command:
sudo visudo
and add the following line:
wic ALL=(ALL) ALL
'wic' should be replaced with your username.
Reference:
http://mithunme.wordpress.com/2013/02/10/adding-a-standard-user-to-etcsudoers-in-mac-os-x/
Change Spring Data REST API URI in Spring Boot
To change Spring Data REST API URI in Spring Boot,
you can add the following property in application.properties:
spring.data.rest.base-uri=/api
Reference:
http://stackoverflow.com/questions/23377036/spring-boot-starter-data-rest-change-url-of-repository-from-the-root-uri
you can add the following property in application.properties:
spring.data.rest.base-uri=/api
Reference:
http://stackoverflow.com/questions/23377036/spring-boot-starter-data-rest-change-url-of-repository-from-the-root-uri
How to remove NO_EXTERNAL_MSGS in IRC channel
You can check IRC channel modes by the following command:
/mode #wic-site
You can remove NO_EXTERNAL_MSGS by the following command:
/mode #wic-site -n
References:
http://www.irchelp.org/irchelp/irctutorial.html
https://www.alien.net.au/irc/chanmodes.html
/mode #wic-site
You can remove NO_EXTERNAL_MSGS by the following command:
/mode #wic-site -n
References:
http://www.irchelp.org/irchelp/irctutorial.html
https://www.alien.net.au/irc/chanmodes.html
Where is Git configuration file?
Git configuration file is:
~/.gitconfig
Reference:
http://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
~/.gitconfig
Reference:
http://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
How to show Git configuration
To show Git configuration, you can use the following command:
git config --list
Reference:
http://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
Subscribe to:
Posts (Atom)