Skip to content

Instantly share code, notes, and snippets.


Hugo Duncan hugoduncan

View GitHub Profile
View jcloud-run-nodes.clj
(ns example
(:use crane.compute)
(:use clojure.contrib.pprint)
(:import org.jclouds.compute.domain.OsFamily)
(:import org.jclouds.compute.options.TemplateOptions)
(:import org.jclouds.logging.log4j.config.Log4JLoggingModule)
(:import org.jclouds.ssh.jsch.config.JschSshClientModule)
(:import org.jclouds.enterprise.config.EnterpriseConfigurationModule))
(defn load-resource-as-byte-array
View capture source line number
(defmacro with-line-number
"Record the source line number"
[& body]
`(do (defvar- ln# nil)
(binding [*script-line* (:line (meta (var ln#)))
*script-file* (:file (meta (var ln#)))]
View gist:367706
(defscript jre-lib-security [])
(defimpl jre-lib-security :default []
(str @(update-java-alternatives -l "|" cut "-d ' '" -f 3 "|" head -1)
(defn security-file
"Installs JCE policy jars (string paths, please) in the remote
JAVA_HOME's lib/security directory, enabling the use of \"unlimited strength\"
crypto implementations. Options are as for remote-file."
[filename & options]
hugoduncan / gist:374112
Created Apr 21, 2010
runtime string interpolation
View gist:374112
(defmacro capture-values
"Capture the values of the specified symbols in a symbol->value map."
[& values]
(into {} (map (fn [s] [ `'~s s]) values)))
(defn <<!
"Interpolate a string given a map of symbol->value"
[f value-map]
(apply str
(map (fn [x] (if (symbol? x)
hugoduncan / gist:374473
Created Apr 21, 2010
Deploy a warfile to tomcat
View gist:374473
;; Example for deploying a war file
(ns tomcat-deploy
[pallet.crate.tomcat :as tomcat]
[pallet.core :as core]))
(defn deploy-my-file
(tomcat/deploy-local-file "path to warfile" "appname"))
View gist:388626
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<param name="Threshold" value="INFO" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>
View gist:398673
(ns myns.plugin
Goal RequiresDependencyResolution Parameter]
#^{Goal "mygoal"
RequiresDependencyResolution "compile"}
View gist:420007
(ns repro.repro)
;; define a macro and a function that uses it
(defmacro my-macro
`(println "a"))
(defn do-macro
View gist:481979
(ns pallet.ssh-test
[org.jclouds.ssh SshClient ExecResponse]
;; define an instance or implementation of the following interfaces:
(defn maybe-invoke [f & args]
hugoduncan / gist:570249
Created Sep 8, 2010
thread-local values
View gist:570249
(defmacro thread-local
"Create a thread local, initialised by body. The value can be obtained by
dereferncing the the thread-local with deref/@."
[& body]
`(proxy [java.lang.ThreadLocal clojure.lang.IDeref] []
[] ~@body)
[] (.get ~'this))))
You can’t perform that action at this time.