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
(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
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 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
# -*- 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
;; 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
(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
function e(a){throw a;}var f=void 0,k=!0,l=null,m=!1;function aa(){return function(a){return a}}function n(a){return function(){return this[a]}}function o(a){return function(){return a}}var p; | |
function r(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null"; | |
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function s(a){return a!==f}function ba(a){return"string"==typeof a}function ca(a){return"number"==typeof a}function da(a){return a[ea]||(a[ea]=++fa)}var ea="closure_uid_"+Math.floor(2147483648*Math.random()).toString(36) |
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
function e(a){throw a;}var f=void 0,k=!0,l=null,m=!1;function aa(){return function(a){return a}}function n(a){return function(){return this[a]}}function o(a){return function(){return a}}var p; | |
function r(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null"; | |
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function s(a){return a!==f}function ba(a){return"string"==typeof a}function ca(a){return"number"==typeof a}function da(a){return a[ea]||(a[ea]=++fa)}var ea="closure_uid_"+Math.floor(2147483648*Math.random()).toString(36) |
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
(require '[http.async.client :as http]) | |
;; create clients | |
(def client (http/create-client)) | |
;; websocket | |
(let [latch (promise) | |
ws (http/websocket | |
client "ws://localhost:8108/socket" | |
;; text message callback |