This file contains 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
(loop [sec 0 | |
good 0] | |
(let [{:keys [out exit] :as result} (ping! host)] | |
(print (if (zero? exit) "#" ".")) | |
(flush) | |
(let [new-sec (inc sec) | |
clear? (= new-sec 60) | |
new-good (if (zero? exit) (inc good) good)] | |
(when clear? | |
(println (summarize good))) |
This file contains 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 cping.core | |
(:gen-class) | |
(:require [clojure.java.shell :as shell :refer [sh]] | |
[clojure.core.async :refer [queue go-loop timeout chan <! put!]])) | |
(defn- ping! | |
"Use the shell to ping the given host" | |
[host] | |
(sh "ping" "-W" "1" "-c" "1" host)) |
This file contains 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
#!/bin/bash | |
db="${PWD}/data" | |
log_file="${db}/postgres.log" | |
port=9999 | |
#------------------------------------------------------------------------------ | |
function is_alive() { | |
result=$(pg_ctl status -p ${port} -D ${db} | grep "server is running") |
This file contains 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
(defn- handle-change | |
[e owner field] | |
(om/set-state! owner field (value! owner (name field)))) | |
(defn- handle-submit | |
[state owner] | |
(om/set-state! owner :error-msg "") | |
(let [{:keys [user pass]} (om/get-state owner) | |
creds {:user user :pass pass} | |
response (chan)] |
This file contains 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
(set-env! | |
:src-paths #{"src" "src-cljs"} | |
:rsc-paths #{"resources"} | |
:dependencies '[[org.clojure/clojure "1.7.0-alpha3"] | |
[org.clojure/core.async "0.1.346.0-17112a-alpha"] | |
[compojure "1.2.1"] | |
[http-kit "2.1.19"] | |
[org.clojure/data.json "0.2.5"] | |
[org.clojure/tools.logging "0.3.1"] | |
[ch.qos.logback/logback-classic "1.1.2"] |
This file contains 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: clojure; -*- | |
(set-env! | |
:src-paths #{"src/clj" "src/cljs"} | |
:rsc-paths #{"resources"} | |
:update :always | |
:dependencies '[[org.clojure/clojure "1.7.0-alpha4"] | |
[org.clojure/core.async "0.1.346.0-17112a-alpha"] | |
[com.taoensso/timbre "3.3.1-1cd4b70"] | |
[http-kit "2.1.19"] |
This file contains 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 lib.fs | |
;; | |
;; File system utilities | |
;; | |
(:require | |
[clojure.string :refer [lower-case join trim]] | |
[clojure.java.io :as io]) | |
(:import | |
[java.util.zip ZipInputStream])) |
This file contains 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 afile.core | |
(:require | |
[clojure.edn :as edn] | |
[clojure.pprint :refer [pprint]] | |
[clojure.test :refer [deftest is run-tests]])) | |
(defn- load-file! | |
[fname init-value] | |
(let [f (java.io.File. fname)] | |
(if (.exists f) |
OlderNewer