Skip to content

Instantly share code, notes, and snippets.

View RickMoynihan's full-sized avatar

Rick Moynihan RickMoynihan

  • Swirrl
  • Manchester
View GitHub Profile
@RickMoynihan
RickMoynihan / evaluate.clj
Last active August 29, 2015 14:22
Simple timbre logging macro to log the contents of the current lexical environment
(defmacro log-env
([] `(log-env :info))
([level] `(log-env ~level "Captured Environment is"))
([level message] `(log/log ~level ~message (zipmap (quote ~(keys &env)) [~@(keys &env)]))))
;; An example of using Grafter's Linked Data Sesame bindings to do
;; RDFS Inferencing.
(ns inferencing.core
(:require [grafter.rdf :refer [add statements subject predicate object prefixer]]
[grafter.rdf.io]
[grafter.rdf.formats :refer :all]
[grafter.rdf.ontologies.rdf :refer :all]
[grafter.rdf.repository :refer [memory-store repo query rdfs-inferencer]]
[grafter.rdf.templater :refer [graph]]))
(defun neotree-find-project-root ()
(interactive)
(neotree-find (projectile-project-root)))
(setq projectile-switch-project-action 'neotree-projectile-action)
(progn
(global-set-key (kbd "s-s") 'neotree-toggle)
(global-set-key (kbd "s-r") 'neotree-find-project-root))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
(defn init [vars hints]
(if (seq vars)
(let [hint (first hints)]
(all
(if-not (zero? hint)
gem 'rdf', '1.0.10'
gem 'tripod'
(ns immutant-bench.queue-speed-test
(:require [immutant.messaging :as m]))
;; Performance stats
;;
;; Robs mac mini (4 cores)
;; -----------------------
;;
;; 10 producers, 5 consumers
;;
immutant@b:~/immutant-bench$ lein immutant run
Starting Immutant: /home/immutant/.lein/immutant/current/jboss/bin/standalone.sh
java.io.IOException: Cannot run program "/home/immutant/.lein/immutant/current/jboss/bin/standalone.sh": java.io.IOException: error=13, Permission denied
at java.lang.ProcessBuilder.start(ProcessBuilder.java:475)
at java.lang.Runtime.exec(Runtime.java:610)
at java.lang.Runtime.exec(Runtime.java:483)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
~/git/immutant-bench $ lein immutant run
Warning: The current app may not be deployed - deploy with 'lein immutant deploy'
Starting Immutant: /Users/rick/.lein/immutant/current/jboss/bin/standalone.sh
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /Users/rick/.lein/immutant/current/jboss
JAVA: java
#!/bin/bash
# Author: Rick Moynihan
# (c) 2013 Stardotstar Ltd
#
# Script to aid copying .gitignore files from the github gitignore project.
#
# Usage:
#
# 1) $ git clone https://github.com/github/gitignore.git
#
@RickMoynihan
RickMoynihan / noescape.clj
Created May 3, 2012 23:42
Symbol abuse, to get escape free SQL strings in Clojure
(defn &&* [symbol-seq]
"escape free strings"
(apply str (interpose " " symbol-seq)))
(&&* '(SELECT "users.*" FROM "users" WHERE ("users.username" = ?) ORDER BY "users.created" ASC))
;; => "SELECT users.* FROM users WHERE (\"users.username\" = ?) ORDER BY users.created ASC"
(defmacro && [& args]
"Use the macro if you can't live with having to quote a list when using &&*"