Skip to content

Instantly share code, notes, and snippets.

View chrisvest's full-sized avatar
🍉

Chris Vest chrisvest

🍉
View GitHub Profile

This is a very simple approach to doing role-based access control with Neo4j. It is optimistic, in the sense that all items are assumed to be world-accessible unless they have specific constraints. Item visibility can be constrained to either individual users or all users who belong to a role. Roles are also hierarchical, so can inherit privileges from other roles.

First, lets create our basic example data:

@chrisvest
chrisvest / .vimrc
Created February 22, 2009 00:32 — forked from bitprophet/.vimrc
.vimrc
syntax on
set background=dark
" Return cursor to the previous position when this file was open last
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
filetype plugin indent on
;; chrisvest's solution to http://4clojure.com/problem/29
(fn [s] (apply str (filter #(Character/isUpperCase %) s)))
;; chrisvest's solution to http://4clojure.com/problem/30
(fn [xs]
(reduce (fn [v x] (if (= x (last v)) v (conj v x))) [] xs))
;; chrisvest's solution to http://4clojure.com/problem/40
(fn [a xs] (butlast (mapcat #(vector % a) xs)))
;; chrisvest's solution to http://4clojure.com/problem/49
(fn [n xs] (vector (take n xs) (drop n xs)))
;; chrisvest's solution to http://4clojure.com/problem/31
#(partition-by identity %)
;; chrisvest's solution to http://4clojure.com/problem/50
#(vals (group-by type %))
;; chrisvest's solution to http://4clojure.com/problem/44
(fn [n xs] (let [c (mod n (count xs))]
(concat (drop c xs) (take c xs))))
;; chrisvest's solution to http://4clojure.com/problem/28
(fn squash [xs]
(if (sequential? xs)
(mapcat squash xs)
(list xs)))