Skip to content

Instantly share code, notes, and snippets.

@xdu
xdu / maven-build-timestamp.md
Created February 10, 2016 13:24
maven build timestamp
<properties>
	<maven.build.timestamp.format>yyyyMMdd.HHmmss</maven.build.timestamp.format>
</properties>

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-jar-plugin</artifactId>
	<configuration>
		<archive>
@xdu
xdu / maven projetct version.md
Last active December 3, 2015 10:34
Change the maven project version and the children

When a maven project contains multiple sub modules, the command line below can change all the versions to the specified one.

mvn release:update-versions -DdevelopmentVersion=16.1.0-SNAPSHOT
@xdu
xdu / vagrant-windows.md
Last active August 29, 2015 14:27
Setup Vagrant under Windows

Vagrant

Although the install of vagrant on linux or MacOSx is quite simple, to install it on windows platform is not a trivial task.

First download the vagrant and follow the setup program. https://www.vagrantup.com/downloads.html

Rsync

Vagrant uses rsync to synchronize a local folder with a folder inside virtualbox, but rsync is not available on windows, you need to download it from https://www.itefix.net/cwrsync.

@xdu
xdu / NTMLProxy.md
Last active August 29, 2015 14:26
Setup a HTTP proxy behind a NTML proxy

Proxy Authentication

A proxy server may ask a client to be authenticated before using the relay. The authentication method can be Basic or NTLM. To find out which method is used by the browser, you can use chrome to open www.google.com and inspect the request headers.

If the headers contain a line like "Proxy-Authorization:NTLM xxxx", it means the proxy uses NTLM to authenticate the user. For the command line applications such as maven or vagrant, even eclipse, they cannot make use this kind proxy server directly, because they don't know how to generate the NTLM authentication hash.

Open a command window and type

set http_proxy=http://proxy.mycompany.com:8080
curl -v http://www.google.com
@xdu
xdu / certificateKeytool.md
Last active June 9, 2021 14:15 — forked from dahernan/certificateKeytool.txt
generate self signed certificate with keytool

To generate a self-signed SSL certificate using the keytool command on Windows, Mac, or Linux:

  • Open a command prompt or terminal.

  • Run this command:

    keytool -genkey -keyalg RSA -alias tomcat -keystore selfsigned.jks \ -validity -keysize 2048

Where <days> indicate the number of days for which the certificate will be valid.
@xdu
xdu / hcserver.java
Created April 4, 2012 13:25
HttpComponents server over SSL socket
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(CyberClient.class.getResourceAsStream("/test.keystore"), "password".toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(ks, "password".toCharArray());
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(kmf.getKeyManagers(), null, null);
SSLServerSocketFactory ssf = sc.getServerSocketFactory();
socket = (SSLServerSocket) ssf.createServerSocket(8888);
// socket = new ServerSocket(port);
@xdu
xdu / security.xml
Last active October 2, 2015 13:08
spring security basic configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd ">
<global-method-security pre-post-annotations="enabled" />
@xdu
xdu / context.xml
Created February 2, 2012 16:26
spring batch configurations
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
@xdu
xdu / gist:1355070
Created November 10, 2011 15:11
xml transient inheritence
@XmlSeeAlso({Dog.class,Cat.class})
class Animal {}
class Dog extends Animal {}
class Cat extends Animal {}
@xdu
xdu / gist:1351027
Created November 9, 2011 10:09
jpa: inheritance primary key
@Entity
@PrimaryKeyJoinColumn(name = "EMP_PK")
class Employee extends Customer {
}