Skip to content

Instantly share code, notes, and snippets.

@verydapeng
verydapeng / AuthServerApplication.java
Created February 6, 2017 07:41
OAuth Server - Spring Cloud Security
package com.example;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
package com.example;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
@verydapeng
verydapeng / SsoApplication.java
Last active October 19, 2016 06:35
SSO with OAuth2
package verydapeng;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.context.annotation.Bean;
import org.springframework.security.oauth2.client.OAuth2ClientContext;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails;
package com.verydapeng;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@verydapeng
verydapeng / springer-free-maths-books.md
Created December 29, 2015 10:45 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of books available for free, here are the direct links
@verydapeng
verydapeng / app.clj
Created August 15, 2015 04:01
a generic clojure web app
(defn app
"create a new application. returns function to stop the application"
[configurations]
(let [state1 (ref {})
state2 (ref {})
background-worker (schedule #(log-app-states
(let [data1 (rest-query (:source1 configurations))
data2 (rest-query (:source2 configurations))]
(dosync (let [[s1 s2] (generate-new-states-which-is-pure data1 data2 @state1 @state2)]
public class AppStyles {
private static final Map<String, String> imageUrlToCssClassMap = new HashMap<>();
private static int counter = 0;
public static String getCssClassNameFor(String imageUrl) {
if (imageUrlToCssClassMap.containsKey(imageUrl)) {
return imageUrlToCssClassMap.get(imageUrl);
}
/* the name "logoImage" must match with the ImageResource's name */
@url logoUrl logoImage;
.logoBackground {
background-image: logoUrl;
}