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
(wc -l (grep "foo" (cat "foo.txt"))) | |
(->> (cat "foo.txt") (grep "foo") "wc -l") |
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 kaazing-eval.core | |
(import [java.io File] | |
[java.net DatagramPacket DatagramSocket InetSocketAddress URI])) | |
(defn publish [msg] | |
(let [remote-uri (URI/create "udp://localhost:50505") | |
remote-addr (InetSocketAddress. (.getHost remote-uri) | |
(.getPort remote-uri)) | |
socket (DatagramSocket.)] | |
(let [bytes (.getBytes msg) |
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 System; | |
using System.Net; | |
using System.Net.Sockets; | |
using System.Text; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
namespace Test.Playground | |
{ | |
[TestClass] | |
public class KaazingPublishTest |
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
(defmacro with-timeout [ms & body] | |
`(let [f# (future ~@body)] | |
(.get #^java.util.concurrent.Future f# ~ms | |
java.util.concurrent.TimeUnit/MILLISECONDS))) |
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
(defn regression-nclients-ms [ds] | |
(with-data ds | |
(let [x ($ :nclients) | |
y ($ :ms) | |
lm (linear-model y x)] | |
(doto (scatter-plot x y :x-label "Number of clients." :y-label "Latency (ms)") | |
(add-lines x (:fitted lm)) | |
(set-title "Regression: linear model of number of clients to latency") | |
view)))) |
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
(defn histogram-with-normal-distribution [ds] | |
"Produce a histgoram of the single-dimensional dataset ds and the corresponding normal distribution." | |
(with-data ds | |
(let [x-mean (mean ds) | |
x-sd (sd ds) | |
x-min (apply min ds) | |
x-max (apply max ds) | |
h (doto (histogram ds :nbins 100 :density true) | |
(set-stroke-color java.awt.Color/blue) | |
(set-title "Distribution of latencies") |
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 storm-tutorial.CustomSerializer | |
(:import [backtype.storm StormSubmitter LocalCluster] | |
[backtype.storm.serialization ISerialization] | |
[java.io DataInputStream DataOutputStream] | |
[org.joda.time DateTime]) | |
(:use [backtype.storm clojure config] | |
[clj-time.core :only (date-time now)] | |
[clj-time.format :only (formatters parse unparse)]) | |
(:gen-class | |
:implements [backtype.storm.serialization.ISerialization])) |
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
;; From Incanter Charts - neat way to do named parameters with defaults in Clojure: | |
([chart & options] | |
(let [{:keys [width dash series dataset] | |
:or {width 1.0 dash 1.0 series 0 dataset 0}} (apply hash-map options) |
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
;; Customize scatter plot to have single-pixel points | |
(let [sp (scatter-plot (range 10) (range 10)) | |
r (-> sp .getXYPlot .getRenderer)] | |
(.setSeriesShape r 0 (java.awt.Rectangle. 0 0 1 1)) | |
(view sp)) |
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 apiclient.websocket | |
(:import (java.net URL) | |
(java.util Properties) | |
(javax.naming Context InitialContext) | |
(javax.jms BytesMessage Connection ConnectionFactory Destination | |
ExceptionListener JMSException | |
Message MessageConsumer MessageListener MessageProducer | |
Session TextMessage Topic TopicSubscriber) | |
(com.kaazing.gateway.jms.client.stomp StompInitialContextFactory | |
GenericBaseMessage GenericBaseMessageImpl |
OlderNewer