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
;;; Author: Scott Jaderholm | |
;;; Created: 2009-12-18 | |
;;; | |
;;; Short Description: Automates the creation of unit conversion | |
;;; functions and includes several common ones. | |
;;; | |
;;; Detailed Description: So for inches, feet, and meters, if you | |
;;; provide equations for inches-to-feet and feet-to-meters, then this | |
;;; package will automatically create feet-to-inches, meters-to-feet, | |
;;; inches-to-meters, meters-to-inches, and all the corresponding |
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
;; an answer to http://kotka.de/blog/2010/03/The_Rule_of_Three.html#summary | |
;; memoize from core.clj: | |
(defn memoize | |
[f] | |
(let [mem (atom {})] | |
(fn [& args] | |
(if-let [e (find @mem args)] | |
(val e) | |
(let [ret (apply f args)] |
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
;annotation syntax | |
(import [java.lang.annotation Retention RetentionPolicy Target ElementType] | |
[javax.xml.ws WebServiceRef WebServiceRefs]) | |
(definterface Foo (foo [])) | |
;annotation on type | |
(deftype ^{Deprecated true | |
Retention RetentionPolicy/RUNTIME | |
javax.annotation.processing.SupportedOptions ["foo" "bar" "baz"] |
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
;; Define a "base type" of Dog | |
(defrecord Dog [breed]) | |
;; Define a "sub type" of TrainedDog | |
(defrecord TrainedDog [dog word]) | |
;; The interface that both Dog and TrainedDog will implement | |
(defprotocol Talker | |
(bark [_]) | |
(speak [_]) |
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
;;Using the Cassowary constraint solver from ClojureScript | |
;;This demo shows using multimethods for readable constraint syntax using +, -, and =. | |
;;Output is a row of circles with random radii spaced so that the space between their boundaries is uniform. | |
(ns c2.main | |
;;refer-clojure :exclude is currently broken in ClojureScript master | |
;;Ticket open: http://dev.clojure.org/jira/browse/CLJS-114 | |
;;Fix applied here: https://github.com/lynaghk/clojurescript/tree/114-refer-clojure-exclude | |
(:refer-clojure :exclude [+ - =]) | |
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
;;Using the Cassowary constraint solver from ClojureScript | |
;;This demo shows using multimethods for readable constraint syntax using +, -, and =. | |
;;Output is a row of circles with random radii spaced so that the space between their boundaries is uniform. | |
(ns c2.main | |
;;refer-clojure :exclude is currently broken in ClojureScript master | |
;;Ticket open: http://dev.clojure.org/jira/browse/CLJS-114 | |
;;Fix applied here: https://github.com/lynaghk/clojurescript/tree/114-refer-clojure-exclude | |
(:refer-clojure :exclude [+ - =]) | |
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 people | |
(:use [clojure.string :only (join)] | |
[clojure.pprint :only (pprint simple-dispatch)])) | |
;; we can make maps using the special literal form: | |
{:a 100 | |
:b 200} | |
(class {:a 100 :b 200}) |
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 people | |
(:use [clojure.string :only (join)] | |
[clojure.pprint :only (pprint simple-dispatch)])) | |
;; we can make maps using the special literal form: | |
{:a 100 | |
:b 200} | |
(class {:a 100 :b 200}) |
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
(fn [] (let [s "(fn [] (let [s %s] (format s (pr-str s))))"] (format s (pr-str s)))) |
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 java.util.Properties | |
import kafka.server.KafkaServer | |
import kafka.server.KafkaConfig | |
import kafka.producer.ProducerConfig | |
import kafka.producer.Producer | |
import kafka.message.Message | |
import kafka.producer.ProducerData | |
import kafka.consumer.ConsumerConfig | |
import kafka.consumer.Consumer | |
import kafka.utils.Utils |
OlderNewer