Skip to content

Instantly share code, notes, and snippets.

View britter's full-sized avatar

Benedikt Ritter britter

View GitHub Profile
@britter
britter / sample.plugin.js
Created November 20, 2014 08:37
Sample jQuery Plugin
(function($) {
var settings = {
settingA = "value1",
settingsB = "value2"
}
$.fn.myplugin = function(options) {
$.extend(settings, options);
return this.each(function(index, item) {
@britter
britter / AModel.java
Created February 20, 2015 14:40
Testing static methods
public class AModel extends Model {
public static AModel createAModel() {
return new AModel().doCreateAModel();
}
// package private for testing
AModel doCreateAModel() {
// code which was previously in createAModel()
}
@britter
britter / ToArrayBenchmark.java
Created May 7, 2015 20:21
ArrayList.toArray Benchmark
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@britter
britter / ToArrayBenchmark.java
Created May 7, 2015 20:34
Comparison of array creation via reflection and via constructor
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Apache Commons Imaging 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ commons-imaging ---
[INFO] Deleting /Users/bene/workspace/apache/commons/imaging/target
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-maven-3) @ commons-imaging ---
@britter
britter / HomeController.java
Created December 22, 2015 17:57
Extended HomeController showing how to format messages retrieved from a MessageSource
/*
* Copyright 2015 Benedikt Ritter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@britter
britter / build.log
Created December 23, 2015 08:49
Heroku build log showing problem with determining git revision
-----> Using set buildpack heroku/java
-----> Java app detected
-----> Installing OpenJDK 1.8... done
-----> Executing: mvn -B -DskipTests clean dependency:list install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building spring-boot-heroku-demo 0.2.0
[INFO] ------------------------------------------------------------------------
[INFO]
@britter
britter / pom.xml
Created December 23, 2015 12:40
Extracting a git commit hash using the buildnumber-maven-plugin in conjunction with resource filtering
<scm>
<url>https://github.com/britter/spring-boot-heroku-demo</url>
</scm>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>messages.properties</include>
@britter
britter / messages.properties
Created December 23, 2015 12:40
messages.properties with static git commit hash and GitHub link
git.commit.hash=6a398ee
git.commit.link=https://github.com/britter/spring-boot-heroku-demo/commit/6a398eeb07765c203db458c6fb2240ad1bbd4654
@britter
britter / home.html
Created December 23, 2015 12:45
Extention of the home.html template for reading values from messages.properties
You're currently looking at version <a href="https://github.com" th:href="#{git.commit.link}"
th:text="#{git.commit.hash}">1bb7244</a>.