Skip to content

Instantly share code, notes, and snippets.

import Data.ByteString.Lazy as BSL
import Data.ByteString.Lazy.Char8 as BSC
import Data.Set as Set
tlds :: Set ByteString
tlds = Set.map BSC.pack $ Set.fromList ["biz", "bz", "cc",
"co", "com", "es", "info",
"io", "me", "net", "org",
"pro", "tv", "us", "ws"]
(defn universal-reducer
"A function that can be used to reduce any function output."
[a b]
(let [a (if (nil? a) 0 a)
b (if (nil? b) 0 b)]
(+ (.hashCode a) (.hashCode b))))
;; Organizing idea is that there are benchmark tasks, which are basically abstract
;; goals you might want to do, apart from any code. And then there are benchmark functions,
;; or variants, that render these concretely into hypothesized bits of code. This helps
;; you compare various implementations of the same task easily.
;;
;; Benchmark framework then takes all your functions, and runs them on your command,
;; generating a report at the end of how all the variants did all the test tasks.
;;
;; A benchmark might need to have data set up and cleanup that is apart from the part that
;; you want to actually benchmark. So you want some way to separate out those phases and
David-Santiagos-Computer:servlet David$ lein pallet converge com.battletheory.deploy.nodes/main 0 -P virtualbox
20:51:43.954 [main] DEBUG pallet.main-invoker - OS Mac OS X 10.7.2
20:51:43.965 [main] DEBUG pallet.main-invoker - Arch x86_64
20:51:43.968 [main] DEBUG pallet.main-invoker - Admin user david
20:51:44.083 [main] DEBUG pallet.main-invoker - private-key-path /Users/David/.ssh/id_rsa true
20:51:44.092 [main] DEBUG pallet.main-invoker - public-key-path /Users/David/.ssh/id_rsa.pub true
20:51:44.113 [main] DEBUG pallet.core - pallet version: 0.6.5
20:51:44.117 [main] INFO pallet.core - retrieving nodes
20:51:51.503 [main] INFO pallet.core - converging nodes
20:51:51.624 [pool-2-thread-1] INFO pallet.core - adjust-node-count :main -1
David-Santiagos-Computer:servlet David$ lein pallet converge com.battletheory.deploy.nodes/main 2 -P virtualbox
WARN logutils - Logging contexts are not supported by your logger configuration
WARN logutils - Logging contexts are not supported by your logger configuration
WARN logutils - Logging contexts are not supported by your logger configuration
WARN logutils - Logging contexts are not supported by your logger configuration
INFO core - retrieving nodes
INFO core - converging nodes
INFO core - adjust-node-count :main 2
INFO core - Starting 2 nodes for :main os-family :ubuntu
INFO vmfest - Template {:os-version-matches "10.10", :os-family :ubuntu}
David-Santiagos-Computer:servlet David$ cat logs/pallet.log
2011-10-29 12:02:38,641 DEBUG [pallet.main-invoker] (main) OS Mac OS X 10.7.2
2011-10-29 12:02:38,783 DEBUG [pallet.main-invoker] (main) Arch x86_64
2011-10-29 12:02:38,784 DEBUG [pallet.main-invoker] (main) Admin user david
2011-10-29 12:02:38,827 DEBUG [pallet.main-invoker] (main) private-key-path /Users/David/.ssh/id_rsa true
2011-10-29 12:02:38,828 DEBUG [pallet.main-invoker] (main) public-key-path /Users/David/.ssh/id_rsa.pub true
2011-10-29 12:02:38,844 DEBUG [pallet.core] (main) pallet version: 0.6.4
2011-10-29 12:02:38,909 TRACE [pallet.core] (main) converge* phases []
2011-10-29 12:02:38,947 ERROR [pallet.main] (main) Exception
java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.Associative
2011-08-14 13:32:26,406 INFO [pallet.compute.vmfest] (pool-2-thread-1) Template {:os-version-matches "10.10", :os-family :ubuntu}
2011-08-14 13:32:26,414 INFO [pallet.compute.vmfest] (pool-2-thread-1) Images:{:vmfest-ubuntu-10-10-64bit-server {:uuid "/Users/David/.vmfest/models/vmfest-ubuntu-10-10-64bit-server.vdi", :ubuntu-10-10-64bit {:os-type-id "Ubuntu_64", :sudo-password "superduper", :no-sudo false, :username "user", :os-family :ubuntu, :os-version "10.10", :os-64-bit true, :password "superduper", :description "Ubuntu 10.10 (64bit)"}}}
2011-08-14 13:32:26,416 DEBUG [pallet.compute.vmfest] (pool-2-thread-1) Looking for {:os-version-matches "10.10", :os-family :ubuntu} in {:vmfest-ubuntu-10-10-64bit-server {:uuid "/Users/David/.vmfest/models/vmfest-ubuntu-10-10-64bit-server.vdi", :ubuntu-10-10-64bit {:os-type-id "Ubuntu_64", :sudo-password "superduper", :no-sudo false, :username "user", :os-family :ubuntu, :os-version "10.10", :os-64-bit true, :password "superduper", :description "Ubuntu 10.10 (64bit)"}
user=> (pprint (update-models))
{:vmfest-ubuntu-10-10-64bit-server
{:uuid
"/Users/David/.vmfest/models/vmfest-ubuntu-10-10-64bit-server.vdi",
:ubuntu-10-10-64bit
{:os-type-id "Ubuntu_64",
:sudo-password "superduper",
:no-sudo false,
:username "user",
:os-family :ubuntu,
user=> (def my-machine (instance my-server "bacug-machine" :ubuntu-10-10-64bit :micro))
java.lang.RuntimeException: Image or Machine not found (NO_SOURCE_FILE:9)
user=> (def my-machine (create-machine my-server "bacug-machine" "Ubuntu_64" basic-config "/Users/David/.vmfest/models/vmfest-ubuntu-10-10-64bit-server.vdi"))
log4j:WARN Fatal parsing error 88 and column 18
log4j:WARN Attribute name "name" associated with an element type "category" must be followed by the ' = ' character.
log4j:ERROR Could not parse url [file:/Users/David/Documents/Development/BattleTheory/servlet/resources/log4j.xml].
org.xml.sax.SAXParseException: Attribute name "name" associated with an element type "category" must be followed by the ' = ' character.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:249)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:180)
David-Santiagos-Computer:servlet David$ cat resources/log4j.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/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"/>