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; |
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.api.Factory; | |
import org.glassfish.hk2.utilities.Binder; | |
import org.glassfish.hk2.utilities.binding.ServiceBindingBuilder; | |
import org.glassfish.jersey.internal.inject.Injections; | |
@SuppressWarnings("unchecked") | |
public class InstantFactoryBinder { |
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
(deftest file-validation | |
(s/defschema FileSchema | |
{:file (s/maybe (s/both js/File (s/pred (fn [f] (if f (< (.-size f) 1000000))) 'large-file)))}) | |
(s/defn validated-file | |
[file :- [FileSchema]] 1) | |
(s/with-fn-validation | |
(is (= 1 (validated-file {:file nil}))))) |
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
[org.clojure/clojurescript "1.7.48"] | |
[org.clojure/core.async "0.1.346.0-17112a-alpha"] | |
[cljs-http "0.1.37"] | |
(:require-macros [cljs.core.async.macros :refer [go]]) | |
(:require [cljs-http.client :as http] | |
[cljs.core.async :refer [<! >! chan]])) | |
(defn rest-call [] | |
(go |
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
lein new duct clojure-web-app +example | |
lein repl | |
(go) | |
[ring/ring-json "0.3.1"] | |
[cheshire "5.1.1"] | |
[ring.middleware.json :refer [wrap-json-body wrap-json-response]] | |
[wrap-json-body {:keywords? true}] |
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') |
OlderNewer