Skip to content

Instantly share code, notes, and snippets.

View K0NRAD's full-sized avatar

Hauke K0NRAD

  • 05:56 (UTC +02:00)
View GitHub Profile
@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 / 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 / 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 / add-user.txt
Created June 14, 2014 19:09
WildFly add user with different jboss.domain.base.dir
$JBOSS_HOME/bin/add-user.sh -sc /xyz/standalone/ -dc /xyz/domain/
@K0NRAD
K0NRAD / navbar_ctrl.js
Last active August 29, 2015 14:05
Handle active state of bootstrap navbar
/*
USAGE:
<div class="header">
<ul class="nav nav-pills pull-right" ng-controller="NavbarCtrl">
<li ng-class="{active: isActive('/')}"><a ng-href="#">Home</a></li>
<li ng-class="{active: isActive('/about')}"><a ng-href="#/about">About</a></li>
</ul>
<h3 class="text-muted">My APP</h3>
@K0NRAD
K0NRAD / .bash_profile
Created September 5, 2014 12:50
OSX show / hide hidden files in finder
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
@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 / 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;
@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) {