This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let [counter (atom 0)] | |
(http-r/execute-request | |
c (http-r/prepare-request :get "http://www.nu.nl/") | |
:part (fn [resp part] | |
(swap! counter inc) | |
(println @counter) | |
(http-r/body-collect resp part)) | |
:completed (fn [resp] | |
(println (count (http/string resp))) | |
(println :parts @counter)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; counting body parts | |
(http-r/execute-request | |
c (http-r/prepare-request :get "http://localhost:8080/json") | |
:part (fn [resp part] | |
(let [counter (if (realized? (:body resp)) (:body resp) (atom 0))] | |
(swap! counter inc) | |
(println :p part) | |
[counter :continue])) | |
:completed (fn [resp] | |
(println :d @@(:body resp);atom within a promise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant::Config.run do |config| | |
config.vm.box = "lucid32" | |
config.vm.provision :puppet, :options => "--verbose --debug" | |
config.vm.provision :puppet do |puppet| | |
puppet.manifests_path = "manifests" | |
puppet.manifest_file = "default.pp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns l1 | |
(:use [clojure.core.logic | |
:only [fresh conde firsto resto run]])) | |
(defn right? | |
[a b l] | |
(or (and (== a (first l)) | |
(== b (second l))) | |
(when-let [t (next l)] | |
(recur a b t)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node 'agent1' { | |
class { 'mysql::server': config_hash => { 'root_password' => 'bar' } } | |
mysql::db { 'sampledb': | |
user => 'sampleuser', | |
password => 'letmein', | |
host => 'localhost', | |
grant => ['all'], | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns stunnr.core | |
(:require [http.async.client :as c] | |
[http.async.client.request :as r])) | |
(def results (atom [])) | |
(def requests (atom [])) | |
(def client (c/create-client)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro json-flash [method path params body] | |
(let [flash# (gensym "flash") | |
params# (assoc params flash# :flash)] | |
`(~method ~path ~params# | |
(let [r# (do ~@body) | |
r# (if-not (empty? ~flash#) | |
(assoc r# :flash ~flash#) | |
r#)] | |
(-> r# | |
json/encode-to-str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (use 'clojure.tools.logging) | |
nil | |
user=> (info "abc") | |
Sep 8, 2011 10:37:34 AM clojure.tools.logging$eval319$fn__320 invoke | |
INFO: abc | |
nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns twitter-sample | |
(:require [http.async.client :as c] | |
[org.danlarkin.json :as j])) | |
(def u "username") | |
(def p "password") | |
(defn print-user-and-text [prefix s] | |
(let [twit (j/decode-from-str s) | |
user (:screen_name (:user twit)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns explicit-client | |
(:require [http.async.client :as http])) | |
(with-open [client (http/create-client)] | |
(let [response (http/GET client "http://clojure.org")] | |
(println "status" (:code (http/status response))) | |
(println "body" (-> http/await http/string)))) |