Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name github-style
// @namespace http://springsource.org
// @description Adds manual merge commands to pull requests
// @include https://github.com/*/*
// @include http://github.com/*/*
// @version 1
// @grant none
// ==/UserScript==
import java.util.EnumSet;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
public class Enums {
public static <E extends Enum<E>, T> Optional<E> lookup(Class<E> elementType, Function<E, T> extractor, T value) {
return EnumSet.allOf(elementType).stream()
.filter(candidate -> Objects.equals(extractor.apply(candidate), value)).findFirst();
@philwebb
philwebb / DemoApplication.java
Created February 8, 2019 01:54
Null rendering in thymeleaf
package com.example.demo;
import java.util.Collection;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.thymeleaf.context.IExpressionContext;
import org.thymeleaf.dialect.IDialect;
@philwebb
philwebb / bddmockito.sh
Created January 29, 2019 20:00
Mockito -> BDDMockito
#!/bin/sh
function migrate {
sed -i.bak \
-e 's|import static org.mockito.Mockito.when;|import static org.mockito.BDDMockito.given;|g' \
-e 's|import org.mockito.runners.MockitoJUnitRunner;|import org.mockito.junit.MockitoJUnitRunner;|g' \
-e 's|import org.mockito.Matchers;|import static org.mockito.ArgumentMatchers.*;|g' \
-e 's|import static org.mockito.Mockito.doThrow;|import static org.mockito.BDDMockito.willThrow;|g' \
-e 's|Matchers.any(|any(|g' \
-e 's|doThrow(|willThrow(|g' \

Getting started with Concourse/ATC

Checkout the code

You need to checkout the concourse project, atc will be picked up as a submodule. The develop branch is for active work:

$ git clone https://github.com/concourse/concourse
git checkout develop
git submodule update --init --recursive
Mon Jun 6 04:09:08 UTC 2016
@Controller
@SessionAttributes(types = Owner.class)
public class OwnerController {
private final ClinicService clinicService;
@Autowired
public OwnerController(ClinicService clinicService) {
this.clinicService = clinicService;
}
@RequestMapping("/")
public ResponseEntity<String> hello() {
return ResponseEntity.ok().header("X-foo", "bar").body("Hi");
}
package sample;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryBuilder;

Keybase proof

I hereby claim:

  • I am philwebb on github.
  • I am philwebb (https://keybase.io/philwebb) on keybase.
  • I have a public key whose fingerprint is 857C C843 87E0 6EC1 97ED D1A6 56E7 0051 2485 74F7

To claim this, I am signing this object: