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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<script type="text/javascript" src="Eventful.js"></script> | |
<script type="text/javascript" src="Mustache.js"></script> | |
</head> | |
<body> | |
<div style="float: left; margin-right: 30px;"> | |
<h2>Object Definition</h2> | |
<pre> var Person = function (name) { |
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
var Tween = (function () { | |
var animations = {}, nanim = 0; | |
var Tween = {}; | |
Tween.step = function () { | |
var d = new Date(); | |
var thisTick = d.getTime(); | |
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
<html> | |
<head> | |
<script type="text/javascript" src="src/Server.js"></script> | |
<script type="text/javascript" src="src/Cursor.js"></script> | |
<script type="text/javascript" src="src/Collection.js"></script> | |
<script type="text/javascript" src="src/Db.js"></script> | |
</head> | |
<body> | |
| |
<script type="text/javascript"> |
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
(def *tx* nil) | |
(def *lucene*) ; def'd during startup | |
(defmacro with-tx [& body] | |
`(binding [*tx* (.beginTx *neo*)] | |
(try | |
(let [val# (do ~@body)] | |
(.success *tx*) | |
val#) | |
(finally (.finish *tx*))))) |
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 multiples [limit & nums] | |
(->> (map #(range % limit %) nums) | |
(apply concat) | |
(distinct))) | |
(print (time | |
(apply + | |
(multiples 1000 3 5)))) |
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
; memoize this | |
(defn collatz [n l] | |
(if (= n 1) | |
(inc l) | |
(if (even? n) | |
(recur (/ n 2) (inc l)) | |
(recur (inc (* 3 n)) (inc l))))) | |
(print (time | |
(apply max-key last |
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
(use 'clojure.test) | |
(testing "Initialising" | |
(start "var/test") | |
(are [x y] (= x y) | |
(.getClass *neo*) EmbeddedGraphDatabase | |
(.getClass *lucene* LuceneFullTextIndexService))) | |
(testing "Homogeneous Nodes" |
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 register-classed-indices [classes] | |
(transaction-handler | |
(afterCommit [_ data state] nil) | |
(beforeCommit [_ data] | |
(let [remnodes (into {} (map (fn [^Node node] [(.getId node) {}]) (.deletedNodes data))) | |
rnodes (reduce (fn [props ^PropertyEntry removal] (update-in props [(.getId ^Node (.entity removal))] assoc (.key removal) (.previouslyCommitedValue removal))) remnodes (filter #(contains? remnodes (.getId ^Node (.entity ^PropertyEntry %))) (.removedNodeProperties data)))] | |
(doseq [^PropertyEntry removal (.removedNodeProperties data)] | |
(let [entity ^Node (.entity removal) | |
key (.key removal) | |
entity-id (.getId entity) |
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
(defprotocol TestProtocol | |
(test-method [this])) | |
(deftype MutableLocking | |
; Compiles ok | |
[^{:volatile-mutable true} mut-var] | |
TestProtocol | |
(test-method [this] | |
(locking this | |
(set! mut-var {:set 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
everyone.now.joinChat = function () { | |
this.now.inChat = true; | |
var userlist = []; | |
everyone.now.iterate(function (user) { | |
if (user.now.inChat) { | |
userlist.push(userId(user)); | |
} | |
}); | |
this.now.receiveUsers(userlist); | |
everyone.now.broadcastJoin(this); |
OlderNewer