Skip to content

Instantly share code, notes, and snippets.

<!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) {
var Tween = (function () {
var animations = {}, nanim = 0;
var Tween = {};
Tween.step = function () {
var d = new Date();
var thisTick = d.getTime();
<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>
&nbsp;
<script type="text/javascript">
(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*)))))
(defn multiples [limit & nums]
(->> (map #(range % limit %) nums)
(apply concat)
(distinct)))
(print (time
(apply +
(multiples 1000 3 5))))
; 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
(use 'clojure.test)
(testing "Initialising"
(start "var/test")
(are [x y] (= x y)
(.getClass *neo*) EmbeddedGraphDatabase
(.getClass *lucene* LuceneFullTextIndexService)))
(testing "Homogeneous Nodes"
(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)
(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})
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);