Skip to content

Instantly share code, notes, and snippets.

View thombergs's full-sized avatar

Tom Hombergs thombergs

View GitHub Profile
@thombergs
thombergs / mvn-deploy.sh
Last active June 27, 2023 05:03
Using Maven to deploy to Maven Central
mvn -s settings.xml clean javadoc:jar source:jar gpg:sign -Dgpg.passphrase=your_passphrase deploy
@thombergs
thombergs / EventConsumer.java
Last active October 10, 2016 20:20
Code samples pointing out different features of the Spring Framework.
@Component
public class EventConsumer implements ApplicationListener<E>{
@Override
public void onApplicationEvent(E event) {
try {
onEvent(event);
} catch (Exception e) {
...
}
public enum ParserState {
INITIAL {
@Override
public ParserState nextState(ParseWindow window) {
String line = window.getFocusLine();
if (matchesFromFilePattern(line)) {
logTransition(line, INITIAL, FROM_FILE);
return FROM_FILE;
} else {
@thombergs
thombergs / build.gradle
Last active October 21, 2020 21:51
Accessing the SVN revision number in a Gradle script
import org.tmatesoft.svn.core.wc.*
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.tmatesoft.svnkit', name: 'svnkit', version: '1.7.11'
}
}
@thombergs
thombergs / 001.java
Last active August 29, 2015 14:11
Code of the Day - funny code snippets from real software projects
try {
...
} catch (final AbstractException ab) {
// Schade, aber nicht tödlich
...
}
package de.adesso.jobs;
public class WirSuchenDich {
public Job findeJobFuer(Person du) {
if (du.bistLeidenschaftlicherProgrammierer()) {
Arbeitgeber adesso = Arbeitgeber
.get("Bester IT-Arbeitgeber Deutschlands");
du.meldeDich("0231 / 7000 7100");
return new Job(du, adesso);
public class Calculator{
public int absoluteSum(int a, int b){
if(a < 0) a = -a;
if(b < 0) b = -b;
return a + b;
}
}
@thombergs
thombergs / git-cheat-sheet.sh
Last active December 4, 2016 17:14
Git Cheat Sheet
# clone the remote repo into a (automatically created) folder named like the repo
git clone <FORK_URL>
# list all registered remote repositories
git remote -v
# add the original repo as remote and name it "upstream"
git remote add upstream <ORIGINAL_URL>
# fetch the current state from the upstream remote
git fetch upstream
# change to local master
git checkout master
@thombergs
thombergs / setup_machine.cmd
Last active June 16, 2017 21:43
Shell script to install some default tools via chocolatey
REM run this script with administrator privileges
REM install chocolatey itself
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
REM install packages
choco install -y googlechrome
choco install -y foxitreader
choco install -y sublimetext3
choco install -y procexp
@thombergs
thombergs / AssumeConnection.java
Last active October 17, 2017 18:50
Assumptions and Conditional Test Execution with JUnit 4 and 5
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(AssumeConnectionCondition.class)
public @interface AssumeConnection {
String uri();
}