Skip to content

Instantly share code, notes, and snippets.

View hiredman's full-sized avatar

Kevin Downey hiredman

View GitHub Profile
(import '(java.net ServerSocket Socket)
'(java.io PushbackReader BufferedReader
InputStreamReader OutputStreamWriter
PrintWriter))
(let [a (ServerSocket. 4445)]
(loop []
(let [b (.accept a)]
(with-open [in (-> b .getInputStream InputStreamReader. BufferedReader. PushbackReader.)
out (-> b .getOutputStream OutputStreamWriter. PrintWriter.)]
(ns hiredman.uucode)
;;Each data line starts with a character indicating the number
;;of data bytes encoded on that line and ends with a newline
;;character. All data lines, except perhaps the last, encode
;;45 bytes of data.
(def x "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.")
(ns hiredman.schedule
(:import (java.util.concurrent ScheduledThreadPoolExecutor TimeUnit)))
(def unit {:minutes TimeUnit/MINUTES :seconds TimeUnit/SECONDS :hours TimeUnit/HOURS})
(def tasks (ref {}))
(def #^{:doc "ScheduledThreadPoolExecutor for scheduling repeated/delayed tasks"}
task-runner (ScheduledThreadPoolExecutor. (+ 1 (.availableProcessors (Runtime/getRuntime)))))
#!/bin/sh
classpath="clojure/clojure-1.0.0.jar:./classes/:."
download-clojure(){
wget http://clojure.googlecode.com/files/clojure_1.0.0.zip 2> /dev/null
unzip clojure_1.0.0.zip > /dev/null
}
create-test-file() {
hostname="circe.nexus.lan"
ifconfig_re0="ether 00:1d:7d:78:2a:69"
wlans_ath0="wlan0"
ifconfig_wlan0="WPA"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto failover laggport re0 laggport wlan0 DHCP"
(defn search-tickets-for [term]
(-> term search zip-soup first :content
((partial filter #(= :body (:tag %)))) first :content
((partial filter #(= :div (:tag %))))
((partial filter #(= "content" ((comp :id :attrs) %))))
((partial map :content)) first ((partial map :content))
((partial map first)) ((partial filter #(= :ul (:tag %)))) first :content
((partial map :content))
((partial map first))
((partial mapcat :content))
(defn replace-with [str map]
(reduce #(.replaceAll % (first %2) (second %2)) str map))
;(replace-with "foo bar baz" {"bar" "beep"})
(ns hiredman.deps)
(defn ffile [file]
(if (string? file)
(java.io.File. file)
file))
(defn read-ns [file]
(with-open [f (-> file ffile java.io.FileReader.
# $FreeBSD: src/share/skel/dot.login_conf,v 1.3 2001/06/10 17:08:53 ache Exp $
#
# see login.conf(5)
#
me:\
:charset=en_US.UTF-8:\
:lang=en_US.UTF-8:\
:timezone=America/Los_Angeles
#:timezone=Asia/Seoul
#:coredumpsize=0:\
(defn action [agent fn args solo?]
(proxy [clojure.lang.AAction] [agent fn args solo?]
(execute [] (prn :foo))))
(defn faux-agent [action-maker init]
(proxy [clojure.lang.Agent] [init]
(getAction [fn args solo?]
(action-maker this fn args solo?))))