Skip to content

Instantly share code, notes, and snippets.

View K0NRAD's full-sized avatar

Hauke K0NRAD

  • 12:34 (UTC +02:00)
View GitHub Profile
@K0NRAD
K0NRAD / Boot2Docker-Proxy
Created May 4, 2015 10:35
Use Boot2Docker on OSX from behind a proxy
# Start boot2docker
...
boot2docker ssh
...
# Open/create profile file with vi
sudo vi var/lib/boot2docker/profile
...
@K0NRAD
K0NRAD / drop_user_tables.sql
Created October 13, 2015 12:44
drop all user tables and sequences
SET serveroutput ON;
BEGIN
FOR c IN( SELECT table_name FROM user_tables WHERE table_name NOT LIKE 'SYS%')
LOOP
EXECUTE IMMEDIATE ('DROP TABLE ' || c.table_name || ' CASCADE CONSTRAINTS');
END LOOP;
FOR s IN (SELECT sequence_name FROM user_sequences )
LOOP
EXECUTE IMMEDIATE ('DROP SEQUENCE ' || s.sequence_name);
@K0NRAD
K0NRAD / EntityNotFoundEjbExceptionMapper.java
Created October 13, 2015 12:47
Java EE ExceptionMapper
import javax.persistence.EntityNotFoundException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
@Provider
public class EntityNotFoundEjbExceptionMapper implements ExceptionMapper<EntityNotFoundException> {
@Override
public Response toResponse(EntityNotFoundException exception) {
@K0NRAD
K0NRAD / create_schema.sql
Last active October 13, 2015 12:54
Create Oracle schema (user)
-- drop / create user
drop user xdev01 CASCADE;
CREATE USER xdev01 IDENTIFIED BY xdev01;
ALTER USER xdev01
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
ACCOUNT UNLOCK;
@K0NRAD
K0NRAD / IOUtility.removePath.java
Last active October 13, 2015 12:55
delete path recursivly
public void removePath(Path path) throws IOException {
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
@K0NRAD
K0NRAD / IOUtils.copyPath.java
Last active October 13, 2015 12:56
copy path recursivly with NIO
public void copyPath(Path source, Path target) throws IOException {
Files.walkFileTree(source, new SimpleFileVisitor<Path>() {
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
return copy(file);
}
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
return copy(dir);
}
@K0NRAD
K0NRAD / added_archetypes_idea.txt
Last active October 13, 2015 12:57
Add archetypes stored in IntelliJ IDEA on Mac
On a Mac, the path is ~/Library/Caches/IntelliJIdea14/Maven/Indices/UserArchetypes.xml
@K0NRAD
K0NRAD / hrinkwrap-resolver-depchain.xml
Created October 13, 2015 19:53
hrinkwrap-resolver-depchain
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
<version>2.1.0</version>
<scope>test</scope>
<type>pom</type>
</dependency>
@K0NRAD
K0NRAD / pom.xml
Created November 24, 2015 15:52
Executable JAR's with maven
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<archive>
<manifest>
<mainClass>path.to.your.main.Class</mainClass>
@K0NRAD
K0NRAD / UriInfo.java
Last active December 16, 2015 08:44
Get URI info for HATEOAS in RESTful services
@Provider
@Path("/preferences")
@Api("/preferences")
public class PreferenceResource {
@Inject
private PreferenceController preferenceController;
@Context
private UriInfo uriInfo;