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
@flask.ext.login.user_logged_in.connect_via(app) | |
def when_user_logged_in(sender_app, user): | |
print "user_logged_in %s" % (user) | |
@flask.ext.login.user_logged_out.connect_via(app) | |
def when_user_logged_out(sender_app, user): | |
print "user_logged_out %s" % (user) |
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
// <Name>Web pages that do not use the AuthorizationService</Name> | |
from t in JustMyCode.Types | |
where t.DeriveFrom("System.Web.UI.Page") | |
from pl in t.Methods | |
where pl.SimpleName == "Page_Load" | |
&& !pl.IsUsingType("Cyberdyne.AuthorizationService") | |
select new { t, t.BaseClass, pl.SimpleName } |
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
namespace Functionglot | |
type Customer = { First : string; Last: string; SSN: uint32; AccountNumber : uint32; } | |
type Shape = | |
| Rectangle of width : float * length : float | |
| Circle of radius : float | |
| EquilateralTriangle of side : float | |
| Square of side : float |
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])) |
OlderNewer