Skip to content

Instantly share code, notes, and snippets.

@hugoduncan
hugoduncan / gist:999745
Created May 31, 2011 01:48
Cluster-spec
(defn cluster-spec
"Create a cluster-spec.
`name` is used as a prefix for all groups in the cluster.
- :groups specify a sequence of groups that define the cluster
- :extends specify a server-spec, a group-spec, or sequence thereof,
for all groups in the cluster
@hugoduncan
hugoduncan / gist:1001548
Created June 1, 2011 00:26
debian squeeze preseed late_command for automated install of virtualbox guest additions
# Install virtualbox additions.
# Requires the guest additions iso connected to the secondary slave.
# This seems overly complicated, but is a combination
# that seems to work:
# the vbox ose packages were somehow being installed by the standard task,
# the LSB header is required for update-rc.d, which in turn is needed,
# due to straight linking to rc2.d not working (automatic boot sequence,
# and dependency management),
# cdrom source not being removed at the point when this script runs.
# Deletes /etc/udev/rules.d/70-persistent-net.rules to allow cloning.
@hugoduncan
hugoduncan / gist:1002932
Created June 1, 2011 18:23
record-public-key
(defn record-public-key
"Record a public key"
[session user & {:keys [filename type parameter-path]
:or {type "rsa"} :as options}]
(let [filename (or filename (ssh-default-filenames type))
path (str (user-ssh-dir user) filename ".pub")]
(->
session
(remote-file/with-remote-file
(action/as-clj-action
@hugoduncan
hugoduncan / gist:1005093
Created June 2, 2011 19:20
vmfest manager with sata
(defn attach-hard-disk [m uuid]
{:pre [(model/Machine? m)]}
(session/with-vbox (:server m) [_ vbox]
(let [medium (vbox/find-medium vbox uuid)]
(session/with-session m :shared [_ vb-m]
(try
(attach-device vb-m "SATA Controller" 0 0 :hard-disk medium)
(catch clojure.contrib.condition.Condition _
(attach-device vb-m "IDE Controller" 0 0 :hard-disk medium)))
(.saveSettings vb-m)))))
@hugoduncan
hugoduncan / gist:1007540
Created June 4, 2011 03:34
debian squeeze preseed
# add preseed/url=http://host/path/to/preseed.cfg to the kernel options
# locale
d-i debian-installer/locale string en_US
# Keyboard selection.
d-i console-keymaps-at/keymap select us
d-i keyboard-configuration/xkb-keymap select us
# netcfg will choose an interface that has link if possible. This makes it
@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)
@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:1077956
Created July 12, 2011 13:16
vmfest meta file example
{:debian-6-0-1-tb {:description "Debian Squeeze 6.0.1"
:os-family :debian
:os-version "6.0.1"
:os-type-id "Debian_64"
:os-64-bit true
:username "vmfest"
:password "vmfest"
:sudo-password "vmfest"}}
@hugoduncan
hugoduncan / gist:1103191
Created July 24, 2011 22:30
clojurescript minor mode
;;; clojurescript-mode.el --- Minor mode for clojurescript code
;; Copyright (C) 2011 Hugo Duncan
;;
;; Authors: Hugo Duncan
;; Version: 0.1.0
;; Keywords: languages, lisp, javascript
;; To run the compiler every time a cljs file is saved:
@hugoduncan
hugoduncan / gist:1103200
Created July 24, 2011 22:42
pom file for putting the closure library into a jar file
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.cloudhoist</groupId>
<artifactId>closure-library</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>google closure library</name>
<description>closure library in a jar</description>
<build>