Skip to content

Instantly share code, notes, and snippets.

View jvillste's full-sized avatar

Jukka Villstedt jvillste

View GitHub Profile
class ModelParser extends JavaTokenParsers {
def packageParser: Parser[PackageAST] = ident ~ "{" ~ rep(typeParser) ~ "}" ^^
{ case name ~ "{" ~ types ~ "}" => new PackageAST(name, types) }
def typeParser: Parser[TypeAST] = ident ~ opt(":" ~> repsep(ident,",")) ~ opt("{" ~> rep(propertyParser) <~ "}") ^^
{ case name ~ superTypes ~ properties => new TypeAST(name,superTypes,properties) }
def propertyParser: Parser[PropertyAST] = ident ~ ":" ~ ident ^^
{ case name ~ ":" ~ range => new PropertyAST(name,range) }
public interface IKaivoDatabase {
void add(String subject, String predicate, String object);
void addWithObjectIndex(String subject, String predicate, String object, int index);
void addWithSubjectIndex(String node, String predicate, String newValue, int index);
void remove(String subject, String predicate, String object);
void removeObject(String subject, String predicate, int objectIndex);
void removeSubject(String object, String predicate, int subjectIndex);
void changeObject(String subject, String predicate, int index, String newObject);
org.sidos.metamodel{
string
number
}
fi.sirunsivut.persons {
import org.sidos.metamodel
(defn apropos
"Returns list of namespace - symbol pairs matching a symbol name pattern"
[pattern]
(apply concat (for [ns (all-ns)]
(for [symbol-name (keys (ns-publics ns))
:when (.contains (str symbol-name)
pattern)]
(list (ns-name ns)
symbol-name)))))
@jvillste
jvillste / ricks-clojure.el
Created September 9, 2011 20:33 — forked from RickMoynihan/ricks-clojure.el
elisp for SLIME and swank-clojure
(defun clojure-reset-namespace ()
"Reloads the current Clojure namespace by first removing it and
then re-evaluating the slime buffer. Use this to remove old
symbol definitions and reset the namespace to contain only what
is defined in your current Emacs buffer."
(interactive)
(save-buffer)
(slime-interactive-eval (concat "(remove-ns '" (slime-current-package) ")"))
(slime-compile-and-load-file))
(defn- load [image-list]
(when (:needs-to-load image-list)
(quad-buffer/load (:quad-buffer image-list))
(quad-list/load (:quad-list image-list))
(texture-atlas/load (:texture-atlas image-list)))
(assoc image-list :needs-to-load false))
(defn- draw-image-list [image-list]
(draw/draw-quads (:vertex-buffer-id (:quad-buffer image-list))
(:texture-coordinate-buffer-id (:texture-atlas image-list))
(defn- handle-input [input state-changes event]
(-> input
(assoc :past-states (conj (:past-states input)
(:current-state input)))
(assoc :current-state (apply assoc input-state
(concat state-changes
[:last-event event
:time (System/nanoTime)])))))
(defn handle-mouse-button-press [input lwjgl-event]
(defn combined-key-code [key-code]
(case key-code
left-shift :shift
right-shift :shift
left-control :control
right-control :control
left-alt :alt
alt-gr :alt
nil))
@jvillste
jvillste / gist:1916569
Created February 26, 2012 12:53
protocol mocking
;.;. FAIL at (NO_SOURCE_FILE:1)
;.;. Expected: [{:y 20, :x 10, :height 10} {:y 30, :x 10, :height 15} {:y 45, :x 10, :height 10}]
;.;. Actual: java.lang.ClassCastException: clojure_lwjgl.applications.traditional$eval6058$fn__6059$fn$reify__6061 cannot be cast to clojure.lang.Associative
;.;. clojure_lwjgl.applications.traditional$vertical_stack.invoke(traditional.clj:50)
;.;. clojure_lwjgl.applications.traditional$eval6058$fn__6059$fn__6060.invoke(NO_SOURCE_FILE:1)
;.;. clojure_lwjgl.applications.traditional$eval6058$fn__6059.invoke(NO_SOURCE_FILE:1)
;.;. clojure_lwjgl.applications.traditional$eval6058.invoke(NO_SOURCE_FILE:1)
;.;. clojure_lwjgl.applications.traditional$eval6054.invoke(NO_SOURCE_FILE)
(fact "vertical stack sets x and y coordinates"
@jvillste
jvillste / functional_programming_patterns.txt
Created May 15, 2012 13:10
Functional programming patterns
Create new entity and insert it to a collection. Return the modified collection and the new entity
(let [updated-collection new-entity] (add-entity collection))