Skip to content

Instantly share code, notes, and snippets.

View hascode's full-sized avatar

Micha Kops hascode

View GitHub Profile
@hascode
hascode / RoutingAfterCBRExample.scala
Created February 28, 2013 19:45
Camel Scala DSL: Routing after a Content-Based-Router
package com.hascode.tutorial
import org.apache.camel.scala.dsl.builder.RouteBuilder
import org.apache.camel.CamelContext
import org.apache.camel.impl.DefaultCamelContext
import javax.jms.ConnectionFactory
import org.apache.camel.component.jms.JmsComponent
import org.apache.activemq.ActiveMQConnectionFactory
import org.apache.camel.Processor
import org.apache.camel.scala.dsl.builder.RouteBuilderSupport
import org.apache.camel.Exchange
@hascode
hascode / pom.xml
Created August 24, 2013 20:50
java ee 7 webapp from maven archetype with maven embedded glassfish plugin v4.0
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hascode.tutorial</groupId>
<artifactId>javaee7-webapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
@hascode
hascode / gist:7039247
Created October 18, 2013 09:52
Setting a global alias to allow a pretty-printed git log output defining an alias named plog (for pretty-log).
git config --global alias.plog "log --graph --decorate --all --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'"
git plog
@hascode
hascode / gist:8349080
Last active January 2, 2016 19:18
Maven Surefire/Failsave examples
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<excludes>
<exclude>it/**</exclude>
</excludes>
@hascode
hascode / pom.xml
Created March 25, 2014 09:56
Maven Plugin Setup for phantomJS + Jasemine
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>0.2.1</version>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
</execution>
@hascode
hascode / pom.xml
Created August 22, 2014 06:14
Referencing information generated by atlas-create-home-zip
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
[...]
<productDataPath>src/test/xml/generated-test-resources.zip</productDataPath>
</configuration>
@hascode
hascode / curry.js
Last active August 29, 2015 14:07
Javascript Currying
Function.prototype.curry = function(){
var func = this, args = Array.prototype.slice.call(arguments);
return function(){
return func.apply(this, args.concat(Array.prototype.slice.call(arguments)));
}
};
var add = function(a,b){
return a+b;
}
@hascode
hascode / memoization.js
Created October 15, 2014 07:36
JavaScript Memoization
var fib = function(n){
return (n<2) ? 1 : fib(n-1) + fib(n-2);
}
var calc = function(numbers){
var self = this;
numbers.forEach(function(n){
if(!self.cache){
self.cache = {};
}
@hascode
hascode / pom.xml
Created January 2, 2015 12:12
Hamcrest + JUnit 4.12
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hascode.tutorial</groupId>
<artifactId>hamcrest-tutorial</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
@hascode
hascode / CustomExceptionMapper.java
Created February 27, 2015 13:07
Example JAX-RS Exception Mapper
@Provider
public class CustomExceptionMapper implements ExceptionMapper<CustomException> {
@Override
public Response toResponse(final CustomException exception) {
return Response.status(Status.BAD_REQUEST).entity(exception).type(MediaType.APPLICATION_JSON).build();
}
}