Skip to content

Instantly share code, notes, and snippets.

View tbatchelli's full-sized avatar

Antoni Batchelli tbatchelli

View GitHub Profile
@tbatchelli
tbatchelli / scratchpad-cw2014.txt
Created January 25, 2014 03:13
Scratchpad proposal sent to Clojure/West 2014
Scratchpad: Code + everything needed to run it
———————————————————————
Scratchpad is a platform that lets you build scratchpads and run them
at the REPL. A scratchpad is a self-contained clojure file that includes
both code and everything needed to run it: library dependencies and
infrastructure.
Dependencies are expressed in lein-style and are downloaded and added
into the classpath when you load the scratchpad into the REPL. You can
(ns pallet-aws
(:require [pallet.api :as api]
[pallet.compute :as compute]))
(def id "<your aws identity>")
(def cred "<your aws credendial>")
;; Security Groups and VPC
;;------------------------
(defplan pull-config
"Plan function to pull the node info into the session, under `:nodetool`"
[]
(let [nv (exec-script ("nodetool" "info"))
node-id (target-id)]
(pallet.actions/assoc-settings
:nodetool
(return-value-expr
[nv]
(let [result (:out nv)]
2013-11-07 14:56:00,209 DEBUG [operate-76] p.script-builder sudo-cmd-for {:username "abatchelli", :sudo-password nil, :sudo-user "quantum", :password nil, :no-sudo nil}
2013-11-07 14:56:00,209 DEBUG [operate-76] p.script-builder prefix /usr/bin/sudo -n -u quantum
2013-11-07 14:56:00,209 DEBUG [operate-76] p.s.execute ssh-script-on-target command {:env-cmd "/usr/bin/env", :env nil, :env-fwd [:SSH_AUTH_SOCK], :prefix ["/usr/bin/sudo" "-n" "-u" "quantum"], :execv ("/bin/bash" "/tmp/palletD4670")}
2013-11-07 14:56:00,504 DEBUG [operate-76] p.execute q-pallet-dev1 <== upload: upload-build: upload-qi: Directory /mnt/quantum/qi...
2013-11-07 14:56:00,606 INFO [operate-76] p.execute q-pallet-dev1 #> upload: upload-build: upload-qi: Directory /mnt/quantum/qi : SUCCESS
2013-11-07 14:56:00,898 DEBUG [operate-76] p.s.execute q-pallet-dev1 <== ----------------------------------------
2013-11-07 14:56:00,899 INFO [operate-76] p.s.execute q-pallet-dev1 22 upload: upload-build: upload-qi: remote-file /mnt/quantum/qi/Quan
2013-11-07 14:31:18,670 DEBUG [operate-59] p.l.execute localhost ==> -----------------------------------------
2013-11-07 14:31:18,670 DEBUG [operate-59] p.l.execute localhost ==> #!/usr/bin/env bash
2013-11-07 14:31:18,670 DEBUG [operate-59] p.l.execute localhost ==> mkdir -p /Users/tbatchelli || exit 1
2013-11-07 14:31:18,670 DEBUG [operate-59] p.l.execute localhost ==> cd /Users/tbatchelli
2013-11-07 14:31:18,670 DEBUG [operate-59] p.l.execute localhost ==> set -h
2013-11-07 14:31:18,670 DEBUG [operate-59] p.l.execute localhost ==> echo 'rsync /Users/tbatchelli/dev/clients/qr/uplift/target/deploy/920459718/qlauncher/qlauncher-fashion-13.2.13-SNAPSHOT-063ef44da2c05a07720d1e723e7cfe64e93f2310 to /mnt/quantum/qi...';
2013-11-07 14:31:18,670 DEBUG [operate-59] p.l.execute localhost ==> {
2013-11-07 14:31:18,670 DEBUG [operate-59] p.l.execute localhost ==> /usr/bin/rsync -e '/usr/bin/ssh -o "StrictHostKeyChecking no" -p 22' -F -F -r --delete --copy-links --exclude "qlauncher.properties" --exclude "data
@tbatchelli
tbatchelli / core.clj
Created July 26, 2013 23:27
Sieve of Erastothenes as a data-flow using core.async (http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes)
(ns sieve.core
(:require [clojure.core.async :as async :refer :all]]))
(defn counter-stream [n]
(let [c (chan)]
(go
(loop [i n]
(>! c i)
(recur (inc i))))
c))
@tbatchelli
tbatchelli / project.clj
Created July 9, 2013 21:58
project.clj for storm-deploy using jclouds 1.5.2
(defproject storm-deploy "0.0.6-SNAPSHOT"
:source-paths ["src/clj"]
:test-paths ["test/clj"]
:profiles {:dev {:resource-paths ["conf"]}}
:aliases {"deploy-storm" ["run" "-m" "backtype.storm.provision"]}
:repositories {
"sonatype" "https://oss.sonatype.org/content/repositories/releases"
"jclouds-snapshot" "https://oss.sonatype.org/content/repositories/snapshots"
}

Pallet Cheatsheet

by namespace

  • action
    • with-action-options
    • declare-action
  • defaction
(bootstrap-ns dobladez
'[[com.palletops/java-crate "0.8.5-beta.5"]
[com.palletops/mongodb-crate "0.1.0-SNAPSHOT"]
[com.palletops/upstart-crate "0.8.0-alpha.2"]])
(ns dobladez
(:require [pallet.crate.java :as java]
[pallet.crate.mongodb :as mongodb]
[pallet.crate.upstart :as upstart]
[pallet.api :as api]
[pallet.actions :as actions]))
@tbatchelli
tbatchelli / logback-test.xml
Created June 6, 2013 13:43
pallet's verbose logger
<configuration scan="true" scanPeriod="1 seconds" debug="false">
<!-- <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" /> -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>