Skip to content

Instantly share code, notes, and snippets.

View hiredman's full-sized avatar

Kevin Downey hiredman

View GitHub Profile
(import '(java.io BufferedReader IOException InputStream InputStreamReader OutputStreamWriter)
'(java.net URL URLConnection URLEncoder)
'(sun.misc BASE64Encoder))
(def update-url "https://twitter.com/statuses/update.xml")
(defn creds [username password]
(.trim (.encode (BASE64Encoder.) (.getBytes (str username ":" password)))))
(defn twitter [username password text]
build/hiredman/astro.class: hiredman/astro.clj build/.clojure build/.tagsoup
${CLOJURE} -e "(compile 'hiredman.astro)"
build/version:
echo ${VERSION} > build/version
astro.jar: build/hiredman/astro.class build/version
jar cevf hiredman.astro astro.jar -C build/ . > /dev/null
@du -hs astro.jar
(import '(javax.swing JFrame JTextArea JPanel UIManager SwingUtilities JScrollPane BoxLayout)
'(java.awt.event ActionListener KeyAdapter)
'(java.io StringReader PrintWriter PushbackReader Writer StringReader OutputStreamWriter)
'(java.awt GridLayout FlowLayout)
'(java.util.concurrent LinkedBlockingQueue ArrayBlockingQueue)
'(clojure.lang IDeref Associative LineNumberingPushbackReader))
(. UIManager (setLookAndFeel (. UIManager (getSystemLookAndFeelClassName))))
(defn fn->kl [fun]
(def a (into-array Byte/TYPE
(let [a (java.util.ArrayList. (map byte (range 6000)))]
(java.util.Collections/shuffle a)
a)))
(set! *warn-on-reflection* true)
(defn byte-array-contains? [coll key]
"scans a byte array for a given value"
(let [c (int (count coll))
(defn get-url [x]
(with-open [a (-> (doto (-> x URL. .openConnection)
(.setRequestProperty "User-Agent" "clojurebot"))
.getInputStream InputStreamReader. BufferedReader.)]
(loop [buf (StringBuilder.) line (.readLine a)]
(if line
(recur (doto buf (.append line)) (.readLine a))
(.toString buf)))))
(import '(java.util.concurrent BlockingQueue SynchronousQueue ArrayBlockingQueue))
(defstruct token :count :value)
(defn thread-factory
([#^BlockingQueue in term pred #^String name #^BlockingQueue out]
(.start
(Thread.
(fn []
(let [t (.take in)]
*default host=CHANGE_THIS.FreeBSD.org
*default base=/var/db
*default prefix=/usr
*default release=cvs tag=RELENG_7
*default delete use-rel-suffix
*default compress
src-all
(defn sig [x]
(:sig (meta (resolve x))))
(defmulti type-of (comp type first list))
(defmethod type-of :function [thing & _] (sig thing))
(defmethod type-of java.util.List [expr & a]
(conj (map #(type-of % (first a)) (rest expr))
(ns hiredman.zip
(:import (java.util.zip ZipEntry ZipOutputStream ZipInputStream)
(java.io ByteArrayInputStream ByteArrayOutputStream)))
(defn pad-to-8 [string]
(if (> 8 (count string))
(recur (.concat "0" string))
string))
(defn zip-string [string]
#/bin/sh!
mkdir AOT_TEST
cd AOT_TEST
mkdir foo
mkdir classes
echo "(ns foo.bar (:gen-class)) (defn -main [] (println \"foo\"))" > foo/bar.clj
$1 -cp $2:./classes:. clojure.main -e "(compile 'foo.bar)"
$1 -cp $2:./classes:. foo.bar
rm -rf foo
rm -rf classes