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 org.neo4j.graphdb.traversal.Evaluator; | |
import org.neo4j.graphdb.traversal.Evaluation; | |
import org.neo4j.graphdb.*; | |
// exclude Movies seen by userNode | |
public class CustomFilteringEvaluator implements Evaluator { | |
private RelationshipType hasSeenRelationshipType = DynamicRelationshipType.withName("HAS_SEEN"); | |
private final Node userNode; | |
public CustomFilteringEvaluator(Node userNode) { | |
this.userNode = userNode; |
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 make-account [name balance] | |
{:name name :balance balance}) | |
(defn withdraw [account n] | |
(update-in account [:balance] - n)) | |
; Single-Treaded withdraw/loop | |
(loop [a (make-account "Ben" 5000)] | |
(Thread/sleep 1) | |
(if (pos? (:balance a)) |
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
(require 'clojure-mode "clojure-mode" t) | |
(require 'slime t) | |
(when (eq system-type 'cygwin) | |
(add-hook 'slime-connected-hook (lambda () | |
(setq slime-to-lisp-filename-function (lambda (filename) | |
(replace-regexp-in-string | |
"\n" "" (shell-command-to-string | |
(format "cygpath.exe --windows %s" filename)))) | |
slime-from-lisp-filename-function (lambda (filename) |
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
(defun reopen-sudo () | |
(interactive) | |
(unless (file-remote-p (buffer-file-name)) | |
(find-file (tramp-make-tramp-file-name "sudo" "root" "localhost" (buffer-file-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
(set! *unchecked-math* true) | |
(defmacro iloop [[b t n] & body] | |
`(loop [~@b] | |
(when ~t | |
~@body | |
(recur ~n)))) | |
(defn count-primes [^long n] | |
(let [c (inc n) |
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
#!/bin/bash | |
ORIG_MVN=/opt/maven/bin/mvn | |
while [ ! -r "pom.xml" ] && [ "$PWD" != "/" ] | |
do | |
cd .. | |
done | |
if [ -r "pom.xml" ]; then |
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
(defvar swank-autoconnect-port 4005) | |
(defvar swank-autoconnect-timer nil) | |
(defun swank--listeningp () | |
(ignore-errors | |
(let ((p (open-network-stream "SLIME Lisp Connection Test" nil "localhost" swank-autoconnect-port))) | |
(when p | |
(delete-process p) | |
t)))) |
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 #^{:author "Jürgen Hötzel", | |
:doc "Message Digest function for Clojure | |
Usage | |
(require 'md) | |
MD5 Checksum String: | |
(md/digest-str (md/sum \"MD5\" \"/etc/passwd\")) | |
\"85dbcf75fa3eb92335cc3ac47dfa64c9\""} | |
md |
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
(defadvice shell-cd (after shell-dirtrack-update-buffer-name activate) | |
(let* ((new-name (generate-new-buffer-name "*shell*")) | |
(old-name (generate-new-buffer-name (buffer-name)))) | |
(unless (string= new-name old-name) | |
(rename-buffer new-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
(ns sicp.queens) | |
(def empty-board '()) | |
(defn safe? | |
"Check if queen in last row is safe" | |
[positions] | |
(let [[queen-pos & left] positions | |
k (count positions) | |
diags-up (map - left (range 1 (inc k))) |