This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SpringSecuritySigninService extends GormUserDetailsService { | |
void signIn(User user) { | |
def authorities = loadAuthorities(user, user.username, true) | |
def userDetails = createUserDetails(user, authorities) | |
SecurityContextHolder.getContext().setAuthentication( | |
new UsernamePasswordAuthenticationToken(userDetails, null, | |
userDetails.authorities)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GoogleAuthService extends GrailsOAuthService { | |
@Override | |
OAuthService createOAuthService(String callbackUrl) { | |
def builder = createServiceBuilder(GoogleApi20, | |
grailsApplication.config.auth.google.key as String, | |
grailsApplication.config.auth.google.secret as String, | |
callbackUrl) | |
return builder.grantType(OAuthConstants.AUTHORIZATION_CODE) | |
.scope('https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthController { | |
SpringSecuritySigninService springSecuritySigninService | |
def signin = { | |
GrailsOAuthService service = resolveService(params.provider) | |
if (!service) { | |
redirect(url: '/') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OAuthProfile getProfile(OAuthService authService, Token accessToken) { | |
OAuthRequest request = new OAuthRequest(Verb.GET, 'https://www.googleapis.com/oauth2/v1/userinfo') | |
authService.signRequest(accessToken, request) | |
def response = request.send() | |
def user = JSON.parse(response.body) | |
def login = "${user.given_name}.${user.family_name}".toLowerCase() | |
new OAuthProfile(username: login, email: user.email, uid: user.id, picture: user.picture) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LinkStatistics { | |
static belongsTo = [link: Link] | |
Integer score | |
Date dateCreated | |
static mapping = { | |
table("v_link_statistics") | |
link(fetch: FetchMode.EAGER) | |
version(false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.vertx.java.core.Handler; | |
import org.vertx.java.core.VoidHandler; | |
import org.vertx.java.core.eventbus.Message; | |
import org.vertx.java.platform.Verticle; | |
public class Sender extends Verticle { | |
public void start() { | |
send(0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns kafka.core | |
(:require | |
[clojure.core.async :as async] | |
[clj-kafka.core :refer [with-resource]] | |
[clj-kafka.producer :refer [producer send-message message]] | |
[clj-kafka.consumer.zk :refer [consumer messages shutdown]]) | |
(:gen-class)) | |
(def p (producer {"metadata.broker.list" "localhost:9092" | |
"serializer.class" "kafka.serializer.DefaultEncoder" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns file-counter.core | |
(:require [clojure.core.async :refer :all]) | |
(:gen-class)) | |
(defn count-files [count-chn path-chn path] | |
(doseq [file (.listFiles (java.io.File. path))] | |
(if (.isFile file) | |
(println (.getAbsolutePath file)) | |
(>!! path-chn (.getAbsolutePath file))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@groovy.lang.Grab("com.netflix.rxnetty:rx-netty:0.3.14") | |
import io.netty.buffer.ByteBuf | |
import io.reactivex.netty.RxNetty | |
import io.reactivex.netty.protocol.http.server.HttpServer | |
import io.reactivex.netty.protocol.http.server.HttpServerPipelineConfigurator | |
import io.reactivex.netty.protocol.http.server.HttpServerRequest | |
import io.reactivex.netty.protocol.http.server.HttpServerResponse | |
import io.reactivex.netty.protocol.http.server.RequestHandler | |
import rx.functions.Func1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pl.allegro.tech.hermes.common.di; | |
import org.glassfish.hk2.api.DynamicConfiguration; | |
import org.glassfish.hk2.utilities.Binder; | |
import org.glassfish.hk2.utilities.binding.ScopedBindingBuilder; | |
import org.glassfish.jersey.internal.inject.Injections; | |
@SuppressWarnings("unchecked") | |
public class InstantBinder { | |
ScopedBindingBuilder builder; |
OlderNewer