Skip to content

Instantly share code, notes, and snippets.

@puffnfresh
puffnfresh / core.cljs
Created July 22, 2011 12:27
ClojureScript macros
(ns puffnfresh.core
(:require-macros [puffnfresh.timeout :as timeout]))
(defn -main [& args]
(timeout/timeout-macro
(prn "Hello")
(prn "World")
(prn "!")))
(set! *main-cli-fn* -main)
@daveray
daveray / gist:1055523
Created June 30, 2011 02:49
Async Workflows in Seesaw
(ns seesaw.async
(:use [seesaw core]))
; see http://dotnetslackers.com/articles/net/Programming-user-interfaces-using-f-sharp-workflows.aspx#1478
(defmacro async
"Macro that executes an async call (the first form), ignores its result, and the
executes the body normally."
[async-call & body]
`(~@(apply list (first async-call) `(fn [& args#] ~@body) (rest async-call))))
@ibdknox
ibdknox / hiccup.clj
Created June 27, 2011 20:58
generating html in noir
(use 'hiccup.core)
;; ****************************************************************
;; The basics
;; ****************************************************************
(html [:p])
=> "<p />"
;; Any elements after that become the content of the tag
@daveray
daveray / pi.clj
Created June 23, 2011 02:54
Seesaw Ad Hoc StyleSheet
(ns pi.core
(:use seesaw.core))
(native!)
(def gap [:fill-h 5])
; Set up the structure of the ui, giving widgets classes and ids as needed.
(defn make-frame []
(frame
@chapmanb
chapmanb / vagrant_pallet.clj
Created June 20, 2011 11:26
Running pallet with manual specification of a server; example with vagrant virtualbox
(ns distblast-cluster.vagrant
(:require [pallet.compute :as compute]
[pallet.phase :as phase]
[pallet.core :as core]
[pallet.utils :as utils]
[pallet.compute.node-list :as node-list]
[pallet.action.exec-script :as exec-script]))
(defn test-script [session]
(-> session
@cloudartisan
cloudartisan / Launching cluster fails
Created June 20, 2011 07:59
Pallet + EC2 == too hard :-(
$ lein pallet converge staging.core/mongodb-cluster 1
WARN implementation - pallet.compute.vmfest provider failed to load: java.io.FileNotFoundException: Could not locate vmfest/virtualbox/virtualbox__init.class or vmfest/virtualbox/virtualbox.clj on classpath: (vmfest.clj:1)
INFO core - retrieving nodes
ERROR main - Exception
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
at clojure.lang.LazySeq.sval(LazySeq.java:47)
at clojure.lang.LazySeq.seq(LazySeq.java:56)
at clojure.lang.RT.seq(RT.java:450)
at clojure.core$seq.invoke(core.clj:122)
@hugoduncan
hugoduncan / gist:1033762
Created June 19, 2011 04:36
Use aether for artifact resolving
(ns pallet.aether
"Wrapper for aether resolution
See:
https://docs.sonatype.org/display/AETHER/Home"
(:require
[clojure.java.io :as io]
[clojure.contrib.logging :as logging])
(import
org.apache.maven.repository.internal.MavenRepositorySystemSession
@hugoduncan
hugoduncan / gist:1033105
Created June 18, 2011 13:34
Create and destroy security group
(require 'pallet.compute)
(def service (pallet.compute/service "your service name from config.clj here")
(def security-group-client
(..
(clojure.contrib.reflect/get-field
org.jclouds.ec2.compute.EC2ComputeService "ec2Client" (.compute service))
getSecurityGroupServices))
(.createSecurityGroupInRegion security-group-client "us-east-1" "sg" "my new sg)
@cloudartisan
cloudartisan / core.clj
Created June 17, 2011 04:11
Pallet source for deployment to staging
(ns staging.core
(:require
[pallet.core :as core]
[pallet.compute :as compute]
[pallet.resource :as resource]
[pallet.stevedore :as stevedore]
[pallet.crate.automated-admin-user :as automated-admin-user]
[staging.crate.mongodb :as mongodb]))
(def ec2-service
@odyssomay
odyssomay / lein.sh
Created June 15, 2011 22:43
Persistent leiningen
#!/bin/sh
LEIN_VERSION="1.6.0-SNAPSHOT"
export LEIN_VERSION
case $LEIN_VERSION in
*SNAPSHOT) SNAPSHOT="YES" ;;
*) SNAPSHOT="NO" ;;
esac