Skip to content

Instantly share code, notes, and snippets.

View tbatchelli's full-sized avatar

Antoni Batchelli tbatchelli

View GitHub Profile
(ns benchmarks
(:use net.cgrand.enlive-html)
(:require [hiccup.core :as hiccup]
[clj-html.core :as clj-html]))
(defn clj-html-benchmark []
(let [text "Some text"]
(clj-html/html
[:html
[:head
user> (use 'pallet.maven)
(use 'org.jclouds.compute)
(use 'pallet.compute)
(require 'webapp-nodes.nodes)
(def service (compute-service-from-settings))
#'user/service
user> (pallet.core/converge {webapp-nodes.nodes/proxied 2 webapp-nodes.nodes/haproxy 1} :compute service :phase :deploy)
==== add-target-keys :haproxy :bootstrap nil
==== add-target-keys :proxied :bootstrap nil
==== add-target-keys :haproxy :configure us-east-1/i-9d303bf7
@tbatchelli
tbatchelli / tbatchelli.el
Created October 9, 2010 19:05
Incremental mark for clojure
;;;;; extend selection in clojure
;;;; from: http://xahlee.org/emacs/syntax_tree_walk.html
(defun semnav-up (arg)
(interactive "p")
(when (nth 3 (syntax-ppss))
(if (> arg 0)
(progn
(skip-syntax-forward "^\"")
(goto-char (1+ (point)))
INFO core - retrieving nodes
INFO core - converging nodes
INFO core - destroying excess nodes
INFO core - destroying 1 nodes with tag :haproxy
INFO core - adjust-node-counts starting new nodes
INFO core - apply-phase :pre-configure for :haproxy with 0 nodes
INFO core - apply-phase :configure for :haproxy with 0 nodes
INFO core - apply-phase :after-configure for :haproxy with 0 nodes
INFO core - apply-phase :pre-deploy for :haproxy with 0 nodes
INFO core - apply-phase :deploy for :haproxy with 0 nodes
#<ServerSocket ServerSocket[addr=localhost/127.0.0.1,port=0,localport=4005]>
INFO core - retrieving nodes
INFO core - converging nodes
INFO core - destroying excess nodes
INFO core - adjust-node-counts starting new nodes
INFO core - Starting 1 nodes for :haproxy
INFO core - building node template for :haproxy
INFO core - Default OS is :amzn-linux
INFO core - Options {:inbound-ports [80 22]}
INFO ssh - Connecting to 184.72.173.86 port 22
(#<EC2Hardware [id=m1.xlarge, providerId=m1.xlarge, name=m1.xlarge, processors=[[cores=4.0, speed=2.0]], ram=15360, volumes=[[id=null, type=LOCAL, size=10.0, device=/dev/sda1, durable=false, isBootDevice=true], [id=null, type=LOCAL, size=420.0, device=/dev/sdb, durable=false, isBootDevice=false], [id=null, type=LOCAL, size=420.0, device=/dev/sdc, durable=false, isBootDevice=false], [id=null, type=LOCAL, size=420.0, device=/dev/sdd, durable=false, isBootDevice=false], [id=null, type=LOCAL, size=420.0, device=/dev/sde, durable=false, isBootDevice=false]], supportsImage=is64Bit()]>
#<EC2Hardware [id=m2.2xlarge, providerId=m2.2xlarge, name=m2.2xlarge, processors=[[cores=4.0, speed=3.25]], ram=35020, volumes=[[id=null, type=LOCAL, size=10.0, device=/dev/sda1, durable=false, isBootDevice=true], [id=null, type=LOCAL, size=840.0, device=/dev/sdb, durable=false, isBootDevice=false]], supportsImage=is64Bit()]>
#<EC2Hardware [id=m1.large, providerId=m1.large, name=m1.large, processors=[[cores=2.0, speed=2.0]], ram=768
(ns vmfest.util
(:import java.lang.Character))
(defn case-type [c]
(when-not (nil? c)
(if (Character/isUpperCase c) :U :L)))
(defn camel-to-clojure-style* [words current-word remaining-name last-char next-char]
(println words " " current-word " " remaining-name " " last-char " " next-char)
(let [last-char-case (case-type last-char)
; SLIME 20100404
user> (doc import)
-------------------------
clojure.core/import
([& import-symbols-or-lists])
Macro
import-list => (package-symbol class-name-symbols*)
For each name in class-name-symbols, adds a mapping from name to the
class named by package.name to the current namespace. Use :import in the ns
;;;; reflection
(defn method-call-fn [method-name return-type parameter-types]
(let [o-symbol (symbol "o")
method-symbol (symbol (eval method-name))
args (map #(with-meta (symbol (str "x" %2)) {:tag %1}) parameter-types (range))]
(eval `(fn [~o-symbol ~@args] (. ~o-symbol ~method-symbol ~@args )))))
(defn get-signature [^java.lang.reflect.Method method]
(let [method-name (.getName method)
@tbatchelli
tbatchelli / gist:635873
Created October 20, 2010 06:12
How does this look like?
(execute-task my-machine
(set-attributes-task
{:memory-size [(long 1024)]
:cpu-count [(long 2)]
:name ["A new name"]})))